How do I make a Python client that can consume a .NET (soap) web service? -
i'm trying make python client can consume .net (soap) web service. i've been looking @ suds library so, appears recommended. have far:
from suds.client import client suds.transport.https import windowshttpauthenticated ntlm_transport = windowshttpauthenticated(username='myusername', password='mypassword') client = client('http://server:port/path?wsdl', transport=ntlm_transport) some_complex_type = client.factory.create('somecomplextype') # how set properties of some_complex_type if wsdl doesn't define looks like? return_value = client.service.methodthatusessomecomplextype(some_complex_type)
from suds documentation complex arguments, appears typically if print client.factory.create('somecomplextype')
output properties complex type has (according wsdl). in case, however, if do: print some_complex_type
, "<empty>", which, guess, means wsdl missing definition somecomplextype
(aside stating exists).
does maker of web service i'm consuming have things set incorrectly? or there special/different way microsoft defines types in wsdl, , need configure suds client differently?
i've found when using suds library, in example above, if complex type definition missing wsdl, can send python dictionary, values remote service wants, in place of complex type.
for example, using example above, instead of doing following:
some_complex_type = client.factory.create('somecomplextype') some_complex_type.foo = 'hello' # borks definition of somecomplextype missing wsdl some_complex_type.bar = 'world' return_value = client.service.methodthatusessomecomplextype(some_complex_type)
you can following:
some_complex_type = { 'foo': 'hello' 'bar': 'world' } return_value = client.service.methodthatusessomecomplextype(some_complex_type)
the some_complex_type dictionary can contain sub-dictioaries , sub-lists of other dictionaries, etc. form of dictionary tree should match form of xml web service wants receive.
Comments
Post a Comment