Developing Web Services (JAX-WS) in WebLogic using Oracle Enterprise Pack for Eclipse(OEPE) – A Tutorial

Short Link: http://wp.me/p5Jvc-aU

It’s been a long time since that I am writing a blog post. Since last few days I have been playing around with implementing JAX-WS Web Services on WebLogic Server. This blog post intends to cover three aspects. Creating web services using the top-down, the bottom-up approach and implementing WS-Security semantics for WebLogic web services.

First a brief walk thru of the development environment. I am running the WebLogic server configuration in Windows 7 environment. I have downloaded and installed the Weblogic Server version 10.3.5.0. I have downloaded the Oracle Enterprise Pack for Eclipse (OEPE) version 12.1.1.0. The OEPE is my integrated development environment for the Web service project. Now that I have established the project pre-requisites, let’s move on to the nitty gritty of creating a web service.

Web Service using the top-down (WSDL First) method

In the Eclipse’s top menu click File –> New –> Web Service Project. In the Web Service project creation wizard page, enter project name as OnlineStore, select Oracle Weblogic Server 11gR1 (10.3.5). 10.3.5 version is selected because the installed Weblogic server version should match the target runtime version. Retain the default Oracle Weblogic Server configuration option. Leave the EAR membership and Working Sets check boxes unchecked. In the next wizard page i.e. the Java page retain the default settings. In the subsequent Web Module wizard page set the context root as onlinestore, retain the default settings for Context Directory and leave the Generate web.xml deployment descriptor checkbox checked. Click Finish to initiate the Web Service project creation.

On successful creation of the project, the project directory structure will be as follows:

  • JAX-WS Web Services
  • Referenced Types
  • Java Resources (Source code for Web Services and back end processing related artifacts)
  • JavaScript Resources
  • build
  • javadoc
  • WebContent (Miscellaneous web application related artifacts)

Create a new WSDL file customer.wsdl within the WebContent directory. The contents of the WSDL file are shown below:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://buymore.com/online/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="customer" targetNamespace="http://buymore.com/online/"
	xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
  <wsdl:types>
    <xsd:schema targetNamespace="http://buymore.com/online/">
     <xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/" schemaLocation="soap-encoding.xsd"/>
      <xsd:element name="SearchInput">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="id" type="xsd:string"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="CustomerResponse">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="fName" type="xsd:string"/>
            <xsd:element name="lName" type="xsd:string"/>
            <xsd:element ref="tns:Addresses"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="Addresses">
      		<xsd:complexType>
      			<xsd:complexContent>
      				<xsd:restriction base="soapenc:Array">
      					<xsd:attribute  ref="soapenc:arrayType" wsdl:arrayType="tns:Address[]" /> 
      				</xsd:restriction>
      			</xsd:complexContent>
			</xsd:complexType>
      </xsd:element> 
      <xsd:element name="Phones">
      		<xsd:complexType>
      			<xsd:complexContent>
      				<xsd:restriction base="soapenc:Array">
      					<xsd:attribute  ref="soapenc:arrayType" wsdl:arrayType="tns:Phone[]" /> 
      				</xsd:restriction>
      			</xsd:complexContent>
			</xsd:complexType>
      </xsd:element> 
      <xsd:element name="Address">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="line1" type="xsd:string"/>
            <xsd:element name="line2" type="xsd:string"/>
            <xsd:element name="city" type="xsd:string"/>
            <xsd:element name="state" type="xsd:string"/>
            <xsd:element name="zipCode" type="xsd:integer"/>
            <xsd:element ref="tns:Phones"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="Phone">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="countryCode" type="xsd:string"/>
            <xsd:element name="cityCode" type="xsd:string"/>
            <xsd:element name="number" type="xsd:string"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>      
    </xsd:schema>
  </wsdl:types>
  <wsdl:message name="GetCustomerRequest">
    <wsdl:part element="tns:SearchInput" name="input"/>
  </wsdl:message>
  <wsdl:message name="GetCustomerResponse">
    <wsdl:part element="tns:CustomerResponse" name="output"/>
  </wsdl:message>
  <wsdl:portType name="customerPort">
    <wsdl:operation name="getCustomerData">
      <wsdl:input message="tns:GetCustomerRequest"/>
      <wsdl:output message="tns:GetCustomerResponse"/>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="customerService" type="tns:customerPort">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="getCustomerData">
      <soap:operation soapAction="http://buymore.com/online/getCustomerData"/>
      <wsdl:input>
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="CustomerService">
    <wsdl:port binding="tns:customerService" name="Information">
      <soap:address location="http://localhost/"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

Let’s now understand the content structure of the customer.wsdl file. The root element wsdl:definitions specifies the namespace of the various elements used within the WSDL. The wsdl:types element encapsulates the data structure definitions used as a part of the SOAP message payload. For our exercise, we are developing a web service which will accept customer id as input and respond by providing information like customer’s name, addresses and phone details per address.

The first data construct defined is ‘SearchInput’ which encapsulates the customer id. Refer the following xml snippet.

      <xsd:element name="SearchInput">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="id" type="xsd:string"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>

I have defined a complex type named SearchInput which accepts a string element named id. For the response portion we define the complex type CustomerResponse. Here’s the relevant snippet.

      <xsd:element name="CustomerResponse">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="fName" type="xsd:string"/>
            <xsd:element name="lName" type="xsd:string"/>
            <xsd:element ref="tns:Addresses"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>

The entries for fName and lName are self-explanatory. We have added one more element Addresses. The element definition does not have a name attriute, but instead using a ref attribute. The reference points to a complex type definition named ‘tns:Addresses’ within the wsdl:types construct. The namespace tns points to http://buymore.com/online/ which is also the target namespace for this xml. On a related side note, the target namespace name is used to define the package name for the generated Java source. The generated package name will be com.buymore.online. The tns:Addresses reference maps to the following complex structure.

      <xsd:element name="Addresses">
      		<xsd:complexType>
      			<xsd:complexContent>
      				<xsd:restriction base="soapenc:Array">
      					<xsd:attribute  ref="soapenc:arrayType" wsdl:arrayType="tns:Address[]" /> 
      				</xsd:restriction>
      			</xsd:complexContent>
			</xsd:complexType>
      </xsd:element> 

The Addresses element definition encases an Array of the type tns:Address. This is defined using the wsdl:arrayType attribute. The element Address definition is shown in the snippet below:

      <xsd:element name="Address">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="line1" type="xsd:string"/>
            <xsd:element name="line2" type="xsd:string"/>
            <xsd:element name="city" type="xsd:string"/>
            <xsd:element name="state" type="xsd:string"/>
            <xsd:element name="zipCode" type="xsd:integer"/>
            <xsd:element ref="tns:Phones"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>

The Address element itself encases an array of Phone elements via the tns:Phones reference. The definition of tns:Phones is on similar lines to tns:Addresses and does not warrant a separate explanation.

The next construct within the WSDL is wsdl:message. Here we define the input and the output SOAP message structure.

  <wsdl:message name="GetCustomerRequest">
    <wsdl:part element="tns:SearchInput" name="input"/>
  </wsdl:message>
  <wsdl:message name="GetCustomerResponse">
    <wsdl:part element="tns:CustomerResponse" name="output"/>
  </wsdl:message>

We have defined two messages one for the input and one for the output of the Web Service operation. The first message is named GetCustomerRequest which defines that it includes the complex type element named tns:SearchInput within its assembly. The second message defines the output message construct and specifies that it uses tns:CustomerResponse and a part of its assembly.

The subsequent WSDL definition wsdl:portType defines the abstract operations supported by the Web Service. Refer the following code snippet.

  <wsdl:portType name="customerPort">
    <wsdl:operation name="getCustomerData">
      <wsdl:input message="tns:GetCustomerRequest"/>
      <wsdl:output message="tns:GetCustomerResponse"/>
    </wsdl:operation>
  </wsdl:portType>

Here we are defining an abstract operation named getCustomerData which uses the two messages tns:GetCustomerRequest and tns:GetCustomerResponse as its input and ouput. The next definition is wsdl:binding element. The wsdl:binding defines the protocol and message format details for an operation. Refer snippet.

  <wsdl:binding name="customerService" type="tns:customerPort">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="getCustomerData">
      <soap:operation soapAction="http://buymore.com/online/getCustomerData"/>
      <wsdl:input>
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>

The style and use attribute defines that the XML payload will use document/literal type of message format. The transport attribute defines that HTTP will be used as the message communication format. The last WSDL structure wsdl:service defines the service specifics such as the ports supported by the Web Service, the supported protocols etc. Web service clients can use this element to access the service from the defined ports and get details about how to communicate with the web service.

  <wsdl:service name="CustomerService">
    <wsdl:port binding="tns:customerService" name="Information">
      <soap:address location="http://localhost/"/>
    </wsdl:port>
  </wsdl:service>

