Typical usage of Orchard.SOAP looks like this:

  from Orchard import SOAP

  # for Pickling and Unpickling
  a = { 'a' : { 'b' : 'boo' } }

  xml_string = SOAP.dumps(a)
  obj = SOAP.loads(xml_string)

  # for RPC clients
  proxy = SOAP.connect(url='http://www.zaks.demon.co.uk/calc')
  result = proxy.doubler([10, 20, 30, 50, 100])
  print result

Orchard.SOAP

This module reads and writes SOAP 1.1 format XML and provides RPC client support (HTTP only).

Pickling and Unpickling

The Orchard.SOAP module provides a similar interface to Python's native pickle module, but writes and reads SOAP 1.1 format XML.

The object to be pickled must be a dictionary (or Orchard Node) with only one key, so that that key can become the root element of the SOAP XML instance. The value of that key can be any type of Python object.

If the object to be pickled is an Orchard Node and includes additional keys in the XML Namespaces namespace ('http://www.w3.org/2000/xmlns/'), they will be used as namespace declarations on the root element. For example:

  >>> xmlns_ns = 'http://www.w3.org/2000/xmlns/'
  >>> root = Orchard.Node()
  >>> root[(xmlns_ns, 'foo')] = 'urn:foo'
  >>> root.my_root = "string value"
  >>> print SOAP.dumps(root)
  <?xml version="1.0"?>
  <my_root
     xsi:type="xsd:string"
     SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
     xmlns:foo="urn:foo">string value</my_root>
[XML output edited for readability.]

RPC

Orchard.SOAP provides a basic SOAP HTTP RPC client that takes rather ordinary Python procedure calls and forwards them to the remote SOAP server for processing, and then returning the result or raising an exception if there is a SOAP fault or other transport error. (Error handling not fully implemented, the actual exception raised is not yet defined.)

The one unique thing about SOAP RPCs (different from ordinary Python procedure calls) is that every SOAP RPC takes only one dictionary as an argument, and returns a dictionary as the result.

'SOAP.connect()' creates a proxy object representing the remote SOAP server. All method calls made using the proxy will be wrapped up as a SOAP message, sent to the server for processing, and the result unwrapped and returned to the caller. As in the example in the synopsis above:

  proxy = SOAP.connect(url='http://www.zaks.demon.co.uk/calc')
  result = proxy.doubler([10, 20, 30, 50, 100])
  print result

'SOAP.connect()' accepts the following arguments:
url The URL of the SOAP server.
debug Set to 1 to print XML sent and received.
namespace The namespace to use for these RPC methods.