Download TEAM LinG - LinuxTone.Org

Transcript
Web Applications and Web Services
A rather redundant section follows, as the four SOAP functions are bound to SOAP-over-HTTP:
<!--A binding of the BittyWiki API functions (previously defined only
in the abstract) to the specific “SOAP-over-HTTP” protocol.-->
<binding type=”BittyWikiPortType” name=”BittyWikiSOAPBinding”>
<soap:binding style=”rpc” transport=”http://schemas.xmlsoap.org/soap/http” />
<operation name=”getPage”>
<input><soap:body use=”literal” namespace=”urn:BittyWiki” /></input>
<output><soap:body use=”literal” namespace=”urn:BittyWiki” /></output>
</operation>
<operation name=”save”>
<input><soap:body use=”literal” namespace=”urn:BittyWiki” /></input>
<output><soap:body use=”literal” namespace=”urn:BittyWiki” /></output>
</operation>
<operation name=”delete”>
<input><soap:body use=”literal” namespace=”urn:BittyWiki” /></input>
<output><soap:body use=”literal” namespace=”urn:BittyWiki” /></output>
</operation>
</binding>
Finally, the code to let WSDL know where to find the BittyWiki web service:
<!--A link to the BittyWiki web service on the web. It uses the
BittyWiki API defined in BittyWikiPortType, as realized by its
SOAP-over-HTTP binding, BittyWikiSOAPBinding.-->
<service name=”BittyWiki”>
<port name=”BittyWikiPort” binding=”BittyWikiSOAPBinding”>
<soap:address location=”http://localhost:8002/”/>
</port>
</service>
</definitions>
The BittyWiki API doesn’t define any custom data types, so there’s no types element in its WSDL file.
If you want to see a types element that has some complexTypes, look at the WSDL file for the Google
Web APIs.
WSDL is pretty complicated: That WSDL file is bigger than the Python script implementing the web service it describes. WSDL files are usually generated from the corresponding web service source code, so
that humans don’t have to specify them. It’s not possible to do this from Python code because a big part
of WSDL is defining the data types, and Python functions don’t have predefined data types. Both the
SOAPpy and ZSI libraries can parse WSDL (in fact, they share a WSDL library: wstools), but there’s not
much in the way of Python-specific resources for generating WSDL.
Try It Out
Manipulating BittyWiki through a WSDL Proxy
The following looks more or less like the previous example of BittyWiki manipulation through direct
SOAP calls:
533
TEAM LinG