To summarize the wsdl:service is a collection of end points. An end point indicates a specific location for accessing a service using a specific protocol and data format.

Update(22nd May 2012 Response to Prithviraj’s 2nd comment)
Add the following file soap-encoding.xsd within the WebContent directory. The contents of the xsd are as follows:

<?xml version='1.0' encoding='UTF-8' ?>



<!-- Schema for the SOAP/1.1 encoding



Portions © 2001 DevelopMentor. 

© 2001 W3C (Massachusetts Institute of Technology, Institut National de Recherche en Informatique et en Automatique, Keio University). All Rights Reserved.  

 

This document is governed by the W3C Software License [1] as described in the FAQ [2].

[1] http://www.w3.org/Consortium/Legal/copyright-software-19980720

[2] http://www.w3.org/Consortium/Legal/IPR-FAQ-20000620.html#DTD 

By obtaining, using and/or copying this work, you (the licensee) agree that you have read, understood, and will comply with the following terms and conditions:



Permission to use, copy, modify, and distribute this software and its documentation, with or without modification,  for any purpose and without fee or royalty is hereby granted, provided that you include the following on ALL copies of the software and documentation or portions thereof, including modifications, that you make:



1.  The full text of this NOTICE in a location viewable to users of the redistributed or derivative work. 



2.  Any pre-existing intellectual property disclaimers, notices, or terms and conditions. If none exist, a short notice of the following form (hypertext is preferred, text is permitted) should be used within the body of any redistributed or derivative code: "Copyright © 2001 World Wide Web Consortium, (Massachusetts Institute of Technology, Institut National de Recherche en Informatique et en Automatique, Keio University). All Rights Reserved. http://www.w3.org/Consortium/Legal/" 



3.  Notice of any changes or modifications to the W3C files, including the date changes were made. (We recommend you provide URIs to the location from which the code is derived.)   



Original W3C files; http://www.w3.org/2001/06/soap-encoding

Changes made: 

     - reverted namespace to http://schemas.xmlsoap.org/soap/encoding/

     - reverted root to only allow 0 and 1 as lexical values

	 - removed default value from root attribute declaration



THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.



COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION.



The name and trademarks of copyright holders may NOT be used in advertising or publicity pertaining to the software without specific, written prior permission. Title to copyright in this software and any associated documentation will at all times remain with copyright holders.



