Weblogic Authors: Yeshim Deniz, Elizabeth White, Michael Meiner, Michael Bushong, Avi Rosenthal

Related Topics: Weblogic

Weblogic: Article

Developing JAX-RPC-based Web Services

Developing JAX-RPC-based Web Services

Web services are a type of service that can be shared by and used as components of distributed, Web-based applications. They are based on a collection of standards and protocols that allow us to make processing requests to remote systems by speaking a common, nonproprietary language and using common protocols (like HTTP, SOAP).

The Java API for XML-based remote procedure calls (JAX-RPC) simplifies the process of building Web services that incorporate XML-based RPC. It defines mappings between Java types and XML types that attempt to hide the details of XML and provide a familiar method-call paradigm. This article looks at how developers can use JAX-RPC to implement and call SOAP-based Web services described by the Web Services Description Language (WSDL) on the BEA WebLogic platform.

JAX-RPC-Based Web Services
JAX-RPC fully embraces the heterogeneous nature of Web services. It allows a JAX-RPC client to talk to another Web service deployed on a different platform and coded in a different language. JAX-RPC provides the specification for invocation modes, client generation, parameter modes, mappings for Java to WSDL and WSDL to Java, and client-side APIs for invoking the Web service.

Invocation Modes and Clients
JAX-RPC supports three kinds of Web services invocation modes:

  • Synchronous request-response: A client invokes a remote method on a Web service; the thread blocks while it is processed by the Web service and receives a return value or an exception.
  • One-way RPC mode: A client invokes a remote method on a Web service in one-way mode; the thread does not block and continues execution. The client gets no return value.
  • Nonblocking RPC mode: A client invokes a remote method on a Web service and continues processing in the same thread. Later, the client processes the remote method by performing blocking, receive, or polling for return values.

    With these modes, JAX-RPC supports two types of Java client applications - namely, static client and dynamic client. In this article, we will see how both Java clients can be written or generated using synchronous request-response mode on the WebLogic platform.

    Parameter Modes
    The Web service invocation based on JAX-RPC uses pass-by-copy semantics for parameter passing. It does not support the pass-by-reference way of parameter passing. The following types of parameters are supported by jax-rpc:

  • IN type: An IN parameter is passed as copy. The value of the IN parameter is copied before a Web service invocation. The return value is created as a copy and returned to the Web service client.
  • OUT type: An OUT parameter is passed as copy without any input value to the Web service method. The Web service method fills the OUT parameter and returns it to the client.
  • INOUT type: An INOUT parameter is passed as copy with an input value to the Web service method. The Web service method uses the input value, processes it, fills the INOUT parameter with a new value, and returns it to the client.

    The parameter passing mode for out and inout parameters uses holder classes. Holder classes enable the mapping to preserve the intended WSDL signature and parameter-passing semantics. The JAX-RPC specification includes "holder classes" for the mapping of simple XML types to the Java data types. The holder classes for primitive ones (e.g., int, float, etc.) are available with JAX-RPC implementation under the avax.xml.rpc.holders package. For the complex XML data types, the name of the holder class is constructed by appending Holder to the name of the corresponding Java class. These generated holder classes are packaged as part of the generated subpackage named holders in the WSDL-to-Java mapping.

    Each holder class provides the following methods and fields:

  • A public field named "value": The mapped Java type
  • A default constructor: Initializes the value field to a default value
  • A constructor: Sets the value field to the passed parameter

    Web Service Invocation
    BEA WebLogic 7.0 comes with a JAX-RPC 1.0-compliant runtime engine, which has both client-side and service-side libraries and deployment tools. Figure 1 shows a normal Web service invocation flow for synchronous request-response mode. The client application uses WebLogic's JAX-RPC runtime to perform a remote procedure call to invoke a method on the Web service. The runtime serializes Java objects to the SOAP message, which is sent to the Web service end point using HTTP transport. On the Web service side, WebLogic Platform receives this request and the service side JAX-RPC runtime deserializes the SOAP message into Java types and invokes the method on the Web service. The Web service, after processing the request, sends the response back to the client in a similar fashion.

    I have explained the simple Web service invocation based on JAX-RPC. The remainder of this article develops a sample Web service, and a static and dynamic client for it, on the WebLogic platform.

    An Order Processing Web Service
    I chose an order processing example for its proximity to a real busines-use case. This Web service will be capable of processing and updating a given "Order" using two methods - processOrder and updateOrder. ProcessOrder will take orderID string as an IN parameter and Order object as an OUT parameter. It will return status string as the return parameter. The updateOrder will take Order object as the INOUT parameter, update the orderDate, and return the Order object back to client. As both methods use a complex datatype, Order, that is also an OUT/INOUT parameter, a holder class has to be developed. The Order class and its holder class are shown in Listings 1 and 2 (the complete code can be found on the Web at www.sys-con.com/weblogic/sourcec.cfm):

    Now let's develop our Web service for the described functionality. The code is shown in Listing 3.

    The next step is to compile and deploy it on the WebLogic platform. WebLogic comes with some easy-to-use deployment tools using Ant (Apache's build tool) and includes predefined tasks for deploying the service on WebLogic Server 7.0. The sample "build.xml" is shown in Listing 4. This build file will generate an EAR file that will store information about the service endpoint, deployment descriptor (web-services.xml), and serializer and deserializer code (OrderCodec class); and will even generate a static client in the sample.client package and bundle it in a JAR file. The deployment descriptor (web-services.xml; it can be found in 'web-services.war' in 'ws_order.ear') has to be changed for the style of the parameter so the first method is OUT and the second method is INOUT. Once these changes are complete, repackage whole files into the EAR file (ws_order.ear) and deploy it using WebLogic's admin console. The OrderProcessing service will be available at the following URL:


    In our case it may look like :


    OrderProcessing Web Service Clients
    Static Client

    The static client to invoke a Web service uses a more strongly typed Java interface. On WebLogic, writing a static client is really easy as the Ant tasks specified above generate the client JAR, which has the following:

  • A Web service-specific implementation of the Service interface, which acts a stub factory
  • Serialization class for non-built-in data types and their Java representations
  • An interface and implementation of each SOAP port

    A client application has to use the generated classes in the client JAR. The static client is invoking the processOrder () method of the OrderProcessing Web service (see Listing 5).

    Dynamic Client
    A dynamic client is analogous to looking up and invoking the Java class methods using the reflection APIs. All the information like target endpoint and method parameters must be set explicitly. Listing 6 shows you how to write a dynamic client for invoking the updateOrder method OrderProcessing Web service.

    Running the Client
    For running both types of client, set the environment using a WebLogic-specific "setWLSEnv.bat" file. This .bat/.sh will set the classpath variable to include JAX-RPC-related jar files. Additionally, we have to add a client-specific JAR file generated by running the ant task earlier. After the environment is set, simply give the following commands:

    For the static client:
    <prompt>java sample.client.StaticClient

    For the dynamic client:
    <prompt>java sample.client.DynamicClient

    In this article I tried to demonstrate how to develop JAX-RPC-based Web services. The method described here gives the developer the freedom to write client and Web services in a way that hides all the complexities of serializing objects on-the-wire XML format. For the developer, it will simply appear to be a Java method invocation. This article also highlights how easy it is to expose a given "Java class" as a Web service.


  • http://e-docs.bea.com/wls/docs70/webserv/index.html
  • http://java.sun.com/xml/jaxrpc
  • More Stories By Rajesh Sumra

    Rajesh Sumra is a Senior Software Engineer in the Wireless Solutions Lab, Hewlett Packard. He holds a Masters degree in Information Technology from IIIT, Bangalore. He has been working with the e-speak project for more than a year and later been involved in developing UDDI Server functionalities for the HP's UDDI Server. Currently he is involved in designing and developing an Web services based framework for mobile infrastructure.

    Comments (0)

    Share your thoughts on this story.

    Add your comment
    You must be signed in to add a comment. Sign-in | Register

    In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.

    @ThingsExpo Stories
    DX World EXPO, LLC, a Lighthouse Point, Florida-based startup trade show producer and the creator of "DXWorldEXPO® - Digital Transformation Conference & Expo" has announced its executive management team. The team is headed by Levent Selamoglu, who has been named CEO. "Now is the time for a truly global DX event, to bring together the leading minds from the technology world in a conversation about Digital Transformation," he said in making the announcement.
    "Space Monkey by Vivent Smart Home is a product that is a distributed cloud-based edge storage network. Vivent Smart Home, our parent company, is a smart home provider that places a lot of hard drives across homes in North America," explained JT Olds, Director of Engineering, and Brandon Crowfeather, Product Manager, at Vivint Smart Home, in this SYS-CON.tv interview at @ThingsExpo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
    SYS-CON Events announced today that Conference Guru has been named “Media Sponsor” of the 22nd International Cloud Expo, which will take place on June 5-7, 2018, at the Javits Center in New York, NY. A valuable conference experience generates new contacts, sales leads, potential strategic partners and potential investors; helps gather competitive intelligence and even provides inspiration for new products and services. Conference Guru works with conference organizers to pass great deals to gre...
    The Internet of Things will challenge the status quo of how IT and development organizations operate. Or will it? Certainly the fog layer of IoT requires special insights about data ontology, security and transactional integrity. But the developmental challenges are the same: People, Process and Platform. In his session at @ThingsExpo, Craig Sproule, CEO of Metavine, demonstrated how to move beyond today's coding paradigm and shared the must-have mindsets for removing complexity from the develop...
    In his Opening Keynote at 21st Cloud Expo, John Considine, General Manager of IBM Cloud Infrastructure, led attendees through the exciting evolution of the cloud. He looked at this major disruption from the perspective of technology, business models, and what this means for enterprises of all sizes. John Considine is General Manager of Cloud Infrastructure Services at IBM. In that role he is responsible for leading IBM’s public cloud infrastructure including strategy, development, and offering m...
    "Evatronix provides design services to companies that need to integrate the IoT technology in their products but they don't necessarily have the expertise, knowledge and design team to do so," explained Adam Morawiec, VP of Business Development at Evatronix, in this SYS-CON.tv interview at @ThingsExpo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
    To get the most out of their data, successful companies are not focusing on queries and data lakes, they are actively integrating analytics into their operations with a data-first application development approach. Real-time adjustments to improve revenues, reduce costs, or mitigate risk rely on applications that minimize latency on a variety of data sources. In his session at @BigDataExpo, Jack Norris, Senior Vice President, Data and Applications at MapR Technologies, reviewed best practices to ...
    Widespread fragmentation is stalling the growth of the IIoT and making it difficult for partners to work together. The number of software platforms, apps, hardware and connectivity standards is creating paralysis among businesses that are afraid of being locked into a solution. EdgeX Foundry is unifying the community around a common IoT edge framework and an ecosystem of interoperable components.
    Large industrial manufacturing organizations are adopting the agile principles of cloud software companies. The industrial manufacturing development process has not scaled over time. Now that design CAD teams are geographically distributed, centralizing their work is key. With large multi-gigabyte projects, outdated tools have stifled industrial team agility, time-to-market milestones, and impacted P&L stakeholders.
    "Akvelon is a software development company and we also provide consultancy services to folks who are looking to scale or accelerate their engineering roadmaps," explained Jeremiah Mothersell, Marketing Manager at Akvelon, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
    "IBM is really all in on blockchain. We take a look at sort of the history of blockchain ledger technologies. It started out with bitcoin, Ethereum, and IBM evaluated these particular blockchain technologies and found they were anonymous and permissionless and that many companies were looking for permissioned blockchain," stated René Bostic, Technical VP of the IBM Cloud Unit in North America, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Conventi...
    In his session at 21st Cloud Expo, Carl J. Levine, Senior Technical Evangelist for NS1, will objectively discuss how DNS is used to solve Digital Transformation challenges in large SaaS applications, CDNs, AdTech platforms, and other demanding use cases. Carl J. Levine is the Senior Technical Evangelist for NS1. A veteran of the Internet Infrastructure space, he has over a decade of experience with startups, networking protocols and Internet infrastructure, combined with the unique ability to it...
    22nd International Cloud Expo, taking place June 5-7, 2018, at the Javits Center in New York City, NY, and co-located with the 1st DXWorld Expo will feature technical sessions from a rock star conference faculty and the leading industry players in the world. Cloud computing is now being embraced by a majority of enterprises of all sizes. Yesterday's debate about public vs. private has transformed into the reality of hybrid cloud: a recent survey shows that 74% of enterprises have a hybrid cloud ...
    "Cloud Academy is an enterprise training platform for the cloud, specifically public clouds. We offer guided learning experiences on AWS, Azure, Google Cloud and all the surrounding methodologies and technologies that you need to know and your teams need to know in order to leverage the full benefits of the cloud," explained Alex Brower, VP of Marketing at Cloud Academy, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clar...
    Gemini is Yahoo’s native and search advertising platform. To ensure the quality of a complex distributed system that spans multiple products and components and across various desktop websites and mobile app and web experiences – both Yahoo owned and operated and third-party syndication (supply), with complex interaction with more than a billion users and numerous advertisers globally (demand) – it becomes imperative to automate a set of end-to-end tests 24x7 to detect bugs and regression. In th...
    "MobiDev is a software development company and we do complex, custom software development for everybody from entrepreneurs to large enterprises," explained Alan Winters, U.S. Head of Business Development at MobiDev, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
    Coca-Cola’s Google powered digital signage system lays the groundwork for a more valuable connection between Coke and its customers. Digital signs pair software with high-resolution displays so that a message can be changed instantly based on what the operator wants to communicate or sell. In their Day 3 Keynote at 21st Cloud Expo, Greg Chambers, Global Group Director, Digital Innovation, Coca-Cola, and Vidya Nagarajan, a Senior Product Manager at Google, discussed how from store operations and ...
    "There's plenty of bandwidth out there but it's never in the right place. So what Cedexis does is uses data to work out the best pathways to get data from the origin to the person who wants to get it," explained Simon Jones, Evangelist and Head of Marketing at Cedexis, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
    SYS-CON Events announced today that CrowdReviews.com has been named “Media Sponsor” of SYS-CON's 22nd International Cloud Expo, which will take place on June 5–7, 2018, at the Javits Center in New York City, NY. CrowdReviews.com is a transparent online platform for determining which products and services are the best based on the opinion of the crowd. The crowd consists of Internet users that have experienced products and services first-hand and have an interest in letting other potential buye...
    SYS-CON Events announced today that Telecom Reseller has been named “Media Sponsor” of SYS-CON's 22nd International Cloud Expo, which will take place on June 5-7, 2018, at the Javits Center in New York, NY. Telecom Reseller reports on Unified Communications, UCaaS, BPaaS for enterprise and SMBs. They report extensively on both customer premises based solutions such as IP-PBX as well as cloud based and hosted platforms.