[Soap-Python] Setting attributes in SOAP responses through pysimplesoap SoapDispatcher

Mark Howell mark-sub1 at hypgnosys.org
Tue Aug 25 23:45:08 CEST 2015


Hello pysimplesoap-ers,

I'm trying to use pysimplesoap to serve replies with XML attributes.

A snippet of the kind of message I'd like to be able to generate with 
SoapDispatcher, coming from docs for ONVIF (IP video interoperability 
standards):

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tt="http://www.onvif.org/ver10/schema"
xmlns:trt="http://www.onvif.org/ver10/media/wsdl">
<SOAP-ENV:Body>
<<trt:GetProfilesResponse>
<trt:Profiles fixed="true" token="Profile1">
<tt:Name>Profile1</tt:Name>
<tt:VideoSourceConfiguration xsi:type="tt:VideoSourceConfiguration"
token="video_source_config">
...

How might I set the "fixed" and "token" attributes of the "trt:Profiles" 
element in my dispatcher fn "get_profiles()", below?

Code snippet thus far:

def get_profiles():
     ret = {
         'trt:Profiles' : { # how can I set attributes here?
             'tt:Name' : 'blahblahblah'
         }
     }

...

     dispatcher = SoapDispatcher(
         'my_dispatcher',
         location='http://localhost:8080/',
         action='http://localhost:8080',
         namespace='http://www.onvif.org/ver10/media/wsdl',
         prefix='trt',
         namespaces={
             'trt' : 'http://www.onvif.org/ver10/media/wsdl',
             'tt' : 'http://www.onvif.org/ver10/schema'
         },
         trace=True,
         ns=True
     )

     dispatcher.register_function(
         'GetProfiles',
         get_profiles,
         args={},
         returns={
             'trt:Profiles' : {
                 'tt:Name' : str
                 # ... and lots of other stuff, TBI
             }
         }

     )

Cheers,

Mark.


More information about the Soap mailing list