-->

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"

           xmlns:tns="http://schemas.xmlsoap.org/soap/encoding/"

           targetNamespace="http://schemas.xmlsoap.org/soap/encoding/" >

        

 <xs:attribute name="root" >

   <xs:annotation>

     <xs:documentation>

	   'root' can be used to distinguish serialization roots from other

       elements that are present in a serialization but are not roots of

       a serialized value graph 

	 </xs:documentation>

   </xs:annotation>

   <xs:simpleType>

     <xs:restriction base='xs:boolean'>

	   <xs:pattern value='0|1' />

	 </xs:restriction>

   </xs:simpleType>

 </xs:attribute>



  <xs:attributeGroup name="commonAttributes" >

    <xs:annotation>

	  <xs:documentation>

	    Attributes common to all elements that function as accessors or 

        represent independent (multi-ref) values.  The href attribute is

        intended to be used in a manner like CONREF.  That is, the element

        content should be empty iff the href attribute appears

	  </xs:documentation>

	</xs:annotation>

    <xs:attribute name="id" type="xs:ID" />

    <xs:attribute name="href" type="xs:anyURI" />

    <xs:anyAttribute namespace="##other" processContents="lax" />

  </xs:attributeGroup>



  <!-- Global Attributes.  The following attributes are intended to be usable via qualified attribute names on any complex type referencing them. -->

       

  <!-- Array attributes. Needed to give the type and dimensions of an array's contents, and the offset for partially-transmitted arrays. -->

   

  <xs:simpleType name="arrayCoordinate" >

    <xs:restriction base="xs:string" />

  </xs:simpleType>

          

  <xs:attribute name="arrayType" type="xs:string" />

  <xs:attribute name="offset" type="tns:arrayCoordinate" />

  

  <xs:attributeGroup name="arrayAttributes" >

    <xs:attribute ref="tns:arrayType" />

    <xs:attribute ref="tns:offset" />

  </xs:attributeGroup>    

  

  <xs:attribute name="position" type="tns:arrayCoordinate" /> 

  

  <xs:attributeGroup name="arrayMemberAttributes" >

    <xs:attribute ref="tns:position" />

  </xs:attributeGroup>    



  <xs:group name="Array" >

    <xs:sequence>

      <xs:any namespace="##any" minOccurs="0" maxOccurs="unbounded" processContents="lax" />

	</xs:sequence>

  </xs:group>



  <xs:element name="Array" type="tns:Array" />

  <xs:complexType name="Array" >

    <xs:annotation>

	  <xs:documentation>

	   'Array' is a complex type for accessors identified by position 

	  </xs:documentation>

	</xs:annotation>

    <xs:group ref="tns:Array" minOccurs="0" />

    <xs:attributeGroup ref="tns:arrayAttributes" />

    <xs:attributeGroup ref="tns:commonAttributes" />

  </xs:complexType> 



  <!-- 'Struct' is a complex type for accessors identified by name. 

       Constraint: No element may be have the same name as any other,

       nor may any element have a maxOccurs > 1. -->

   

  <xs:element name="Struct" type="tns:Struct" />



  <xs:group name="Struct" >

    <xs:sequence>

      <xs:any namespace="##any" minOccurs="0" maxOccurs="unbounded" processContents="lax" />

	</xs:sequence>

  </xs:group>



  <xs:complexType name="Struct" >

    <xs:group ref="tns:Struct" minOccurs="0" />

    <xs:attributeGroup ref="tns:commonAttributes"/>

  </xs:complexType> 



  <!-- 'Base64' can be used to serialize binary data using base64 encoding

       as defined in RFC2045 but without the MIME line length limitation. -->



  <xs:simpleType name="base64" >

    <xs:restriction base="xs:base64Binary" />

  </xs:simpleType>



 <!-- Element declarations corresponding to each of the simple types in the 

      XML Schemas Specification. -->



  <xs:element name="duration" type="tns:duration" />

  <xs:complexType name="duration" >

    <xs:simpleContent>

      <xs:extension base="xs:duration" >

        <xs:attributeGroup ref="tns:commonAttributes" />

      </xs:extension>

    </xs:simpleContent>

  </xs:complexType>



  <xs:element name="dateTime" type="tns:dateTime" />

  <xs:complexType name="dateTime" >

    <xs:simpleContent>

      <xs:extension base="xs:dateTime" >

        <xs:attributeGroup ref="tns:commonAttributes" />

      </xs:extension>

    </xs:simpleContent>

  </xs:complexType>







  <xs:element name="NOTATION" type="tns:NOTATION" />

  <xs:complexType name="NOTATION" >

    <xs:simpleContent>

      <xs:extension base="xs:QName" >

        <xs:attributeGroup ref="tns:commonAttributes" />

      </xs:extension>

    </xs:simpleContent>

  </xs:complexType>

  



  <xs:element name="time" type="tns:time" />

  <xs:complexType name="time" >

    <xs:simpleContent>

      <xs:extension base="xs:time" >

        <xs:attributeGroup ref="tns:commonAttributes" />

      </xs:extension>

    </xs:simpleContent>

  </xs:complexType>



  <xs:element name="date" type="tns:date" />

  <xs:complexType name="date" >

    <xs:simpleContent>

      <xs:extension base="xs:date" >

        <xs:attributeGroup ref="tns:commonAttributes" />

      </xs:extension>

    </xs:simpleContent>

  </xs:complexType>



  <xs:element name="gYearMonth" type="tns:gYearMonth" />

  <xs:complexType name="gYearMonth" >

    <xs:simpleContent>

      <xs:extension base="xs:gYearMonth" >

        <xs:attributeGroup ref="tns:commonAttributes" />

      </xs:extension>

    </xs:simpleContent>

  </xs:complexType>



  <xs:element name="gYear" type="tns:gYear" />

  <xs:complexType name="gYear" >

    <xs:simpleContent>

      <xs:extension base="xs:gYear" >

        <xs:attributeGroup ref="tns:commonAttributes" />

      </xs:extension>

    </xs:simpleContent>

  </xs:complexType>



  <xs:element name="gMonthDay" type="tns:gMonthDay" />

  <xs:complexType name="gMonthDay" >

    <xs:simpleContent>

      <xs:extension base="xs:gMonthDay" >

        <xs:attributeGroup ref="tns:commonAttributes" />

      </xs:extension>

    </xs:simpleContent>

  </xs:complexType>



  <xs:element name="gDay" type="tns:gDay" />

  <xs:complexType name="gDay" >

    <xs:simpleContent>

      <xs:extension base="xs:gDay" >

        <xs:attributeGroup ref="tns:commonAttributes" />

      </xs:extension>

    </xs:simpleContent>

  </xs:complexType>



  <xs:element name="gMonth" type="tns:gMonth" />

  <xs:complexType name="gMonth" >

    <xs:simpleContent>

      <xs:extension base="xs:gMonth" >

        <xs:attributeGroup ref="tns:commonAttributes" />

      </xs:extension>

    </xs:simpleContent>

  </xs:complexType>

  

  <xs:element name="boolean" type="tns:boolean" />

  <xs:complexType name="boolean" >

    <xs:simpleContent>

      <xs:extension base="xs:boolean" >

        <xs:attributeGroup ref="tns:commonAttributes" />

      </xs:extension>

    </xs:simpleContent>

  </xs:complexType>



  <xs:element name="base64Binary" type="tns:base64Binary" />

  <xs:complexType name="base64Binary" >

    <xs:simpleContent>

      <xs:extension base="xs:base64Binary" >

        <xs:attributeGroup ref="tns:commonAttributes" />

      </xs:extension>

    </xs:simpleContent>

  </xs:complexType>



  <xs:element name="hexBinary" type="tns:hexBinary" />

  <xs:complexType name="hexBinary" >

    <xs:simpleContent>

     <xs:extension base="xs:hexBinary" >

       <xs:attributeGroup ref="tns:commonAttributes" />

     </xs:extension>

    </xs:simpleContent>

  </xs:complexType>



  <xs:element name="float" type="tns:float" />

  <xs:complexType name="float" >

    <xs:simpleContent>

      <xs:extension base="xs:float" >

        <xs:attributeGroup ref="tns:commonAttributes" />

      </xs:extension>

    </xs:simpleContent>

  </xs:complexType>



  <xs:element name="double" type="tns:double" />

  <xs:complexType name="double" >

    <xs:simpleContent>

      <xs:extension base="xs:double" >

        <xs:attributeGroup ref="tns:commonAttributes" />

      </xs:extension>

    </xs:simpleContent>

  </xs:complexType>



  <xs:element name="anyURI" type="tns:anyURI" />

  <xs:complexType name="anyURI" >

    <xs:simpleContent>

      <xs:extension base="xs:anyURI" >

        <xs:attributeGroup ref="tns:commonAttributes" />

      </xs:extension>

    </xs:simpleContent>

  </xs:complexType>



  <xs:element name="QName" type="tns:QName" />

  <xs:complexType name="QName" >

    <xs:simpleContent>

      <xs:extension base="xs:QName" >

        <xs:attributeGroup ref="tns:commonAttributes" />

      </xs:extension>

    </xs:simpleContent>

  </xs:complexType>



  

  <xs:element name="string" type="tns:string" />

  <xs:complexType name="string" >

    <xs:simpleContent>

      <xs:extension base="xs:string" >

        <xs:attributeGroup ref="tns:commonAttributes" />

      </xs:extension>

    </xs:simpleContent>

  </xs:complexType>



  <xs:element name="normalizedString" type="tns:normalizedString" />

  <xs:complexType name="normalizedString" >

    <xs:simpleContent>

      <xs:extension base="xs:normalizedString" >

        <xs:attributeGroup ref="tns:commonAttributes" />

      </xs:extension>

    </xs:simpleContent>

  </xs:complexType>



  <xs:element name="token" type="tns:token" />

  <xs:complexType name="token" >

    <xs:simpleContent>

      <xs:extension base="xs:token" >

        <xs:attributeGroup ref="tns:commonAttributes" />

      </xs:extension>

    </xs:simpleContent>

  </xs:complexType>



  <xs:element name="language" type="tns:language" />

  <xs:complexType name="language" >

    <xs:simpleContent>

      <xs:extension base="xs:language" >

        <xs:attributeGroup ref="tns:commonAttributes" />

      </xs:extension>

    </xs:simpleContent>

  </xs:complexType>



  <xs:element name="Name" type="tns:Name" />

  <xs:complexType name="Name" >

    <xs:simpleContent>

      <xs:extension base="xs:Name" >

        <xs:attributeGroup ref="tns:commonAttributes" />

      </xs:extension>

    </xs:simpleContent>

  </xs:complexType>



  <xs:element name="NMTOKEN" type="tns:NMTOKEN" />

  <xs:complexType name="NMTOKEN" >

    <xs:simpleContent>

      <xs:extension base="xs:NMTOKEN" >

        <xs:attributeGroup ref="tns:commonAttributes" />

      </xs:extension>

    </xs:simpleContent>

  </xs:complexType>



  <xs:element name="NCName" type="tns:NCName" />

  <xs:complexType name="NCName" >

    <xs:simpleContent>

      <xs:extension base="xs:NCName" >

        <xs:attributeGroup ref="tns:commonAttributes" />

      </xs:extension>

    </xs:simpleContent>

  </xs:complexType>



  <xs:element name="NMTOKENS" type="tns:NMTOKENS" />

  <xs:complexType name="NMTOKENS" >

    <xs:simpleContent>

      <xs:extension base="xs:NMTOKENS" >

        <xs:attributeGroup ref="tns:commonAttributes" />

      </xs:extension>

    </xs:simpleContent>

  </xs:complexType>



  <xs:element name="ID" type="tns:ID" />

  <xs:complexType name="ID" >

    <xs:simpleContent>

      <xs:extension base="xs:ID" >

        <xs:attributeGroup ref="tns:commonAttributes" />

      </xs:extension>

    </xs:simpleContent>

  </xs:complexType>



  <xs:element name="IDREF" type="tns:IDREF" />

  <xs:complexType name="IDREF" >

    <xs:simpleContent>

      <xs:extension base="xs:IDREF" >

        <xs:attributeGroup ref="tns:commonAttributes" />

      </xs:extension>

    </xs:simpleContent>

  </xs:complexType>



  <xs:element name="ENTITY" type="tns:ENTITY" />

  <xs:complexType name="ENTITY" >

    <xs:simpleContent>

      <xs:extension base="xs:ENTITY" >

        <xs:attributeGroup ref="tns:commonAttributes" />

      </xs:extension>

    </xs:simpleContent>

  </xs:complexType>



  <xs:element name="IDREFS" type="tns:IDREFS" />

  <xs:complexType name="IDREFS" >

    <xs:simpleContent>

      <xs:extension base="xs:IDREFS" >

        <xs:attributeGroup ref="tns:commonAttributes" />

      </xs:extension>

    </xs:simpleContent>

  </xs:complexType>



  <xs:element name="ENTITIES" type="tns:ENTITIES" />

  <xs:complexType name="ENTITIES" >

    <xs:simpleContent>

      <xs:extension base="xs:ENTITIES" >

        <xs:attributeGroup ref="tns:commonAttributes" />

      </xs:extension>

    </xs:simpleContent>

  </xs:complexType>



  <xs:element name="decimal" type="tns:decimal" />

  <xs:complexType name="decimal" >

    <xs:simpleContent>

      <xs:extension base="xs:decimal" >

        <xs:attributeGroup ref="tns:commonAttributes" />

      </xs:extension>

    </xs:simpleContent>

  </xs:complexType>



  <xs:element name="integer" type="tns:integer" />

  <xs:complexType name="integer" >

    <xs:simpleContent>

      <xs:extension base="xs:integer" >

        <xs:attributeGroup ref="tns:commonAttributes" />

      </xs:extension>

    </xs:simpleContent>

  </xs:complexType>



  <xs:element name="nonPositiveInteger" type="tns:nonPositiveInteger" />

  <xs:complexType name="nonPositiveInteger" >

    <xs:simpleContent>

      <xs:extension base="xs:nonPositiveInteger" >

        <xs:attributeGroup ref="tns:commonAttributes" />

      </xs:extension>

    </xs:simpleContent>

  </xs:complexType>



  <xs:element name="negativeInteger" type="tns:negativeInteger" />

  <xs:complexType name="negativeInteger" >

    <xs:simpleContent>

      <xs:extension base="xs:negativeInteger" >

        <xs:attributeGroup ref="tns:commonAttributes" />

      </xs:extension>

    </xs:simpleContent>

  </xs:complexType>



  <xs:element name="long" type="tns:long" />

  <xs:complexType name="long" >

    <xs:simpleContent>

      <xs:extension base="xs:long" >

        <xs:attributeGroup ref="tns:commonAttributes" />

      </xs:extension>

    </xs:simpleContent>

  </xs:complexType>



  <xs:element name="int" type="tns:int" />

  <xs:complexType name="int" >

    <xs:simpleContent>

      <xs:extension base="xs:int" >

        <xs:attributeGroup ref="tns:commonAttributes" />

      </xs:extension>

    </xs:simpleContent>

  </xs:complexType>



  <xs:element name="short" type="tns:short" />

  <xs:complexType name="short" >

    <xs:simpleContent>

      <xs:extension base="xs:short" >

        <xs:attributeGroup ref="tns:commonAttributes" />

      </xs:extension>

    </xs:simpleContent>

  </xs:complexType>



  <xs:element name="byte" type="tns:byte" />

  <xs:complexType name="byte" >

    <xs:simpleContent>

      <xs:extension base="xs:byte" >

        <xs:attributeGroup ref="tns:commonAttributes" />

      </xs:extension>

    </xs:simpleContent>

  </xs:complexType>



  <xs:element name="nonNegativeInteger" type="tns:nonNegativeInteger" />

  <xs:complexType name="nonNegativeInteger" >

    <xs:simpleContent>

      <xs:extension base="xs:nonNegativeInteger" >

        <xs:attributeGroup ref="tns:commonAttributes" />

      </xs:extension>

    </xs:simpleContent>

  </xs:complexType>



  <xs:element name="unsignedLong" type="tns:unsignedLong" />

  <xs:complexType name="unsignedLong" >

    <xs:simpleContent>

      <xs:extension base="xs:unsignedLong" >

        <xs:attributeGroup ref="tns:commonAttributes" />

      </xs:extension>

    </xs:simpleContent>

  </xs:complexType>



  <xs:element name="unsignedInt" type="tns:unsignedInt" />

  <xs:complexType name="unsignedInt" >

    <xs:simpleContent>

      <xs:extension base="xs:unsignedInt" >

        <xs:attributeGroup ref="tns:commonAttributes" />

      </xs:extension>

    </xs:simpleContent>

  </xs:complexType>



  <xs:element name="unsignedShort" type="tns:unsignedShort" />

  <xs:complexType name="unsignedShort" >

    <xs:simpleContent>

      <xs:extension base="xs:unsignedShort" >

        <xs:attributeGroup ref="tns:commonAttributes" />

      </xs:extension>

    </xs:simpleContent>

  </xs:complexType>



  <xs:element name="unsignedByte" type="tns:unsignedByte" />

  <xs:complexType name="unsignedByte" >

    <xs:simpleContent>

      <xs:extension base="xs:unsignedByte" >

        <xs:attributeGroup ref="tns:commonAttributes" />

      </xs:extension>

    </xs:simpleContent>

  </xs:complexType>



  <xs:element name="positiveInteger" type="tns:positiveInteger" />

  <xs:complexType name="positiveInteger" >

    <xs:simpleContent>

      <xs:extension base="xs:positiveInteger" >

        <xs:attributeGroup ref="tns:commonAttributes" />

      </xs:extension>

    </xs:simpleContent>

  </xs:complexType>

  <xs:element name="anyType" />

