Java Web Services

Source: Internet
Author: User
Tags soap web services xmlns java web wsdl

The early Apache Axis was built on the first WEB service-oriented Java standard JAX-RPC Foundation. This is not a good approach, as it turns out, because Jax-RPC restricts the internal design of the Axis code and creates performance problems and lacks flexibility. JAX-RPC also makes assumptions about the direction of Web service development, which later proved to be wrong.

When you start AXIS2 development, you are already working on the alternatives to Jax-RPC, so Axis2 has considered enough flexibility at design time to enable it to implement the support of alternative WEB service standards over the underlying framework. The latest AXIS2 version also implements support for the JAXB 2.x Java XML Data binding standard and replaces the JAX-RP Jax-ws 2.x Java WEB Service standard. This article will show you how to use JAXB and Jax-ws for Axis2 and find out some of the limitations of AXIS2 's current support for these standards.

JAXB in the Axis2

AXIS2 implements support for JAXB 2.x as one of the alternatives to data binding, and you can choose to generate code from the WEB services Description Language (WSDL) service definition using Wsdl2java. As with most alternative alternatives, a set of link (linkage) classes and a set of data model classes are created using the code generated by JAXB 2.x from WSDL. These link classes, which include a client stub and a server-side message sink, act as interfaces between application code and AXIS2. The data model class represents the actual message data.

JAXB 2.x uses annotations in the data model class to control how data is converted from XML. The annotation method allows you to use a different JAXB implementation at run time without modifying the source code or recompiling the class. The JAXB implementation is responsible for accessing annotation information from the data model classes and applying these annotations when performing XML transformations.

Code downloads (see downloads) provide a sample application demonstrating the use of JAXB in Axis2, located in the JAXB directory. This application is another version of the Simple Library Management Service in the previous article in this series (including data binding comparisons in the AXIS2 data Binding). The WSDL service definition defines four actions:

GetBook is used to retrieve details about a particular book identified by International Standard Books number (ISBN)

Getbooksbytype is used to retrieve details about all books of a particular type

GetTypes is used to find available book types

Addbook is used to add new books to the library

Listing 1 shows a heavily edited WSDL that contains only the parts related to the GetBook operation:

Listing 1. Library Service WSDL

<wsdl:definitions targetnamespace= "http://ws.sosnoski.com/library/wsdl"


xmlns:wns= "HTTP://WS.SOSNOSKI.COM/LIBRARY/WSDL"


xmlns:tns= "Http://ws.sosnoski.com/library/types"


xmlns:wsdl= "http://schemas.xmlsoap.org/wsdl/"


xmlns:wsdlsoap= "http://schemas.xmlsoap.org/wsdl/soap/" >


<wsdl:types>





<schema elementformdefault= "qualified"


targetnamespace= "HTTP://WS.SOSNOSKI.COM/LIBRARY/WSDL"


xmlns= "Http://www.w3.org/2001/XMLSchema" >





<import namespace= "Http://ws.sosnoski.com/library/types"


schemalocation= "Types.xsd"/>





<element name= "GetBook" >


<complexType>


<sequence>


<element name= "ISBN" type= "string"/>


</sequence>


</complexType>


</element>





<element name= "Getbookresponse" >


<complexType>


<sequence>


<element name= "Getbookreturn" minoccurs= "0" type= "tns:bookinformation"/>


</sequence>


</complexType>


</element>


    ...





</schema>





</wsdl:types>





<wsdl:message name= "Getbookrequest" >


<wsdl:part element= "Wns:getbook" name= "parameters"/>


</wsdl:message>





<wsdl:message name= "Getbookresponse" >


<wsdl:part element= "wns:getbookresponse" name= parameters "/>"


</wsdl:message>


  ...





<wsdl:porttype name= "Library" >





<wsdl:operation name= "GetBook" >


<wsdl:input message= "wns:getbookrequest" name= getbookrequest "/>"


<wsdl:output message= "wns:getbookresponse" name= getbookresponse "/>"


</wsdl:operation>


   ...





</wsdl:portType>





<wsdl:binding name= "librarysoapbinding" type= "Wns:library" >





<wsdlsoap:binding style= "Document"


transport= "Http://schemas.xmlsoap.org/soap/http"/>





<wsdl:operation name= "GetBook" >





<wsdlsoap:operation soapaction= "Urn:getbook"/>





<wsdl:input name= "Getbookrequest" >


<wsdlsoap:body use= "literal"/>


</wsdl:input>





<wsdl:output name= "Getbookresponse" >


<wsdlsoap:body use= "literal"/>


</wsdl:output>





</wsdl:operation>


   ...





</wsdl:binding>





<wsdl:service name= "Jaxb-library" >





<wsdl:port binding= "wns:librarysoapbinding" name= "Library" >


<wsdlsoap:address location= "http://localhost:8080/axis2/services/jaxb-library"/>


</wsdl:port>





</wsdl:service>





</wsdl:definitions>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.