Brian Lloyd
Brian Lloyd, http://www.zope.com
E-mail: brian@zope.com
Release 1.0
Oct 29, 2001
See Also:
from WebService.ServiceProxy import ServiceProxy
service = ServiceProxy('http://www.xmethods.net/sd/BabelFishService.wsdl')
value = service.BabelFish('en_de', 'This is a test!')
from WebService.ServiceProxy import SOAPMethod
method = SOAPMethod('EchoString',
url='http://www.example.com/EchoService',
namespace='urn:EchoService',
soapAction=''urn:EchoService#EchoString'
)
result = method(data='Echo this string!')
from WebService.ServiceProxy import ServiceProxy
service = ServiceProxy('http://www.xmethods.net/sd/BabelFishService.wsdl')
value = service.BabelFish('en_de', 'This is a test!')
None if undefined.
1.1. For new messages, this should be set before the
serialize() method is called to have an effect.
If the message is loaded from an existing message body, this attribute will
reflect the protocol version of the message after the deserialize()
method is called.
'document' and 'rpc'. The default is 'rpc'.
None
if the message body is not yet available. Note that for SOAPMessage
instances that are not initialized with a message body, the message body
is not available until after the serialize() method is called.
None
if the named part is not found.
None
if the named header is not found.
(namespaceURI, typeName). If the actor or
mustUnderstand attributes are specified, the corresponding header
attributes will appear in the SOAP message.
None if the named
parameter is not found. The return value will be either a Parameter
or MIMEPart object.
(namespaceURI, typeName).
The namespace should only be passed when adding parameters to
a SOAP document-style message. Note that parameters are serialized in
the order that they are added to the message.
multipart/related message.
None if no fault is present in the message. Note that
fault information is not available until the message has been deserialized.
XXX attribute of the SOAPMessage.
This method will call the beforeSerialize() before beginning
serialization and afterSerialize() afterward, making it easy
for subclasses to provide custom message processing.
from WebService.SOAPMessage import SOAPMessage
from WebService.Transports import HTTPTransport
# Build the outgoing SOAP request message.
message = SOAPMessage()
message.soapAction = 'urn:xmethodsBabelFish#BabelFish'
message.methodName = 'BabelFish'
message.namespace = 'urn:xmethodsBabelFish'
message.addParameter('translationmode', 'en_de', (DOM.NS_XSD, 'string'))
message.addParameter('sourcedata', 'This is a test!', (DOM.NS_XSD, 'string'))
message.serialize()
# Send the message to the remote web service.
transport = HTTPTransport()
response = transport.send(
'http://services.xmethods.net:80/perl/soaplite.cgi',
'urn:xmethodsBabelFish#BabelFish',
message.getMessageBody(),
message.getContentType()
)
# Create a new SOAPMessage for the response.
reply_msg = SOAPMessage(response.body)
reply_msg.deserialize()
result = reply_msg.getReturnValue()
from WebService.WSDLTools import WSDLReader
reader = WSDLReader()
wsdl = reader.loadFromURL('http://www.xmethods.net/sd/BabelFishService.wsdl')
for service in wsdl.services.values():
print service.name
'document'
or 'rpc'. The default is 'rpc' if a style is not
specified.
from WebService.SOAPCallInfo import SOAPCallInfo
from WebService.WSDLTools import WSDLWriter
from WebService.Utility import DOM
writer = WSDLWriter('http://www.example.com/services/EchoService.wsdl')
writer.startService('EchoService',
'http://www.example.com/services/EchoService.cgi',
'A simple echoing service.',
)
callinfo = SOAPCallInfo('echoString')
callinfo.documentation = 'Echo a string argument.'
callinfo.addInParameter('data', (DOM.NS_XSD_01, 'string'))
callinfo.setReturnParameter('return', (DOM.NS_XSD_01, 'string'))
writer.writeMethod(callinfo)
callinfo = SOAPCallInfo('echoInteger')
callinfo.documentation = 'Echo an integer argument.'
callinfo.addInParameter('data', (DOM.NS_XSD_01, 'int'))
callinfo.setReturnParameter('return', (DOM.NS_XSD_01, 'int'))
writer.writeMethod(callinfo)
callinfo = SOAPCallInfo('echoFloat')
callinfo.documentation = 'Echo a float argument.'
callinfo.addInParameter('data', (DOM.NS_XSD_01, 'float'))
callinfo.setReturnParameter('return', (DOM.NS_XSD_01, 'float'))
writer.writeMethod(callinfo)
writer.endService()
wsdl = writer.toXML()
None if not specified.
None if not specified.
None
if the description was not loaded from a URL.
checksum argument to a WSDLReader.
Note that the hash returned is based on the entirety of the logical WSDL
description, including any imported elements of the description.
<service> element.
<port> element.
<portType> element.
<operation> element
within a portType.
parameterOrder attribute of the operation,
or None if the attribute is not defined.
<input> element of
the operation binding, or None if no input element is present.
<output> element of
the operation, or None if no output element is present.
<fault>
elements of the operation.
<input>, <output>
and <fault> elements within an operation.
'input', 'output' or
'fault'.
<binding> element.
(namespaceURI, typeName), which will be used to try to find a
matching DOM Element.
<operation>
element within a binding element.
<input>
element of the operation binding, or None if no input element is
present.
<output>
element of the operation binding, or None if no output element is
present.
<fault> elements of the operation binding.
(namespaceURI, typeName), which will be used to
try to find a matching DOM Element.
<input> of the operation binding.
The binding may be an instance of a supported binding class or a
DOM Element.
<output> of the operation binding.
The binding may be an instance of a supported binding class or a
DOM Element.
<fault> of the operation binding
named by name. The binding may be an instance of a supported
binding class or a DOM Element.
<input>,
<output> and <fault> elements within an operation binding.
None for input and output elements.
'input', 'output' or
'fault'.
(namespaceURI, typeName), which will be used to
try to find a matching DOM Element.
<message> element.
(namespaceURI, typeName).
<part> element.
(namespaceURI, typeName), or None
if the type attribute is not defined.
(namespaceURI, typeName), or None
if the element attribute is not defined.
<types> element. It acts
as an ordered collection containing XMLSchema instances associated
with the service description (either directly defined in a <types>
element, or included via import). The Types object can be indexed
by ordinal or by the targetNamespace of the contained schemas.
<import> element.
<soap:binding> element.
<soap:address> element.
<soap:operation> element.
<soap:body> element.
<soap:fault> element.
<soap:header> element.
<soap:headerfault> element.
<http:binding> element.
<http:address> element.
<http:operation> element.
<http:urlReplacement> element.
<http:urlEncoded> element.
<mime:multipartRelated> element.
<mime:part> element.
<mime:content> element.
<mime:mimeXml> element.
None. For
SOAPCallInfo objects loaded from WSDL, a value of None
indicates that the WSDL did not define a value for the attribute.
'document' and 'rpc'. The default
value for this attribute is 'rpc'.
'literal' and 'encoded', per
the WSDL specification. The default value for this attribute is
'encoded'.
(namespaceURI, typeName) that indicates an XSD simpleType,
complexType or element associated with the parameter.
The optional namespace, if specified, indicates a namespace URI to
be used for element serialization. A true value may be passed for the
optional element_type to indicate that type is a reference to
an XSD element rather than a simpleType or complexType.
return
parameter of the operation. Note that it possible for SOAP operations to
not define a return value, in which case this returns None.
(namespaceURI, typeName) that indicates an
XSD simpleType, complexType or element associated with the parameter.
type attribute of the
parameter is a reference to an XSD element rather than a simpleType or
complexType. The default for this attribute is 0.
None.
namespace attribute must
have a non-null value and there is an added mustUnderstand
attribute indicating whether or not the header is a ``must understand''
SOAP header.
from WebService.SOAPCallInfo import callInfoFromWSDL
from WebService.WSDLTools import WSDLReader
wsdl = WSDLReader.loadFromURL('http://www.mssoapinterop.org/asmx/typed.asmx?WSDL')
service = wsdl.services[0]
port = service.ports[0]
binding = port.getBinding()
for item in binding.getOperations():
callinfo = callInfoFromWSDL(port, item.name)
print 'Method ' + callinfo.methodName + ' takes arguments: ',
for param in callinfo.getInParameters():
print param.name + ' ',
print
document is bound to that of
the SOAPReader.
'1.1').
None if the message does not contain a header.
None if the body has no child elements.
None if the RPC struct has no child elements.
href attribute of the element. If element does not have an
href attribute, the input element is returned.
None if the message does not contain a fault.
None if the message does not contain a fault.
None if
the message does not contain it.
None if the message does not contain it.
None if the message does not contain it.
None if the
message does not contain it.
from WebService.SOAPReader import SOAPReader from WebService.Utility import DOM xmldata = '''<?xml version="1.0" encoding="UTF-8" standalone="no"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <SOAP-ENV:Body> <m:SomeMethodName xmlns:m="Some-URI"> <param1 xsi:type=''xsd:int''>1</param1> <param2 xsi:type=''xsd:int''>2</param2> <param3 xsi:type=''xsd:int''>3</param3> </m:SomeMethodName> </SOAP-ENV:Body> </SOAP-ENV:Envelope>''' reader = SOAPReader(xmldata) params = reader.getRPCParams() print 'The number of parameters is ' + str(len(params))
UTF-8.
version passed in the constructor.
version passed in the constructor.
from WebService.SOAPWriter import SOAPWriter
from WebService.Utility import DOM
writer = SOAPWriter()
writer.startEnvelope(encodingStyle=writer.NS_SOAP_ENC)
writer.startBody()
# Write the RPC struct element.
writer.startElement('BabelFish', 'urn:xmethodsBabelFish')
# Write the parameter elements.
typestr = writer.makeQName(DOM.NS_XSD, 'string')
writer.startElement('translationmode')
writer.writeAttr('type', typestr, DOM.NS_XSI)
writer.writeText('en_de')
writer.endElement()
writer.startElement('sourcedata')
writer.writeAttr('type', typestr, DOM.NS_XSI)
writer.writeText('This is a test!')
writer.endElement()
# End the RPC struct element.
writer.endElement()
writer.endBody()
writer.endEnvelope()
xml = writer.toString(1)
xml variable would produce:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns0="urn:xmethodsBabelFish"
xmlns:ns1="http://www.w3.org/2001/XMLSchema"
xmlns:ns2="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
<ns0:BabelFish>
<translationmode ns2:type="ns1:string">
en_de
</translationmode>
<sourcedata ns2:type="ns1:string">
This is a test!
</sourcedata>
</ns0:BabelFish>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
UTF-8.
document is bound to that of
the XMLWriter.
prefix:name, or simply name if
namespaceURI is the default namespace). This value is suitable for
qualified name linking within the document.
id attribute of an XML
element for referencing purposes.
from WebService.XMLWriter import XMLWriter
writer = XMLWriter()
writer.startElement('numbers')
for n in range(5):
writer.startElement('item')
writer.writeText(str(n))
writer.endElement()
writer.endElement()
xml = writer.toString(1)
xml variable would produce:
<?xml version="1.0" encoding="UTF-8"?>
<numbers>
<item>
0
</item>
<item>
1
</item>
<item>
2
</item>
<item>
3
</item>
<item>
4
</item>
</numbers>
None (if the context is for serialization rather than deserialization).
None (if the context is for deserialization rather than serialization).
| Schema Type | Python Type |
|---|---|
xsd:boolean |
int |
xsd:integer |
long |
xsd:unsignedInt |
long |
xsd:unsignedLong |
long |
xsd:nonPositiveInteger |
long |
xsd:nonNegativeInteger |
long |
xsd:negativeInteger |
long |
xsd:positiveInteger |
long |
xsd:long |
long |
xsd:int |
int |
xsd:short |
int |
xsd:unsignedShort |
int |
xsd:byte |
int |
xsd:unsignedByte |
int |
xsd:decimal |
float |
xsd:double |
float |
xsd:float |
float |
xsd:string |
string |
xsd:normalizedString |
string |
xsd:anyURI |
string |
xsd:QName |
string |
xsd:Name |
string |
xsd:NCName |
string |
xsd:token |
string |
xsd:language |
string |
xsd:NOTATION |
string |
xsd:NMTOKENS |
sequence |
xsd:NMTOKEN |
string |
xsd:IDREFS |
sequence |
xsd:IDREF |
string |
xsd:ENTITIES |
sequence |
xsd:ENTITY |
string |
xsd:ID |
string |
xsd:dateTime |
date-time tuple |
xsd:timePeriod |
date-time tuple |
xsd:duration |
date-time tuple |
xsd:time |
date-time tuple |
xsd:date |
date-time tuple |
xsd:gYearMonth |
date-time tuple |
xsd:gYear |
date-time tuple |
xsd:gMonthDay |
date-time tuple |
xsd:gDay |
date-time tuple |
xsd:gMonth |
date-time tuple |
xsd:base64Binary |
string |
xsd:base64 |
string |
xsd:hexBinary |
string |
enc:base64 |
string |
enc:arrayType |
sequence |
| Schema Type | Python Type |
|---|---|
string |
xsd:string |
int |
xsd:integer |
long |
xsd:long |
float |
xsd:float |
sequence |
soap-enc:Array |
from WebService.XMLSchema import SchemaReader
reader = SchemaReader()
schema = reader.loadFromURL('http://www.example.com/schemas/someSchema.xml')
for element in schema.elements.values():
print element.name
None if not specified.
None if the schema was
not loaded from a URL.
'text/xml'. An optional headers mapping may be
specified, containing extra HTTP headers to be sent with the message.
This method returns an classHTTPResponse instance containing the response
information, unless a server error occurs. An HTTPResponse will be
raised as an exception for any non-2xx response that does not include a
text/xml message body.
SOAPAction MIME
header with the message. The message should be the SOAP message string
to be sent. The optional contentType indicates the content type of the
message (which defaults to 'text/xml'. An optional headers
mapping may be specified, containing extra MIME headers to be sent with the
message.
Since SMTP messaging is inherently one-way, this method returns None.
None if no match is found.
None if no match is found.
This document was generated using the LaTeX2HTML translator.
LaTeX2HTML is Copyright © 1993, 1994, 1995, 1996, 1997, Nikos Drakos, Computer Based Learning Unit, University of Leeds, and Copyright © 1997, 1998, Ross Moore, Mathematics Department, Macquarie University, Sydney.
The application of LaTeX2HTML to the Python documentation has been heavily tailored by Fred L. Drake, Jr. Original navigation icons were contributed by Christopher Petrilli.