</xs:schema>

Now that we have defined the customer.wsdl, let’s proceed to the next step of creating a Weblogic Web Service. In the Project Explorer view of Eclipse right click the customer.wsdl file. Select the ‘Weblogic Web Services’ menu item and further select ‘Generate Web Service..’. Within the Java Source folder the com.buymore.online and CustomerService_InformationImpl class is created. The class name is an amalgamation of wsdl:service’s name, “_”, wsdl:port’s name and ‘Impl’ strings. Within the WebContent\WEB-INF\lib folder a customer_wsdl.jar is created. The jar contains the following classes in the com.buymore.online package:

  • Address
  • Addresses
  • CustomerPort
  • CustomerPortAsyncHandler
  • CustomerResponse
  • CustomerService
  • ObjectFactory
  • package-info
  • Phone
  • Phones
  • SearchInput

Here are the source code of relevant classes.

package com.buymore.online;

import java.math.BigInteger;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;


/**
 * <p>Java class for anonymous complex type.
 * 
 * <p>The following schema fragment specifies the expected content contained within this class.
 * 
 * <pre>
 * &lt;complexType>
 *   &lt;complexContent>
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       &lt;sequence>
 *         &lt;element name="line1" type="{http://www.w3.org/2001/XMLSchema}string"/>
 *         &lt;element name="line2" type="{http://www.w3.org/2001/XMLSchema}string"/>
 *         &lt;element name="city" type="{http://www.w3.org/2001/XMLSchema}string"/>
 *         &lt;element name="state" type="{http://www.w3.org/2001/XMLSchema}string"/>
 *         &lt;element name="zipCode" type="{http://www.w3.org/2001/XMLSchema}integer"/>
 *         &lt;element ref="{http://buymore.com/online/}Phones"/>
 *       &lt;/sequence>
 *     &lt;/restriction>
 *   &lt;/complexContent>
 * &lt;/complexType>
 * </pre>
 * 
 * 
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "line1",
    "line2",
    "city",
    "state",
    "zipCode",
    "phones"
})
@XmlRootElement(name = "Address")
public class Address {

    @XmlElement(required = true)
    protected String line1;
    @XmlElement(required = true)
    protected String line2;
    @XmlElement(required = true)
    protected String city;
    @XmlElement(required = true)
    protected String state;
    @XmlElement(required = true)
    protected BigInteger zipCode;
    @XmlElement(name = "Phones", namespace = "http://buymore.com/online/", required = true)
    protected Phones phones;

    /**
     * Gets the value of the line1 property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getLine1() {
        return line1;
    }

    /**
     * Sets the value of the line1 property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setLine1(String value) {
        this.line1 = value;
    }

    /**
     * Gets the value of the line2 property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getLine2() {
        return line2;
    }

    /**
     * Sets the value of the line2 property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setLine2(String value) {
        this.line2 = value;
    }

    /**
     * Gets the value of the city property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getCity() {
        return city;
    }

    /**
     * Sets the value of the city property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setCity(String value) {
        this.city = value;
    }

    /**
     * Gets the value of the state property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getState() {
        return state;
    }

    /**
     * Sets the value of the state property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setState(String value) {
        this.state = value;
    }

    /**
     * Gets the value of the zipCode property.
     * 
     * @return
     *     possible object is
     *     {@link BigInteger }
     *     
     */
    public BigInteger getZipCode() {
        return zipCode;
    }

    /**
     * Sets the value of the zipCode property.
     * 
     * @param value
     *     allowed object is
     *     {@link BigInteger }
     *     
     */
    public void setZipCode(BigInteger value) {
        this.zipCode = value;
    }

    /**
     * Gets the value of the phones property.
     * 
     * @return
     *     possible object is
     *     {@link Phones }
     *     
     */
    public Phones getPhones() {
        return phones;
    }

    /**
     * Sets the value of the phones property.
     * 
     * @param value
     *     allowed object is
     *     {@link Phones }
     *     
     */
    public void setPhones(Phones value) {
        this.phones = value;
    }

}

package com.buymore.online;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import org.xmlsoap.schemas.soap.encoding.Array;


/**
 * <p>Java class for anonymous complex type.
 * 
 * <p>The following schema fragment specifies the expected content contained within this class.
 * 
 * <pre>
 * &lt;complexType>
 *   &lt;complexContent>
 *     &lt;restriction base="{http://schemas.xmlsoap.org/soap/encoding/}Array">
 *       &lt;attribute ref="{http://schemas.xmlsoap.org/soap/encoding/}arrayType"/>
 *     &lt;/restriction>
 *   &lt;/complexContent>
 * &lt;/complexType>
 * </pre>
 * 
 * 
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "")
@XmlRootElement(name = "Addresses")
public class Addresses
    extends Array
{


}

package com.buymore.online;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;


/**
 * <p>Java class for anonymous complex type.
 * 
 * <p>The following schema fragment specifies the expected content contained within this class.
 * 
 * <pre>
 * &lt;complexType>
 *   &lt;complexContent>
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       &lt;sequence>
 *         &lt;element name="fName" type="{http://www.w3.org/2001/XMLSchema}string"/>
 *         &lt;element name="lName" type="{http://www.w3.org/2001/XMLSchema}string"/>
 *         &lt;element ref="{http://buymore.com/online/}Addresses"/>
 *       &lt;/sequence>
 *     &lt;/restriction>
 *   &lt;/complexContent>
 * &lt;/complexType>
 * </pre>
 * 
 * 
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "fName",
    "lName",
    "addresses"
})
@XmlRootElement(name = "CustomerResponse")
public class CustomerResponse {

    @XmlElement(required = true)
    protected String fName;
    @XmlElement(required = true)
    protected String lName;
    @XmlElement(name = "Addresses", namespace = "http://buymore.com/online/", required = true)
    protected Addresses addresses;

    /**
     * Gets the value of the fName property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getFName() {
        return fName;
    }

    /**
     * Sets the value of the fName property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setFName(String value) {
        this.fName = value;
    }

    /**
     * Gets the value of the lName property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getLName() {
        return lName;
    }

    /**
     * Sets the value of the lName property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setLName(String value) {
        this.lName = value;
    }

    /**
     * Gets the value of the addresses property.
     * 
     * @return
     *     possible object is
     *     {@link Addresses }
     *     
     */
    public Addresses getAddresses() {
        return addresses;
    }

    /**
     * Sets the value of the addresses property.
     * 
     * @param value
     *     allowed object is
     *     {@link Addresses }
     *     
     */
    public void setAddresses(Addresses value) {
        this.addresses = value;
    }

}

