Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Sample code for the Acme Booksellers Web service

Return to article


Figure A1. Web service development process
Web service development process

Listing A1. AcmeBookSearch.wsdl

<?xml version="1.0"?>
<definitions name="AcmeBookSearch" 
      targetNamespace="http://www.acme.com/AcmeBookStore/BookSearchSoapService" 
     xmlns:typens="http://www.acme.com/AcmeBookStore/BookSearchSoapService" 
     xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
     xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
     xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
     xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
     xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
     xmlns="http://schemas.xmlsoap.org/wsdl/">
     <types>
     <xsd:schema xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
          targetNamespace="http://www.acme.com/AcmeBookStore/BookSearchSoapService">

               <xsd:complexType name="ReviewInformation">
                    <xsd:all>
                         <xsd:element name="review" type="xsd:string"/>
                         <xsd:element name="author" type="xsd:string" minOccurs="10"/>
                         <xsd:element name="price" type="xsd:float"/>
                    </xsd:all>
                    <xsd:attribute name="reviewer" type="xsd:string" />
               </xsd:complexType>

               <xsd:complexType name="ProductInfo">
                    <xsd:all>
                         <xsd:element name="Details" type="typens:DetailsArray"/>
                    </xsd:all>
               </xsd:complexType>
               <xsd:complexType name="Details">
                    <xsd:all>
                         <xsd:element name="Url" type="xsd:string"/>
                         <xsd:element name="BookName" type="xsd:string"/>
                         <xsd:element name="Authors" type="typens:AuthorArray"/>
                         <xsd:element name="ImageUrl" type="xsd:string"/>
                         <xsd:element name="ListPrice" type="xsd:string"/>
                         <xsd:element name="Isbn" type="xsd:string"/>
                    </xsd:all>
               </xsd:complexType>
               <xsd:complexType name="DetailsArray">
                    <xsd:complexContent>
                         <xsd:restriction base="soapenc:Array">
                              <xsd:attribute ref="soapenc:arrayType" wsdl:arrayType="typens:Details[]"/>
                         </xsd:restriction>
                    </xsd:complexContent>
               </xsd:complexType>
               <xsd:complexType name="AuthorArray">
                    <xsd:complexContent>
                         <xsd:restriction base="soapenc:Array">
                              <xsd:attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:string[]"/>
                         </xsd:restriction>
                    </xsd:complexContent>
               </xsd:complexType>
               <xsd:complexType name="AuthorRequest">
                    <xsd:all>
                         <xsd:element name="author" type="xsd:string"/>
                    </xsd:all>
               </xsd:complexType>

               <xsd:complexType name="Authors">
                    <xsd:all>
                         <xsd:element name="Authors" type="typens:AuthorArray"/>
                    </xsd:all>
               </xsd:complexType>

          </xsd:schema>
     </types>
     
     <!-- Messages for Acme Web APIs -->
     <message name="AuthorSearchRequestHeader">
          <part name="AuthorSearchRequestHeader" type="xsd:string"/>
     </message>

     <message name="ReviewInfo">
          <part name="ReviewInformation" type="typens:ReviewInformation"/>
     </message>
     
     <message name="ReviewInfoResponse">
          <part name="response" type="xsd:boolean"/>
     </message>

     <message name="UpdateBookImageRequest">
          <part name="BookIsbn" type="xsd:string"/>
          <part name="BookImage" type="xsd:string"/>
     </message>
     <message name="UpdateBookImageResponse">
          <part name="return" type="xsd:boolean"/>
     </message>


     <message name="AuthorSearchRequest">
          <part name="AuthorSearchRequest" type="typens:AuthorRequest"/>
     </message>
     <message name="AuthorSearchResponse">
          <part name="return" type="typens:ProductInfo"/>
     </message>
     <message name="AuthorNotPresent">
          <part name="AuthorNotPresent" type="xsd:string"/>
     </message>


     <message name="AuthorPresentRequest">
          <part name="Authors" type="typens:Authors"/>
     </message>
     <message name="AuthorPresentResponse">
          <part name="return" type="xsd:boolean"/>
          <part name="Authors" type="typens:Authors"/>
     </message>
     

     <!-- Port for Acme Web APIs -->
     <portType name="AcmeSearchPortType">
          <operation name="AuthorSearchRequest">
               <input message="typens:AuthorSearchRequest"/>
               <input message="typens:ReviewInfo"/>
               <output message="typens:AuthorSearchResponse"/>
               <fault name="AuthorNotPresentException" message="typens:AuthorNotPresent" />
          </operation>
     </portType>

     <portType name="AcmeBookMangementPortType">
          <operation name="UpdateReview">
               <input message="typens:ReviewInfo"/>
               <output message="typens:ReviewInfoResponse"/>
          </operation>
          <operation name="UpdateBookImage">
               <input message="typens:UpdateBookImageRequest"/>
               <output message="typens:UpdateBookImageResponse"/>
          </operation>
     </portType>

     <portType name="AcmeAuthorPresentPortType">
          <operation name="IsAuthorPresent">
               <input message="typens:AuthorPresentRequest"/>
               <output message="typens:AuthorPresentResponse"/>
          </operation>
     </portType>

     <!-- Binding for Acme Web APIs - RPC, SOAP over HTTP -->
     <binding name="AcmeSearchBinding_RPC" type="typens:AcmeSearchPortType">
          <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
          <operation name="AuthorSearchRequest">
               <soap:operation soapAction="http://www.acme.com/AcmeBookStore/BookSearchSoapService"/>
     
          <input>
                    <soap:header message="AuthorSearchRequestHeader" use="encoded" namespace="http://www.acme.com/AcmeBookStore/BookSearchSoapService" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
                    <soap:body use="encoded" namespace="http://www.acme.com/AcmeBookStore/BookSearchSoapService" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
               </input>
               <output>
                    <soap:body use="encoded" namespace="http://www.acme.com/AcmeBookStore/BookSearchSoapService" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
               </output>
               <!--
               <input>
                    <soap:header message="AuthorSearchRequestHeader" use="literal" namespace="http://www.acme.com/AcmeBookStore/BookSearchSoapService" />
                    <soap:body use="literal" namespace="http://www.acme.com/AcmeBookStore/BookSearchSoapService" />
               </input>
               <output>
                    <soap:body use="literal" namespace="http://www.acme.com/AcmeBookStore/BookSearchSoapService" />
               </output>
               -->
          </operation>
     </binding>
     <binding name="AcmeSearchBinding" type="typens:AcmeSearchPortType">
          <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
          <operation name="AuthorSearchRequest">
               <soap:operation soapAction="http://www.acme.com/AcmeBookStore/BookSearchSoapService"/>
               <!-- 
               <input>
                    <soap:header message="AuthorSearchRequestHeader" use="encoded" namespace="http://www.acme.com/AcmeBookStore/BookSearchSoapService" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
                    <soap:body use="encoded" namespace="http://www.acme.com/AcmeBookStore/BookSearchSoapService" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
               </input>
               <output>
                    <soap:body use="encoded" namespace="http://www.acme.com/AcmeBookStore/BookSearchSoapService" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
               </output>
               -->
               <input>
                    <soap:header message="AuthorSearchRequestHeader" use="literal" namespace="http://www.acme.com/AcmeBookStore/BookSearchSoapService" />
                    <soap:body use="literal" namespace="http://www.acme.com/AcmeBookStore/BookSearchSoapService" />
               </input>
               <output>
                    <soap:body use="literal" namespace="http://www.acme.com/AcmeBookStore/BookSearchSoapService" />
               </output>
          </operation>
     </binding>

     <binding name="AcmeBookMangement" type="typens:AcmeBookMangementPortType">
          <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
          <operation name="UpdateBookImage">
     
          <soap:operation soapAction="http://www.acme.com/AcmeBookStore/BookSearchSoapService"/>
               <input>
                   <mime:multipartRelated>
                    <mime:part>
                     <!-- <soap:body
                              encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
                          namespace="http://www.acme.com/AcmeBookStore/BookSearchSoapService"
                           parts="BookIsbn"
                         use="encoded"/>
                    -->
                          <mime:content part="BookIsbn" type="text/plain"/>
                        </mime:part>
                     <mime:part>
                          <mime:content part="BookImage" type="text/plain"/>
                        </mime:part>
                  </mime:multipartRelated>
               </input>
               <output>
                    <soap:body use="encoded" namespace="http://www.acme.com/AcmeBookStore/BookSearchSoapService" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
               </output>
          </operation>
          <operation name="UpdateReview">
               <soap:operation soapAction="http://www.acme.com/AcmeBookStore/BookSearchSoapService"/>
     
               <input>
                    <soap:body use="encoded" namespace="http://www.acme.com/AcmeBookStore/BookSearchSoapService" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
               </input>
               <output>
                    <soap:body use="encoded" namespace="http://www.acme.com/AcmeBookStore/BookSearchSoapService" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
               </output>
          </operation>
     </binding>
     <binding name="AcmeAuthorPresentBinding" type="typens:AcmeAuthorPresentPortType">
          <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
          <operation name="IsAuthorPresent">
               <soap:operation soapAction="http://www.acme.com/AcmeBookStore/BookSearchSoapService"/>
               <input>
                    <soap:body use="literal" namespace="http://www.acme.com/AcmeBookStore/BookSearchSoapService" />
               </input>
               <output>
                    <soap:body use="literal" namespace="http://www.acme.com/AcmeBookStore/BookSearchSoapService" />
               </output>
          </operation>
     </binding>

     <!-- Endpoint for Acme Web APIs -->
     <service name="AcmeSearchService">
          <port name="AcmeSearchPort" binding="typens:AcmeSearchBinding">
               <soap:address location="http://www.acme.com/acmebooksearch/soap"/>
          </port>
          <port name="AcmeSearchPort_RPC" binding="typens:AcmeSearchBinding_RPC">
               <soap:address location="http://www.acme.com/acmebooksearch/soap"/>
          </port>
          <port name="AcmeBookMangement" binding="typens:AcmeBookMangement">
               <soap:address location="http://www.acme.com/acmebooksearch/soap"/>
          </port>
          <port name="AcmeAuthorPresentPort" binding="typens:AcmeAuthorPresentBinding">
               <soap:address location="http://www.acme.com/acmebooksearch/soap"/>
          </port>
     </service>
</definitions>

Return to article