Given an XML schema for a document style Web service create a WSDL file that describes the service and generate a service implementation.

WSDL file:

					
<message name="AuthorNotFoundException">
     <part name="Author" type="xsd:string" />
</message>

<portType name ="BookSearch">
     <operation name="getBooksByAuthor" >
          <input message="tns:getAuthorName">
          <output message="tns:getBookList">
          <fault name="AuthorNotFoundException" message="tns:AuthorNotFoundException">
     </operation>
</portType>
					
					

Generated service endpoints interface (SEI):

public interface BookSearch extends java.rmi.Remote {
	public Books[] getBooksByAuthor(String authorName) throws java.rmi.RemoteException,
			com.acme.AuthorNotFoundException;
}
					

Generated exception class:

public class AuthorNotFoundException extends java.lang.Exception{	
	...	
	public AuthorNotFoundException(String Author) {
     	...
	}
	
	public getAuthor() {...}
}
					

More detailed example (also demonstrates references in SOAP 1.1 message):

WSDL file:


<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
                   xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
                   xmlns:tns="http://www.example.com"
             targetNamespace="http://www.example.com">

 <wsdl:types>
   <xsd:schema targetNamespace="http://www.example.com">

     <!-- "Person" type used by "compare" operation,
          note use optional attributes -->

     <xsd:complexType name="Person">
       <xsd:sequence>
         <xsd:element name="firstName" type="xsd:string" />
         <xsd:element name="lastName" type="xsd:string" />
       </xsd:sequence>
       <xsd:attribute name="id" type="xsd:ID" use="optional" />
       <xsd:attribute name="href" type="xsd:anyURI" use="optional" />
     </xsd:complexType>

   </xsd:schema>
 </wsdl:types>

 <!-- RPC style message definitions -->

 <wsdl:message name="compareInput">
   <wsdl:part name="person1" type="tns:Person" />
   <wsdl:part name="person2" type="tns:Person" />
 </wsdl:message>

 <wsdl:message name="compareOutput">
   <wsdl:part name="result" type="xsd:boolean" />
 </wsdl:message>

 <!-- Geometry portType -->

 <wsdl:portType name="Human">
   <wsdl:operation name="compare">
     <wsdl:input message="tns:compareInput" />
     <wsdl:output message="tns:compareOutput" />
   </wsdl:operation>
 </wsdl:portType>

 <!-- Binding for "Human" portType that
      uses SOAP encoding -->

 <wsdl:binding name="HumanBinding" type="tns:Human">
   <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" 
   <wsdl:operation name="compare">
     <soap:operation soapAction="" style="rpc" />
     <wsdl:input message="tns:compareInput">
       <soap:body namespace="http://www.example.com" use="literal" />
     </wsdl:input>
     <wsdl:output message="tns:compareOutput">
       <soap:body namespace="http://www.example.com" use="literal" />
     </wsdl:output>
   </wsdl:operation>
 </wsdl:portType>

</wsdl:definitions>
					
					

Will generate SEI:

public interface Human extends java.rmi.Remote {
	public boolean compare(Person person1, Person person2) throws java.rmi.RemoteException;
}					
					

Following Web-Service call:

Person one = new Person("Mikalai", "Zaikin");
Person two = new Person("Volha", "Zaikina");
boolean b = port.compare(one, two);					
					

will be serialized in the following SOAP 1.1 message:


<soap:Envelope xmlns:soap= "http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
  
    <ns:compare xmlns:ns="http://www.example.com">
      <person1>
        <firstName>Mikalai</firstName>
        <lastName>Zaikin</lastName>
      </person1>
      <person2>
        <firstName>Volha</firstName>
        <lastName>Zaikina</lastName>
      </person2>
    </ns:compare>
    
  </soap:Body>
</soap:Envelope>
					
					

Following Web-Service call:

Person one = new Person("Mikalai", "Zaikin");
boolean b = port.compare(one, one);								
					

will be serialized in the following SOAP 1.1 message:


<soap:Envelope xmlns:soap= "http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
  
    <ns:compare xmlns:ns="http://www.example.com">
      <person1 href="#unique_person_id" />
      <person2 href="#unique_person_id" />
    </ns:compare>

    <ns:Person id="unique_person_id" xmlns:ns="http://www.example.com">
      <firstName>Mikalai</firstName>
      <lastName>Zaikin</lastName>
    </ns:Person>
    
  </soap:Body>
</soap:Envelope>
					
					

Professional hosting     Belorussian informational portal         Free SCWCD 1.4 Study Guide     Free SCBCD 1.3 Study Guide     SCDJWS 1.4 Quiz     Free IBM Certified Associate Developer Study Guide     Free SCJP 5.0 (Tiger) Study Guide     Free Mock Exam Engine     IBM Test 000-287. Enterprise Application Development with IBM WebSphere Studio, V5.0 Study Guide     IBM Test 000-255. Developing with IBM Rational Application Developer for WebSphere Software V6 Study Guide