package com.buymore.online;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;


/**
 * <p>Java class for anonymous complex type.
 * 
 * <p>The following schema fragment specifies the expected content contained within this class.
 * 
 * <pre>
 * &lt;complexType>
 *   &lt;complexContent>
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       &lt;sequence>
 *         &lt;element name="countryCode" type="{http://www.w3.org/2001/XMLSchema}string"/>
 *         &lt;element name="cityCode" type="{http://www.w3.org/2001/XMLSchema}string"/>
 *         &lt;element name="number" type="{http://www.w3.org/2001/XMLSchema}string"/>
 *       &lt;/sequence>
 *     &lt;/restriction>
 *   &lt;/complexContent>
 * &lt;/complexType>
 * </pre>
 * 
 * 
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "countryCode",
    "cityCode",
    "number"
})
@XmlRootElement(name = "Phone")
public class Phone {

    @XmlElement(required = true)
    protected String countryCode;
    @XmlElement(required = true)
    protected String cityCode;
    @XmlElement(required = true)
    protected String number;

    /**
     * Gets the value of the countryCode property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getCountryCode() {
        return countryCode;
    }

    /**
     * Sets the value of the countryCode property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setCountryCode(String value) {
        this.countryCode = value;
    }

    /**
     * Gets the value of the cityCode property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getCityCode() {
        return cityCode;
    }

    /**
     * Sets the value of the cityCode property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setCityCode(String value) {
        this.cityCode = value;
    }

    /**
     * Gets the value of the number property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getNumber() {
        return number;
    }

    /**
     * Sets the value of the number property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setNumber(String value) {
        this.number = value;
    }

}

package com.buymore.online;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import org.xmlsoap.schemas.soap.encoding.Array;


/**
 * <p>Java class for anonymous complex type.
 * 
 * <p>The following schema fragment specifies the expected content contained within this class.
 * 
 * <pre>
 * &lt;complexType>
 *   &lt;complexContent>
 *     &lt;restriction base="{http://schemas.xmlsoap.org/soap/encoding/}Array">
 *       &lt;attribute ref="{http://schemas.xmlsoap.org/soap/encoding/}arrayType"/>
 *     &lt;/restriction>
 *   &lt;/complexContent>
 * &lt;/complexType>
 * </pre>
 * 
 * 
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "")
@XmlRootElement(name = "Phones")
public class Phones
    extends Array
{


}

package com.buymore.online;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;


/**
 * <p>Java class for anonymous complex type.
 * 
 * <p>The following schema fragment specifies the expected content contained within this class.
 * 
 * <pre>
 * &lt;complexType>
 *   &lt;complexContent>
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       &lt;sequence>
 *         &lt;element name="id" type="{http://www.w3.org/2001/XMLSchema}string"/>
 *       &lt;/sequence>
 *     &lt;/restriction>
 *   &lt;/complexContent>
 * &lt;/complexType>
 * </pre>
 * 
 * 
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "id"
})
@XmlRootElement(name = "SearchInput")
public class SearchInput {

    @XmlElement(required = true)
    protected String id;

    /**
     * Gets the value of the id property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getId() {
        return id;
    }

    /**
     * Sets the value of the id property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setId(String value) {
        this.id = value;
    }

}

The content of the jar can be viewed in Java Resources\Libraries\Web App Libraries folder within the Eclipse Project Explorer view. Open the CustomerService_InformationImpl class.

package com.buymore.online;

import javax.jws.WebService;
import javax.xml.ws.BindingType;

import com.buymore.online.data.CustomerInfoProvider;

/**
 * This class was generated by the JAX-WS RI. Oracle JAX-WS 2.1.5 Generated
 * source version: 2.1
 * 
 */
@WebService(portName = "Information", serviceName = "CustomerService", targetNamespace = "http://buymore.com/online/", wsdlLocation = "/wsdls/customer.wsdl", endpointInterface = "com.buymore.online.CustomerPort")
@BindingType("http://schemas.xmlsoap.org/wsdl/soap/http")
public class CustomerService_InformationImpl implements CustomerPort {

	public CustomerService_InformationImpl() {
	}

	/**
	 * 
	 * @param input
	 * @return returns com.buymore.online.CustomerResponse
	 */
	public CustomerResponse getCustomerData(SearchInput input) {
		return new CustomerInfoProvider().searchByCustomerId(input);
	}

}

It will contain the following Java method:

	public CustomerResponse getCustomerData(SearchInput input) {
		//TODO:
	}

This method is the Java implementation of the web service. It accepts SearchInput as input argument and returns CustomerResponse. Service specific customization need to be added here.

I created the CustomerInfoProvider class to act as data provider for the web service. Here’s the class source code:

package com.buymore.online.data;

import java.math.BigInteger;

import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPFactory;
import javax.xml.soap.SOAPFault;
import javax.xml.ws.soap.SOAPFaultException;

import com.buymore.online.Address;
import com.buymore.online.Addresses;
import com.buymore.online.CustomerResponse;
import com.buymore.online.Phone;
import com.buymore.online.Phones;
import com.buymore.online.SearchInput;

public class CustomerInfoProvider {
	
	public CustomerInfoProvider() {
		
	}
	
	public CustomerResponse searchByCustomerId(SearchInput input) {
		String customerId = input.getId();
		
		if ("1".equals(customerId)) {
		
			CustomerResponse response = new CustomerResponse();
			response.setFName("Mike");
			response.setLName("Smith");
			
			Address add1 = new Address();
			add1.setCity("Colorado Springs");
			add1.setLine1("123 Imperial Heights");
			add1.setLine2("Orange Drive");
			add1.setState("Colorado");
			add1.setZipCode(BigInteger.valueOf(80907));
			
			Phone phone1 = new Phone();
			phone1.setCountryCode("1");
			phone1.setCityCode("");
			phone1.setNumber("776 4554");
			
			Phone phone2 = new Phone();
			phone2.setCountryCode("1");
			phone2.setCityCode("");
			phone2.setNumber("776 4555");

			Phones phones1 = new Phones();
			phones1.getAny().add(phone1);
			phones1.getAny().add(phone2);
			add1.setPhones(phones1);
			
			Address add2 = new Address();
			add2.setCity("Lynchburg");
			add2.setLine1("12B Lakeside Apts");
			add2.setLine2("Weeping Willow Drive");
			add2.setState("Virginia");
			add2.setZipCode(BigInteger.valueOf(24501));

			Phone phone3 = new Phone();
			phone3.setCountryCode("1");
			phone3.setCityCode("");
			phone3.setNumber("888 2121");

			Phones phones2 = new Phones();
			phones2.getAny().add(phone3);
			add2.setPhones(phones2);
			
			Addresses addresses = new Addresses();
			addresses.getAny().add(add1);
			addresses.getAny().add(add2);
			response.setAddresses(addresses);
			
			return response;
			
		} else if ("2".equals(customerId)) {
			return null;
		} else {
			
			System.setProperty("com.sun.xml.ws.fault.SOAPFaultBuilder.disableCaptureStackTrace", "true");
			
			SOAPFault fault = null;
			try {
				fault = SOAPFactory.newInstance().createFault();
				
				fault.setFaultActor("Consumer");
				fault.setFaultCode("900");
				fault.setFaultString("The input id is invalid. Cannot process the value.");
				throw new SOAPFaultException(fault);
			} catch (SOAPException e) {
				return null;
			}
			
		}
				
	}
}

Refer the constructs for Addressses and Phones in their class definitions and the approach used for populating these two types in CustomerInfoProvider class. Refer lines 50-52 and 71-73. The addition of Phone and Address within their containers appears slightly convoluted.

The searchByCustomerId method of CustomerInfoProvider accepts customer id and returns a CustomerResponse object for id = 1. For id = 2 returns null and for 3 returns a SOAPFault. This is purely to test the web service behavior under normal and abnormal conditions.

The getCustomerData method of CustomerService_InformationImpl is changed to the following:

	public CustomerResponse getCustomerData(SearchInput input) {
		return new CustomerInfoProvider().searchByCustomerId(input);
	}

