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
    Organizations planning enterprise data center consolidation and modernization projects are faced with a challenging, costly reality. Requirements to deploy modern, cloud-native applications simultaneously with traditional client/server applications are almost impossible to achieve with hardware-centric enterprise infrastructure. Compute and network infrastructure are fast moving down a software-defined path, but storage has been a laggard. Until now.
    Digital Transformation is much more than a buzzword. The radical shift to digital mechanisms for almost every process is evident across all industries and verticals. This is often especially true in financial services, where the legacy environment is many times unable to keep up with the rapidly shifting demands of the consumer. The constant pressure to provide complete, omnichannel delivery of customer-facing solutions to meet both regulatory and customer demands is putting enormous pressure on...
    In his general session at 19th Cloud Expo, Manish Dixit, VP of Product and Engineering at Dice, discussed how Dice leverages data insights and tools to help both tech professionals and recruiters better understand how skills relate to each other and which skills are in high demand using interactive visualizations and salary indicator tools to maximize earning potential. Manish Dixit is VP of Product and Engineering at Dice. As the leader of the Product, Engineering and Data Sciences team at D...
    DXWorldEXPO LLC announced today that All in Mobile, a mobile app development company from Poland, will exhibit at the 22nd International CloudEXPO | DXWorldEXPO. All In Mobile is a mobile app development company from Poland. Since 2014, they maintain passion for developing mobile applications for enterprises and startups worldwide.
    "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.
    IoT is at the core or many Digital Transformation initiatives with the goal of re-inventing a company's business model. We all agree that collecting relevant IoT data will result in massive amounts of data needing to be stored. However, with the rapid development of IoT devices and ongoing business model transformation, we are not able to predict the volume and growth of IoT data. And with the lack of IoT history, traditional methods of IT and infrastructure planning based on the past do not app...
    DXWorldEXPO LLC announced today that the upcoming DXWorldEXPO | CloudEXPO New York event will feature 10 companies from Poland to participate at the "Poland Digital Transformation Pavilion" on November 12-13, 2018.
    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 ...
    @DevOpsSummit at Cloud Expo, taking place November 12-13 in New York City, NY, is co-located with 22nd international CloudEXPO | first international DXWorldEXPO and will feature technical sessions from a rock star conference faculty and the leading industry players in the world.
    More and more brands have jumped on the IoT bandwagon. We have an excess of wearables – activity trackers, smartwatches, smart glasses and sneakers, and more that track seemingly endless datapoints. However, most consumers have no idea what “IoT” means. Creating more wearables that track data shouldn't be the aim of brands; delivering meaningful, tangible relevance to their users should be. We're in a period in which the IoT pendulum is still swinging. Initially, it swung toward "smart for smart...
    As data explodes in quantity, importance and from new sources, the need for managing and protecting data residing across physical, virtual, and cloud environments grow with it. Managing data includes protecting it, indexing and classifying it for true, long-term management, compliance and E-Discovery. Commvault can ensure this with a single pane of glass solution – whether in a private cloud, a Service Provider delivered public cloud or a hybrid cloud environment – across the heterogeneous enter...
    DXWorldEXPO LLC announced today that ICC-USA, a computer systems integrator and server manufacturing company focused on developing products and product appliances, will exhibit at the 22nd International CloudEXPO | DXWorldEXPO. DXWordEXPO New York 2018, colocated with CloudEXPO New York 2018 will be held November 11-13, 2018, in New York City. ICC is a computer systems integrator and server manufacturing company focused on developing products and product appliances to meet a wide range of ...
    Michael Maximilien, better known as max or Dr. Max, is a computer scientist with IBM. At IBM Research Triangle Park, he was a principal engineer for the worldwide industry point-of-sale standard: JavaPOS. At IBM Research, some highlights include pioneering research on semantic Web services, mashups, and cloud computing, and platform-as-a-service. He joined the IBM Cloud Labs in 2014 and works closely with Pivotal Inc., to help make the Cloud Found the best PaaS.
    Headquartered in Plainsboro, NJ, Synametrics Technologies has provided IT professionals and computer systems developers since 1997. Based on the success of their initial product offerings (WinSQL and DeltaCopy), the company continues to create and hone innovative products that help its customers get more from their computer applications, databases and infrastructure. To date, over one million users around the world have chosen Synametrics solutions to help power their accelerated business or per...
    In an era of historic innovation fueled by unprecedented access to data and technology, the low cost and risk of entering new markets has leveled the playing field for business. Today, any ambitious innovator can easily introduce a new application or product that can reinvent business models and transform the client experience. In their Day 2 Keynote at 19th Cloud Expo, Mercer Rowe, IBM Vice President of Strategic Alliances, and Raejeanne Skillern, Intel Vice President of Data Center Group and ...
    Dion Hinchcliffe is an internationally recognized digital expert, bestselling book author, frequent keynote speaker, analyst, futurist, and transformation expert based in Washington, DC. He is currently Chief Strategy Officer at the industry-leading digital strategy and online community solutions firm, 7Summits.
    Founded in 2000, Chetu Inc. is a global provider of customized software development solutions and IT staff augmentation services for software technology providers. By providing clients with unparalleled niche technology expertise and industry experience, Chetu has become the premiere long-term, back-end software development partner for start-ups, SMBs, and Fortune 500 companies. Chetu is headquartered in Plantation, Florida, with thirteen offices throughout the U.S. and abroad.
    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...
    From 2013, NTT Communications has been providing cPaaS service, SkyWay. Its customer’s expectations for leveraging WebRTC technology are not only typical real-time communication use cases such as Web conference, remote education, but also IoT use cases such as remote camera monitoring, smart-glass, and robotic. Because of this, NTT Communications has numerous IoT business use-cases that its customers are developing on top of PaaS. WebRTC will lead IoT businesses to be more innovative and address...
    Rodrigo Coutinho is part of OutSystems' founders' team and currently the Head of Product Design. He provides a cross-functional role where he supports Product Management in defining the positioning and direction of the Agile Platform, while at the same time promoting model-based development and new techniques to deliver applications in the cloud.