Structure of the WSDL Document


The Complete WSDL File

Now that you have examined each section of a WSDL document, you need to look at it as a whole. Remember that WSDL is not necessarily for a person to read; it’s more for an application to read in order to use the Web Service. Therefore, the XML might look pretty ugly in the complete document.

<definitions name="GetStockQuote         targetNamespace="http://advocatemedia.com/GetStockQuote.wsdl"         xmlns:myns = "http://advocatemedia.com/GetStockQuote.wsdl"         xmlns:myXsd = "http://advocatemedia.com/GetStockQuote.xsd"         xmlns:soap = "http://schemas.xmlsoap.org/wsdl/soap"         xmlns="http://schemas.xmlsoap.org">        <types>         <schema           targetNamespace="http://advocatemedia.com/GetStockQuote.xsd"           xmlns="http://www.w3.org/2000/10/XMLSchema">           <element name="StockQuoteRequest">              <complexType>                <all>                  <element name="symbol" type="string"/>                </all>              </complexType>           </element>           <element name="StockQuoteResponse">              <complexType>                <all>                  <element name="price" type="float"/>                </all>              </complexType>           </element>          </schema>        </types>        <message name="GetStockQuote">           <part name="body" element="myXSD:StockQuoteRequest"/>        </message>        <message name="GetStockQuoteResponse">           <part name="body" element="myXSD:StockQuoteResponse"/>        </message>       <portType name="GetStockQuotePort>           <operation name="GetStockQuote">               <input message="myns:GetStockQuoteRequest"/>               <output message="myns:GetStockQuoteResponse"/>           </operation>       </portType>       <binding name="GetStockQuoteBindingName"                type="StockQuoteBinding">       <soap:binding             style="rpc"             transport=" http://schemas.xmlsoap.org/soap/http"/>           <operation name="GetStockQuote">               <soap:operation                   soapAction="http://advocatemedia.com/GetStockQuote"/>               <input>                   <soap:body use="literal"/>               </input>               <output>                   <soap:body use="literal"/>               </output>           </operation>       </binding>       <service name="AdvocateMediaGetStockQuotes">         <documentation>Simple Web Service to                        Retrieve a stock quote</documentation>         <port name="GetStockQuotePort"               binding="myns:GetStockQuoteBindingName">           <soap:address                 location="http://advocatemedia.com/GetStockQuote"/>         </port>       </service>   </definitions>

Using import

There is an alternate and perhaps easier way of writing the WSDL file. This involves defining all the types in an XML Schema Reduced (XSD) file while putting all the other definitions relevant to the Web Service in the WSDL file. This way, the schema element and all of its children are in a separate file. If you are using the same elements in different Web Services, you can easily move the schema definitions from application to application. For example, there may be several stock-related Web Services that use the same types and variables. This way one XSD file could support all the different services.

Here is the GetStockQuote.xsd example.

    <schema           targetNamespace="http://advocatemedia.com/GetStockQuote.xsd"           xmlns="http://www.w3.org/2000/10/XMLSchema">           <element name="StockQuoteRequest">              <complexType>                <all>                  <element name="symbol" type="string"/>                </all>              </complexType>           </element>           <element name="StockQuoteResponse">              <complexType>                <all>                  <element name="price" type="float"/>                </all>              </complexType>           </element>      </schema>

From within the WSDL file, the import element is used to bring in the element definitions in GetStockQuote.xsd, as shown in the following code.

<definitions name="GetStockQuote         targetNamespace="http://advocatemedia.com/GetStockQuote.wsdl"         xmlns:myns = "http://advocatemedia.com/GetStockQuote.wsdl"         xmlns:myXsd = "http://advocatemedia.com/GetStockQuote.xsd"         xmlns:soap = "http://schemas.xmlsoap.org/wsdl/soap"         xmlns="http://schemas.xmlsoap.org">        <import namespace="http://advocatemedia.com/GetStocks/schemas"               location ="http://advocatemedia.com/GetStocks/quote.xsd">        <message name="GetStockQuote">           <part name="body" element="myXSD:StockQuoteRequest"/>        </message>        <message name="GetStockQuoteResponse">           <part name="body" element="myXSD:StockQuoteResponse"/>        </message>       <portType name="GetStockQuotePort>           <operation name="GetStockQuote">               <input message="myns:GetStockQuoteRequest"/>               <output message="myns:GetStockQuoteResponse"/>           </operation>       </portType>       <binding name="GetStockQuoteBindingName"                type="StockQuoteBinding">       <soap:binding             style="rpc"             transport=" http://schemas.xmlsoap.org/soap/http"/>           <operation name="GetStockQuote">               <soap:operation                   soapAction="http://advocatemedia.com/GetStockQuote"/>               <input>                   <soap:body use="literal"/>               </input>               <output>                   <soap:body use="literal"/>               </output>           </operation>       </binding>       <service name="AdvocateMediaGetStockQuotes">         <documentation>Simple Web Service to                        Retrieve a stock quote</documentation>         <port name="GetStockQuotePort"               binding="myns:GetStockQuoteBindingName">           <soap:address                 location="http://advocatemedia.com/GetStockQuote"/>         </port>       </service>   </definitions>

Notice that only the difference between this and the original complete WSDL example is the import element.




Cross-Platform Web Services Using C# and Java
Cross-Platform Web Services Using C# & JAVA (Charles River Media Internet & Web Design)
ISBN: 1584502622
EAN: 2147483647
Year: 2005
Pages: 128

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net