Now let’s test the web service we have created. In the server perspective create a server instance configuration for Weblogic Server 11gR1 (10.3.5). This server should point to your local server weblogic installation. Refer the URL‘s section titled Defining the WebLogic Server’ for further instructions. In step 2 use the server type you have installed on your machine. Ignore step 6.

For testing the web service select the CustomerService_InformationImpl.java. On the right click menu select Run As –> Run On Server. A wizard appears. Select the radio button choose an existing server and select the newly configured server instance. Next add the OnlineStore if not already added in the configured section. Proceed to completing the wizard by selecting ‘Finish’ button. This should initiate the WebLogic server startup process. Once the server is started it automatically triggers the Universal Test Client(UTC) initialization and you should see a web page titled ‘WebLogic Test Client’ appearing within eclipse.

Within the operation form field type in 1. Here’s the generated response.

<ns3:CustomerResponse xmlns:ns3="http://buymore.com/online/" xmlns:ns2="http://schemas.xmlsoap.org/soap/encoding/">
      <fName>Mike</fName>
      <lName>Smith</lName>
      <ns3:Addresses>
        <ns3:Address>
          <line1>123 Imperial Heights</line1>
          <line2>Orange Drive</line2>
          <city>Colorado Springs</city>
          <state>Colorado</state>
          <zipCode>80907</zipCode>
          <ns3:Phones>
            <ns3:Phone>
              <countryCode>1</countryCode>
              <cityCode />
              <number>776 4554</number>
            </ns3:Phone>
            <ns3:Phone>
              <countryCode>1</countryCode>
              <cityCode />
              <number>776 4555</number>
            </ns3:Phone>
          </ns3:Phones>
        </ns3:Address>
        <ns3:Address>
          <line1>12B Lakeside Apts</line1>
          <line2>Weeping Willow Drive</line2>
          <city>Lynchburg</city>
          <state>Virginia</state>
          <zipCode>24501</zipCode>
          <ns3:Phones>
            <ns3:Phone>
              <countryCode>1</countryCode>
              <cityCode />
              <number>888 2121</number>
            </ns3:Phone>
          </ns3:Phones>
        </ns3:Address>
      </ns3:Addresses>
    </ns3:CustomerResponse>

Response for id = 2

<ns3:CustomerResponse xmlns:ns3="http://buymore.com/online/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns2="http://schemas.xmlsoap.org/soap/encoding/" xsi:nil="true" />

Response for id = 3

<S:Fault xmlns:ns4="http://www.w3.org/2003/05/soap-envelope">
      <faultcode>900</faultcode>
      <faultstring>The input id is invalid. Cannot process the value.</faultstring>
      <faultactor>Consumer</faultactor>
    </S:Fault>

Now let’s look at bottom-up mapping. We will use the same use case scenario.

Web Service using the bottom-up (Java First) method

Now that we are going to use the same data structures I intend to clearly differenciate by using a different package name com.buymore.online.java2wsdl and all classes which form the data types are appended with ‘J2W’ suffix.

package com.buymore.online.java2wsdl;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "AddressJ2W", propOrder = {
    "line1",
    "line2",
    "city",
    "state",
    "zipCode",
    "phones"
})
public class AddressJ2W {

    @XmlElement(required = true)
    protected String line1;
    @XmlElement(required = true)
    protected String line2;
    @XmlElement(required = true)
    protected String city;
    @XmlElement(required = true)
    protected String state;
    @XmlElement(required = true)
    protected BigInteger zipCode;
    
    @XmlElementWrapper(name="PhonesJ2W")
    @XmlElement(name="PhoneJ2W", required = true)
	List<PhoneJ2W> phones = new ArrayList<PhoneJ2W>();
	
	public List<PhoneJ2W> getPhones() {
		return phones;
	}

	public void setPhones(List<PhoneJ2W> phones) {
		this.phones = phones;
	}

	public void addPhone(PhoneJ2W phone) {
		this.phones.add(phone);
	}


    public String getLine1() {
		return line1;
	}
	public void setLine1(String line1) {
		this.line1 = line1;
	}
	public String getLine2() {
		return line2;
	}
	public void setLine2(String line2) {
		this.line2 = line2;
	}
	public String getCity() {
		return city;
	}
	public void setCity(String city) {
		this.city = city;
	}
	public String getState() {
		return state;
	}
	public void setState(String state) {
		this.state = state;
	}
	public BigInteger getZipCode() {
		return zipCode;
	}
	public void setZipCode(BigInteger zipCode) {
		this.zipCode = zipCode;
	}	
}
package com.buymore.online.java2wsdl;

import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "fName",
    "lName",
    "addresses"
})
@XmlRootElement(name = "CustomerResponseJ2W")
public class CustomerResponseJ2W {
	
    @XmlElement(required = true)
    protected String fName;
    @XmlElement(required = true)
    protected String lName;
    
    @XmlElementWrapper(name="AddressesJ2W")
    @XmlElement(name="AddressJ2W", required = true)
	List<AddressJ2W> addresses = new ArrayList<AddressJ2W>();
	
	public List<AddressJ2W> getAddresses() {
		return addresses;
	}

	public void setPhones(List<AddressJ2W> addresses) {
		this.addresses = addresses;
	}

	public void addAddress(AddressJ2W address) {
		this.addresses.add(address);
	}


    public String getfName() {
		return fName;
	}
	public void setfName(String fName) {
		this.fName = fName;
	}
	public String getlName() {
		return lName;
	}
	public void setlName(String lName) {
		this.lName = lName;
	}

}
package com.buymore.online.java2wsdl;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "PhoneJ2W", propOrder = {
    "countryCode",
    "cityCode",
    "number"
})
public class PhoneJ2W {
	
    @XmlElement(required = true)
    protected String countryCode;
    @XmlElement(required = true)
    protected String cityCode;
    @XmlElement(required = true)
    protected String number;

    public String getCountryCode() {
        return countryCode;
    }

    public void setCountryCode(String value) {
        this.countryCode = value;
    }

    public String getCityCode() {
        return cityCode;
    }

    public void setCityCode(String value) {
        this.cityCode = value;
    }

    public String getNumber() {
        return number;
    }

    public void setNumber(String value) {
        this.number = value;
    }

}
package com.buymore.online.java2wsdl;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {"id"})
@XmlRootElement(name = "SearchInputJ2W")
	public class SearchInputJ2W {


	    @XmlElement(required = true)
	    protected String id;

	    public String getId() {
	        return id;
	    }

	    public void setId(String value) {
	        this.id = value;
	    }

	}

Let’s look at CustomerResponseJ2W class to understand how annotations are used to implement Web Services via the bottom up approach. Our first step in the top down approach was to define complex types. This is similar to the classes defined above.

The first class level annotation used is @XMLAccessorType. This annotation supports the following values FIELD(Every non-static, non-transient field is mapped automatically), NONE(No fields or properties are mapped), PROPERTY(Every getter/setter pair is mapped automatically) and PUBLIC_MEMBER(Every public getter/setter pair and public field is automatically mapped). We choose FIELD for our xml accessor type. Using the XMLType annotation we define the XML property order. The XMLRootElement establishes the class as a top level element and the name attribute value is used during XML generation. The XMLElement annotation at field level define if the fields are mandatory elements or not. If the name attribute is provided, the attribute value is used during the XML rendition. Note the addresses field encapsulates multiple addresses. Without the XMLElementWrapper annotation, the output XML structure would be as follows:

<CustomerResponse>
.
.
	<Address>
	</Address>
	<Address>
	</Address>
.
.
</CustomerResponse>   

To have a structure like

<CustomerResponse>
.
.
	<Addresses>
		<Address>
		</Address>
		<Address>
		</Address>
	</Addresses>
.
.
</CustomerResponse>   

we add the XMLElementWrapper annotation. The name attribute acts as the element name in the rendered XML. I will not spend more time in explaining the annotations for other classes; they are on similar lines. There is only one thing to note. Only CustomerResponseJ2W has the XMLRootElement annotation. The rest of the classes do not use this annotation.All the annotations allow definition of namespace. Do not define namespace here, it leads to unwanted side effects.

Like in the previous example create the provider and service class namely CustomerInfoProviderJ2W and CustomerServiceJ2W. CustomerInfoProviderJ2W is a near duplicate code of CustomerInfoProvider class. It differs in handling the Addresses and Phones collections. Here’s the source code of CustomerServiceJ2W.

package com.buymore.online.java2wsdl.svc;

import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.xml.ws.BindingType;

import com.buymore.online.java2wsdl.CustomerResponseJ2W;
import com.buymore.online.java2wsdl.SearchInputJ2W;
import com.buymore.online.java2wsdl.provider.CustomerInfoProviderJ2W;

