Take the 2-minute tour ×

I'm attempting to write a simple SOAP client in Python that consumes a WSDL file. I've tried pysimplesoap and SUDS and both of these fail for various reasons.

from pysimplesoap.client import SoapClient

wsdl = "http://www.onvif.org/onvif/ver10/device/wsdl/devicemgmt.wsdl"
client = SoapClient(wsdl=wsdl)

print client

The pysimplesoap client fails with AttributeError: Tag not found: service (No elements found)

from SOAPpy import WSDL
server = WSDL.Proxy(wsdlFile)

The SOAPpy client throws an IndexError: list index out of range exception.

I a total newbie to SOAP, so I'm guessing that I've made a very basic error somewhere.

share|improve this question
add comment

1 Answer

With suds:


<wsdl:service name="DeviceService">
    <wsdl:port binding="tds:DeviceBinding" name="DevicePort"> 
    <soap:address location="http://localhost/onvif/device_service/"/> 

between and at the end of devicemgmt.wsdl file. The original wsdl didn't have the service defined and this was the reason why suds was unhappy

The script:

import suds
import os

SERVER_URL = 'http://<INSERT_YOUR_CAMERAS_IP_HERE>:80/device_service'
WSDL_URL='file:' + os.getcwd() + '/wsdl/devicemgmt.wsdl'
security =  suds.wsse.Security()
token =  suds.wsse.UsernameToken('<INSERT_YOUR_USERNAME>', '<INSERT_YOUR_PASSWORD>')
token.setnonce('<INSERT_YOUR_NONCE>') # token.setonce() didn't work for me

print res

"print cli" doesn't work but never mind... Location of wsdl is ./wsdl/devicemgmt.wsdl and files referred from the wsdl were placed in the same location (after fixing the links)

share|improve this answer
Following your post, I've downloaded the devicemgmt.wsdl file and edited it to include the <wsdl:service> fragment posted and I've placed it at the end of the file, just before </wsdl:definitions>. I'm now getting the error Exception: No services defined. I think this is making progress, slowly... –  CadentOrange Feb 7 at 14:51
So very close. I've edited the devicemgmt.wsdl so that onvif.xsd comes directly from the ONVIF website. I'm now getting a 502 "bad gateway" error. –  CadentOrange Feb 7 at 16:08
add comment

Your Answer