@WebService(portName = "InfoJ2W", serviceName = "CustomerServiceJ2W", targetNamespace = "http://buymore.com/online/j2w/")
@BindingType("http://schemas.xmlsoap.org/wsdl/soap/http")
public class CustomerServiceJ2W {

	@WebMethod(action="getCustomerData")
	public CustomerResponseJ2W getCustomerData(SearchInputJ2W input) {
		return new CustomerInfoProviderJ2W().searchByCustomerId(input);
	}
	
}

Here we define the WebService annotation which defines the following attributes
portName: Port Name of the service endpoint
serviceName: Service name
targetNamespace: The namespace used as target within the wsdl:types definition
BindingType: The transmission protocol for the web service implementation

The operation exposed is defined via the WebMethod annotation. The action attribute is optional.

To generate the WSDL file, right click on the CustomerServiceJ2W class in the Project Explorer. Select WebLogic Web Service –> Generate WSDL. Select WebContent as the WSDL directory location. On completion of the process, you will notice two files created within the WebContent folder. They are CustomerServiceJ2W_schema1.xsd and CustomerServiceJ2W.wsdl.

Here’s the file contents for further examination.

CustomerServiceJ2W_schema1.xsd

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xs:schema version="1.0" targetNamespace="http://buymore.com/online/j2w/" xmlns:tns="http://buymore.com/online/j2w/" xmlns:xs="http://www.w3.org/2001/XMLSchema">

  <xs:element name="CustomerResponseJ2W">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="fName" type="xs:string"/>
        <xs:element name="lName" type="xs:string"/>
        <xs:element name="AddressesJ2W" minOccurs="0">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="AddressJ2W" type="tns:AddressJ2W" maxOccurs="unbounded"/>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

  <xs:element name="SearchInputJ2W">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="id" type="xs:string"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

  <xs:element name="getCustomerData" type="tns:getCustomerData"/>

  <xs:element name="getCustomerDataResponse" type="tns:getCustomerDataResponse"/>

  <xs:complexType name="getCustomerData">
    <xs:sequence>
      <xs:element name="arg0" minOccurs="0">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="id" type="xs:string"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="getCustomerDataResponse">
    <xs:sequence>
      <xs:element name="return" minOccurs="0">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="fName" type="xs:string"/>
            <xs:element name="lName" type="xs:string"/>
            <xs:element name="AddressesJ2W" minOccurs="0">
              <xs:complexType>
                <xs:sequence>
                  <xs:element name="AddressJ2W" type="tns:AddressJ2W" maxOccurs="unbounded"/>
                </xs:sequence>
              </xs:complexType>
            </xs:element>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="AddressJ2W">
    <xs:sequence>
      <xs:element name="line1" type="xs:string"/>
      <xs:element name="line2" type="xs:string"/>
      <xs:element name="city" type="xs:string"/>
      <xs:element name="state" type="xs:string"/>
      <xs:element name="zipCode" type="xs:integer"/>
      <xs:element name="PhonesJ2W" minOccurs="0">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="PhoneJ2W" type="tns:PhoneJ2W" maxOccurs="unbounded"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="PhoneJ2W">
    <xs:sequence>
      <xs:element name="countryCode" type="xs:string"/>
      <xs:element name="cityCode" type="xs:string"/>
      <xs:element name="number" type="xs:string"/>
    </xs:sequence>
  </xs:complexType>
</xs:schema>

CustomerServiceJ2W.wsdl

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is Oracle JAX-WS 2.1.5. -->
<definitions targetNamespace="http://buymore.com/online/j2w/" name="CustomerServiceJ2W" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://buymore.com/online/j2w/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
  <types>
    <xsd:schema>
      <xsd:import namespace="http://buymore.com/online/j2w/" schemaLocation="CustomerServiceJ2W_schema1.xsd"/>
    </xsd:schema>
  </types>
  <message name="getCustomerData">
    <part name="parameters" element="tns:getCustomerData"/>
  </message>
  <message name="getCustomerDataResponse">
    <part name="parameters" element="tns:getCustomerDataResponse"/>
  </message>
  <portType name="CustomerServiceJ2W">
    <operation name="getCustomerData">
      <input message="tns:getCustomerData"/>
      <output message="tns:getCustomerDataResponse"/>
    </operation>
  </portType>
  <binding name="InfoJ2WBinding" type="tns:CustomerServiceJ2W">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
    <operation name="getCustomerData">
      <soap:operation soapAction="getCustomerData"/>
      <input>
        <soap:body use="literal"/>
      </input>
      <output>
        <soap:body use="literal"/>
      </output>
    </operation>
  </binding>
  <service name="CustomerServiceJ2W">
    <port name="InfoJ2W" binding="tns:InfoJ2WBinding">
      <soap:address location="REPLACE_WITH_ACTUAL_URL"/>
    </port>
  </service>
</definitions>

To test the web service use the same procedure as before. Select CustomerServiceJ2W.java file and select Run As –> Run On Server.

The final part of this post is using WS-Security in WebLogic Server.

WS-Security in WebLogic

I used the username token method for WS-Security. I referred two blog posts which are self-explanatory and hence am avoiding rewriting them. The first post helps create the Web Service and the second assists in creating the client.

URL 1: How secure a JAX-WS web service on Weblogic
URL 2: How to invoke a JAX-WS web service secured with username/password with another JAX-WS web

Advertisements

25 thoughts on “Developing Web Services (JAX-WS) in WebLogic using Oracle Enterprise Pack for Eclipse(OEPE) – A Tutorial

  1. Very nice post! Can you please also share the source for this example. Copying source is not possible as it line numbers are also getting copied.

    1. Prithviraj,

      Please navigate to the top right corner of the source code posting. You will find that four icons appear. The first two allows viewer to view source code and copy source code to clipboard. You can use any one of those and get the source code without the line numbers.

  2. Hello, I am following your post step by step. The step when we right click on WSDL and select weblogic web services -> generate web service … fails with error:
    oracle.eclipse.tools.webservices.ant.GeneratedAntScriptFailedException: Generated ant script failed:
    D:\eclipse\Prithvi\workspace\OnlineStore\wsdlc_build.xml
    Log file:
    D:\eclipse\Prithvi\workspace\.metadata\.plugins\oracle.eclipse.tools.webservices\ant\build_log.txt
    Log contents:
    Buildfile: D:\eclipse\Prithvi\workspace\OnlineStore\wsdlc_build.xml
    Trying to override old definition of task wsgen

    fork_build:
    [java] Buildfile: D:\eclipse\Prithvi\workspace\OnlineStore\wsdlc_build.xml
    [java]
    [java] build:
    [java] [AntUtil.deleteDir] Deleting directory C:\Users\176893\AppData\Local\Temp\_ckr59b
    [java]
    [java] BUILD FAILED
    [java] D:\eclipse\Prithvi\workspace\OnlineStore\wsdlc_build.xml:68: Failed to parse the URI or refernce ID : [file:/D:/eclipse/Prithvi/workspace/OnlineStore/WebContent/soap-encoding.xsd], please check if the it is correctly defined.
    [java]
    [java] Total time: 0 seconds

    BUILD FAILED
    D:\eclipse\Prithvi\workspace\OnlineStore\wsdlc_build.xml:39: Java returned: 1

    Total time: 2 seconds

    at oracle.eclipse.tools.webservices.ant.WlsAntScript.runAnt(WlsAntScript.java:130)

    at oracle.eclipse.tools.webservices.ant.WlsAntScript.execute(WlsAntScript.java:283)

    at org.eclipse.ui.actions.WorkspaceModifyOperation$1.run(WorkspaceModifyOperation.java:106)

    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1975)

    at org.eclipse.ui.actions.WorkspaceModifyOperation.run(WorkspaceModifyOperation.java:118)

    at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)

    Caused by: org.eclipse.core.runtime.CoreException: D:\eclipse\Prithvi\workspace\OnlineStore\wsdlc_build.xml:39: Java returned: 1

    at org.eclipse.ant.core.AntRunner.handleInvocationTargetException(AntRunner.java:452)

    at org.eclipse.ant.core.AntRunner.run(AntRunner.java:384)

    at oracle.eclipse.tools.webservices.ant.WlsAntScript.runAnt(WlsAntScript.java:128)

    … 5 more

    Can you please tell me what is the issue?

    1. Hi Prithviraj,

      I apologize for the inconvenience caused. I forgot to add the soap-encoding.xsd in my blog post. I have updated the post with the contents of xsd.

      Thanks for bringing this to my notice.

  3. Dear President,
    After using soap-encoding.xsd, it worked like a charm 🙂 Thanks for the very easy to understand tutorial. I have already subscribed to your blog 🙂 I would like to clarify one more thing. I still do not get how do we use this webservice in real world. I mean i need the generic example with reference to above webservice like which files will be kept on server, which on client. How does client invokes this webservice. I am asking this question because through eclipse client I am able to test this webservice but not sure how to integrate it into real world application.

    1. Hi Prithviraj,

      In real world scenario, the consuming application usually uses the WSDL definition to create a client using any suitable web services framework. I have used the weblogic generated code as a matter of convenience.

      You are free to use any Java WebServices framework like Axis, Metro in Java or other platform specific frameworks to create Web Service clients.

  4. Dear Mr. President,
    As per my understanding, I thought in our example, code that we generated upto class CustomerInfoProvider, is a part of WebService. So it will stay on server. But as such i am not able understand which code is a part of client. Because as a client we did not generate any code. Instead we used WebLogic Test Client. Please let me know, if I am missing something.

    1. Hi Prithviraj,

      You are right. You are not missing anything. There has been an oversight from my end. I have not explained Weblogic WebService client creation process in my blog post. I thought I had.

      Here’s a useful link which explains the client creation process using WebLogic tooling.

  5. Hi Mr.President,
    I tried your example today but i’m facing an exception while running this project on weblogic server.
    Can you please help me sort this out.
    Thanks!!

    Below is the exception :
    <Failure occurred in the execution of deployment request with ID '1349260297478' for task '2'. Error is: 'weblogic.application.ModuleException: [HTTP:101216]Servlet: "CustomerServiceServlethttp" failed to preload on startup in Web application: "OnlineStore".
    java.lang.IncompatibleClassChangeError: class com.buymore.online.Phones has interface org.xmlsoap.schemas.soap.encoding.Array as super class
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
    at weblogic.utils.classloaders.GenericClassLoader.defineClass(GenericClassLoader.java:343)
    at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:302)
    at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:270)
    at weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(ChangeAwareClassLoader.java:64)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
    at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:179)
    at weblogic.utils.classloaders.ChangeAwareClassLoader.loadClass(ChangeAwareClassLoader.java:43)
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
    at java.lang.Class.getDeclaredMethods(Class.java:1791)
    at com.sun.xml.bind.v2.model.nav.ReflectionNavigator.getDeclaredMethods(ReflectionNavigator.java:267)
    at com.sun.xml.bind.v2.model.nav.ReflectionNavigator.getDeclaredMethods(ReflectionNavigator.java:64)
    at com.sun.xml.bind.v2.model.impl.RegistryInfoImpl.(RegistryInfoImpl.java:92)

    1. Hi Nick,

      The exception java.lang.IncompatibleClassChangeError points to a mismatch between your WSDL and java generated code. Kindly regenerate the code/WSDL. Check if you have made changes in the generated code.

  6. Hi Mr.President,

    I did not made any change in the java code. Generated the impl code via wsdl and copied the content for the provider from above.
    After your reply also regenerated the code/wsdl, stil the same problem.

    1. Hi Nick,

      The other possibility is that you have two versions of org.xmlsoap.schemas.soap.encoding.Array in your classpath. Can you verify that?

  7. Folowing the first part (top-down) I am getting the error bellow. I sounds to me that I wasn’t allowed to use ID twice in the xsd. What do you think?
    Exception Description: An attempt was made to set more than one XmlID property on class [org.xmlsoap.schemas.soap.encoding.ID]. Property [value] cannot be set as XmlID, because property [id] is already set as XmlID.
    – with linked exception:
    [Exception [EclipseLink-50030] (Eclipse Persistence Services – 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.JAXBException
    Exception Description: An attempt was made to set more than one XmlID property on class [org.xmlsoap.schemas.soap.encoding.ID]. Property [value] cannot be set as XmlID, because property [id] is already set as XmlID.]

    at org.eclipse.persistence.jaxb.JAXBContext$TypeMappingInfoInput.createContextState(JAXBContext.java:832)
    at org.eclipse.persistence.jaxb.JAXBContext.(JAXBContext.java:143)
    at org.eclipse.persistence.jaxb.JAXBContextFactory.createContext(JAXBContextFactory.java:142)
    at com.sun.xml.ws.db.toplink.JAXBContextFactory.newContext(JAXBContextFactory.java:180)

  8. Thank you for this! I’m using NetBeans and Glassfish, but your tutorial was exactly what I was looking for in what to do with the service skeleton generated using NetBeans from a WSDL I was given. Other tutorials I’ve found merely tell you how to generate the skeleton and then say to fill in the rest, which is not very helpful if you’ve never done it before.

  9. Hi… I am using weblogic test client but when I generate web service from wsdl i am getting errors. My generated code is following-

    package com.buymore.online;

    import javax.jws.WebService;
    import javax.xml.ws.BindingType;

    import com.buymore.online.data.CustomerInfoProvider;

    /**
    * This class was generated by the JAX-WS RI. Oracle JAX-WS 2.1.5 Generated
    * source version: 2.1
    *
    */
    @WebService(portName = “Information”, serviceName = “CustomerService”, targetNamespace = “http://buymore.com/online/”, wsdlLocation = “/wsdls/customer.wsdl”, endpointInterface = “com.buymore.online.CustomerPort”)
    @BindingType(“http://schemas.xmlsoap.org/wsdl/soap/http”)
    public class CustomerService_InformationImpl implements CustomerPort {

    public CustomerService_InformationImpl() {
    }

    /**
    *
    * @param input
    * @return returns com.buymore.online.CustomerResponse
    */
    public CustomerResponse getCustomerData(SearchInput input) {
    return new CustomerInfoProvider().searchByCustomerId(input);
    }

    }

    and following is the log details for error -:

    org.eclipse.core.internal.resources.ResourceException: Resource ‘/OnlineStore/build/jws/.tmpclasses/com/buymore/online/CustomerResponse.class’ does not exist.
    at org.eclipse.core.internal.resources.Resource.checkExists(Resource.java:310)
    at org.eclipse.core.internal.resources.Resource.checkAccessible(Resource.java:193)
    at org.eclipse.core.internal.resources.File.getContents(File.java:285)
    at org.eclipse.core.internal.resources.File.getContents(File.java:276)
    at com.bea.workshop.webservices.core.util.JarFileProxy.addFiles(JarFileProxy.java:135)
    at com.bea.workshop.webservices.core.util.JarFileProxy.copyWithFiles(JarFileProxy.java:117)
    at com.bea.workshop.webservices.core.gen.JwsFromWsdlBuilder.buildJws0(JwsFromWsdlBuilder.java:170)
    at com.bea.workshop.webservices.core.gen.JwsFromWsdlBuilder.buildJws(JwsFromWsdlBuilder.java:100)
    at com.bea.workshop.webservices.ui.wizards.jwsfromwsdl.GenerateJwsFromWsdlWizard$1.execute(GenerateJwsFromWsdlWizard.java:146)
    at org.eclipse.ui.actions.WorkspaceModifyOperation$1.run(WorkspaceModifyOperation.java:101)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1797)
    at org.eclipse.ui.actions.WorkspaceModifyOperation.run(WorkspaceModifyOperation.java:113)
    at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:369)
    at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:313)
    at org.eclipse.jface.wizard.WizardDialog.run(WizardDialog.java:934)
    at com.bea.workshop.webservices.ui.wizards.jwsfromwsdl.GenerateJwsFromWsdlWizard.run(GenerateJwsFromWsdlWizard.java:159)
    at com.bea.workshop.webservices.ui.wizards.jwsfromwsdl.GenerateJwsFromWsdlWizard.performFinish(GenerateJwsFromWsdlWizard.java:143)
    at org.eclipse.jface.wizard.WizardDialog.finishPressed(WizardDialog.java:742)
    at org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDialog.java:373)
    at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:618)
    at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:227)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3687)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3298)
    at org.eclipse.jface.window.Window.runEventLoop(Window.java:820)
    at org.eclipse.jface.window.Window.open(Window.java:796)
    at com.bea.workshop.webservices.ui.actions.WebServiceDerivedAction.openWizard(WebServiceDerivedAction.java:96)
    at com.bea.workshop.webservices.ui.actions.GenerateJwsFromWsdlAction.run(GenerateJwsFromWsdlAction.java:95)
    at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:256)
    at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:546)
    at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:490)
    at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:402)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3687)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3298)
    at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2389)
    at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2353)
    at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2219)
    at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:466)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:289)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:461)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:106)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:169)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:106)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:363)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:176)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:508)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:447)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1173)
    at org.eclipse.equinox.launcher.Main.eclipse_main(Main.java:1148)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.m7.installer.util.NitroxMain$1.run(NitroxMain.java:33)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)

  10. I am not sure how often you check here but if you have time, could you please help me with below:

    a) How to remove that ns1, ns0 from the response?
    b) How to bundle this as an ear file?

    I am quite new to J2EE so, any directions in this would be really helpful.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s