Giter Site home page Giter Site logo

suds-py3's Introduction

suds-py3

travisci readthedocs

Suds is a lightweight SOAP python client for consuming Web Services.

Mirror of http://svn.fedorahosted.org/svn/suds/trunk/ supporting Python3 and some fixes.

Overview

The "Suds" web services client is a lightweight soap-based client for python the is licensed under LGPL.

For details, visit:

Since the original library is no longer supported and documentation also disappeared along with it.

A copy of the documentation is hosted at https://suds-py3.readthedocs.io/en/latest/

This is not my original documentation however I have reformatted to sphinx rST style and updated few parts to keep the code examples clean and working.

Pull requests are welcome for the docs.

Features

  • No class generation
  • Provides an object API.
  • Reads wsdl at runtime for encoding/decoding
  • Supports the following SOAP binding styles:
  • Document/Literal
  • RPC/Literal
  • RPC/Encoded
  • Provides objectification of WSDL defined:
  • Types ''(objects)''
  • Enumerations
  • Service and type objects provide inspection via ''print''
  • Supports unicode
  • HTTP authentication
  • ''Basic'' WS-Security

Installation

pip3 install suds-py3

Sample usage

from suds.client import Client
client = Client('http://localhost:8181/soap/helloservice?wsdl', username='bob', password='catbob')
result = client.service.sayHello('bob')
# result -> "Hello, bob!"

Examples

Examples folder contains sample SOAP services in JAVA, .NET WCF.

Example has a python client that loads WSDL from http://localhost:8181/soap/helloservice?wsdl <- This is served by one of the below services.

RUN Any one of the JAVA/.NET WCF services

RUN python examples/test_client.py to test whether this package is working properly.

Running JAVA Soap service

  • cd examples/java-soap/ && sh run_service.sh

Running .NET WCF service

  • cd examples/NET45_WCF/ && run_service.bat <- Run this in Visual Studio developer command prompt

suds-py3's People

Contributors

andreif avatar cackharot avatar dependabot[bot] avatar dougroyal avatar filipleczynski avatar funkybob avatar gopackgo90 avatar hatchjdecho avatar karimabdelhakim avatar level44 avatar martin-pil avatar orangensaft avatar ryanisnan avatar sbywater avatar seeman1978 avatar teeed avatar thirus avatar tirkarthi avatar victorjabur avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

suds-py3's Issues

Some __repr__ methods are returning bytes, not strings

Was just kicking around in a client.Client, and the following:

>>> cc.sd[0].types
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: __repr__ returned non-string (type bytes)
>> cc.sd[0].ports
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: __repr__ returned non-string (type bytes)

Having seen the nightmarish state mainline suds is in, I'm impressed you even got this working in the first place :)

Use of setLocation causes later AttributeError: 'str' object has no attribute 'decode'

In wsdl.py when using the method Service.setLocation() to override a wrong location in the wsdl it stores the raw string. (line 860: m.location = url)

However the method SoapClient.location in client.py uses self.method.location.decode('utf-8')
This is compatible with the Port.init which sets the self.location with .encode('utf-8')

So when trying to use the service after using setLocation() the string fails to decode with the error in the title.

I believe the correct fix would be to change Service.setLocation() in wsdl.py at line 860 to use m.location = url.encode('utf-8').

Cheers
James.

Datetime Object formatting default

I get the following problem, using the suds-py3 package:

  • reading a datetime from a webservice using suds
    • the webservice sends an xml containing the datetime in isoformat (smth. like 2021-07-27T11:40:12.823Z)
  • the generated sudsobject saves this as a python datetime.datetime
  • if I then try to send this object (without changing it) to the same webservice it is sent in a different timeformat, like this 2021-07-27 11:40:12.823000+00:00 which the service does not accept

I was able to work around this, by going over every possible datetime in the subsobject and replacing it with the .isoformat() of the datetime, but that seems a little hacky to me.

Is there a better, or intended way to do this with suds?

I also posted this question an stack overflow: https://stackoverflow.com/questions/68556579/datetime-format-in-suds-py3

suds.sax.date missing lots of stuff

In python 2.x the following method is available

suds.sax.date.UTC

.. but not in the python 3.x version.

In python 2.x., dir(suds.sax.date) gives

['BuildError', 'Date', 'DateTime', 'Filter', 'MethodNotFound', 'Namespace', 'PortNotFound', 'Repr', 'ServiceNotFound', 'SoapHeadersNotPermitted', 'Time', 'Timezone', 'TypeNotFound', 'UTC', 'WebFault', '__builtins__', '__doc__', '__file__', '__name__', '__package__', 'cache', 'dt', 'getLogger', 'isqref', 'log', 'metrics', 'null', 'objid', 'os', 'plugin', 'properties', 'qualify', 're', 'reader', 'sax', 'servicedefinition', 'splitPrefix', 'store', 'sudsobject', 'sys', 'time', 'tostr', 'transport', 'xsd']

but in python3:
['Date', 'DateTime', 'FixedOffsetTimezone', 'LocalTimezone', 'PATTERN_DATE', 'PATTERN_DATETIME', 'PATTERN_TIME', 'RE_DATE', 'RE_DATETIME', 'RE_TIME', 'SNIPPET_DATE', 'SNIPPET_TIME', 'SNIPPET_ZONE', 'Time', 'UtcTimezone', '__all__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'date_from_match', 'datetime', 're', 'time', 'time_from_match', 'tzinfo_from_match', 'unicode']

The reason I need suds.sax.date.UTC is, that I have another python code using it and I want to migrate to python3

Regards,

Sampsa

Please publish update to PYPI

I recently pulled from PYPI and despite the version number matching there were compile issues, specifically in the xsd/sxbuiltin.py file around returning a "long" type. I can see this has been updated on the git repo, but PYPI isn't up to date.
Thanks

Cannot create more than 2 Clients with the same wsdl

I cannot create more than 2 Clients because it will not load the xsd because it thinks that it is already imported

/suds/xsd/schema.py

diff between 1.2 and 1.3.1

version 1.2
def open_imports(self, options):
"""
Instruct all contained L{sxbasic.Import} children to import
the schema's which they reference. The contents of the
imported schema are I{merged} in.
@param options: An options dictionary.
@type options: L{options.Options}
"""
for imp in self.imports:
imported = imp.open(options)
if imported is None:
continue
imported.open_imports(options)
log.debug('imported:\n%s', imported)
self.merge(imported)

version 1.3.1
__already_imported = {}

def open_imports(self, options):
"""
Instruct all contained L{sxbasic.Import} children to import
the schema's which they reference. The contents of the
imported schema are I{merged} in.
@param options: An options dictionary.
@type options: L{options.Options}
"""
for imp in self.imports:
if imp.location:
self.__already_imported.setdefault(imp.location, 0)
if self.__already_imported[imp.location] > 1:
continue
self.__already_imported[imp.location] += 1

        imported = imp.open(options)
        if imported is None:
            continue
        imported.open_imports(options)
        log.debug('imported:\n%s', imported)
        self.merge(imported)

-bash-4.1$ python test_suds.py

0x7ff21f982390 (Client 1 address)
0x7ff2203ab448 (self.__already_imported)
0
0x7ff21f8f4a90 (Client 2 address)
0x7ff2203ab448 (self.__already_imported)
1
0x7ff21f7dd160 (Client 3 address)
0x7ff2203ab448 (self.__already_imported)
2

Traceback (most recent call last):
File "test_suds.py", line 7, in
client3 = Client(wsdl)
File "/opt/python/lib/python3.5/site-packages/suds/client.py", line 111, in init
self.wsdl = reader.open(url)
File "/opt/python/lib/python3.5/site-packages/suds/reader.py", line 152, in open
d = self.fn(url, self.options)
File "/opt/python/lib/python3.5/site-packages/suds/wsdl.py", line 159, in init
self.set_wrapped()
File "/opt/python/lib/python3.5/site-packages/suds/wsdl.py", line 264, in set_wrapped
raise TypeNotFound(query.ref)
suds.TypeNotFound: Type not found: '(getState, http://blah.blah/, )'

WindowsHttpAuthenticated, suds.transport.TransportError: HTTP Error 401: Unauthorized

I am having the same issue. Below is my code and logs

code:

from suds.client import Client
from suds.transport.https import WindowsHttpAuthenticated
ntlm = WindowsHttpAuthenticated(username="domain\\"+username,password=password)
client = Client(url,transport=ntlm)

error logs:

HTTP Error 401: Unauthorized
Traceback (most recent call last):
  File "c:\Python3\lib\site-packages\suds\transport\http.py", line 63, in open
    return self.u2open(u2request)
  File "c:\Python3\lib\site-packages\suds\transport\http.py", line 119, in u2open
    return url.open(u2request, timeout=tm)
  File "c:\Python3\lib\urllib\request.py", line 532, in open
    response = meth(req, response)
  File "c:\Python3\lib\urllib\request.py", line 642, in http_response
    'http', request, response, code, msg, hdrs)
  File "c:\Python3\lib\urllib\request.py", line 570, in error
    return self._call_chain(*args)
  File "c:\Python3\lib\urllib\request.py", line 504, in _call_chain
    result = func(*args)
  File "c:\Python3\lib\urllib\request.py", line 650, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 401: Unauthorized

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\Development\github\fdoc-buildscripts\pythonLibs\Symbols.py", line 51, in uploadCer
    client = Client(self.cerServer["url"],transport=ntlm)
  File "c:\Python3\lib\site-packages\suds\client.py", line 110, in __init__
    self.wsdl = reader.open(url)
  File "c:\Python3\lib\site-packages\suds\reader.py", line 151, in open
    d = self.fn(url, self.options)
  File "c:\Python3\lib\site-packages\suds\wsdl.py", line 135, in __init__
    d = reader.open(url)
  File "c:\Python3\lib\site-packages\suds\reader.py", line 78, in open
    d = self.download(url)
  File "c:\Python3\lib\site-packages\suds\reader.py", line 94, in download
    fp = self.options.transport.open(Request(url))
  File "c:\Python3\lib\site-packages\suds\transport\https.py", line 61, in open
    return HttpTransport.open(self, request)
  File "c:\Python3\lib\site-packages\suds\transport\http.py", line 65, in open
    raise TransportError(str(e), e.code, e.fp)
suds.transport.TransportError: HTTP Error 401: Unauthorized

Note:

Originally posted by @Dineshk77 in #36 (comment)

Why not use FIPS-compliant algorithm instead of MD5

Currently, the library uses MD5 algorithm to generate the nonce:
Filename: suds/wsse.py

def setnonce(self, text=None):
        """
        Set I{nonce} which is arbitraty set of bytes to prevent
        reply attacks.
        @param text: The nonce text value.
            Generated when I{None}.
        @type text: str
        """
        if text is None:
            s = []
            s.append(self.username)
            s.append(self.password)
            s.append(Token.sysdate())
            m = md5()
            m.update(':'.join(s).encode("utf-8"))
            self.nonce = m.hexdigest()
        else:
            self.nonce = text

Also, the library uses MD5 algorithm to generate the "mangled id" from url and document attemped to be retrived:
Filename: suds/reader.py

def mangle(self, name, x):
        """
        Mangle the name by hashing the I{name} and appending I{x}.
        @return: the mangled name.
        """
        h = hashlib.md5(name.encode('utf8')).hexdigest()
        return '%s-%s' % (h, x)

As the library uses the MD5 algorithm which is not FIPS-compliant, the Apps using the library gives the below error when running on FIPS enabled platforms:
fips_md.c(146): OpenSSL internal error, assertion failed: Digest update previous FIPS forbidden algorithm error ignoredย 

Can we update the library to use FIPS-compliant algorithm for the above purposes?

Deprecation warning due to invalid escape sequences in Python 3.7

Deprecation warning are generated over invalid escape sequences. This can be fixed by using raw strings or escaping the literals again.

find . -iname '*.py'  | xargs -P 4 -I{} python -Walways -m py_compile {}

./suds/wsdl.py:621: DeprecationWarning: invalid escape sequence \s
  body.parts = re.split('[\s,]', parts)
./suds/resolver.py:89: DeprecationWarning: invalid escape sequence \%
  self.splitp = re.compile('({.+})*[^\%s]+' % ps[0])

Client overrides method-specific location URL

In https://github.com/cackharot/suds-py3/blob/master/suds/client.py#L107 the URL from which WSDL was loaded is stored as location in options:

self.options.location = url

When invoking requests, this URL is then loaded up and preferred over method-specific URL specified in SOAP response in https://github.com/cackharot/suds-py3/blob/master/suds/client.py#L634:

location = self.location()

I load wsdl from https://somehost/somepath?wsdl but SOAP requests must be sent without the query parameter so to https://somehost/somepath. The code in https://github.com/cackharot/suds-py3/blob/master/suds/client.py#L107 causes the URL with ?wsdl getting sent instead.

To workaround that, I cleared the location after initializing Suds Client:

client = Client(...)
client.options.location = None

This allows self.location() lookup to return self.method.location instead.

However, on python 3 urllib.request operations (that suds uses to load up WSDL) seem to return bytes not str. This leads to self.method.location being bytes and not str. However, the calls itself (to actually perform SOAP operation) in urllib.request expect URL to be str not bytes. So my calls fail.

My question here would be: why is https://github.com/cackharot/suds-py3/blob/master/suds/client.py#L107 line added in suds-py3 (it doesn't exist in original suds library). Is it intentional or accident, and what might the reasoning be?

I assume the line shouldn't be there, and code should instead decode() the URL that is sent to urllib.request.urlopen (or urllib.request.OpenerDirector.open()) instead?

(Disclaimer: I am not SOAP expert by any mean, merely trying to migrate an old project from py2->py3.)

cannot process href in build_catalog in multiref.py

20200925_173508
The soap response message likes the snapshot. Suds cannot process href.

source code
def build_catalog(self, body):
for child in body.children:
if self.soaproot(child):
self.nodes.append(child)
id = child.get('id')
if id is None:
continue
key = '#%s' % id
self.catalog[key] = child
I think recurse invoke build_catalog can resolve this problem.
I modified.
def build_catalog(self, body):
for child in body.children:
if self.soaproot(child):
self.nodes.append(child)
id = child.get('id')
if id is None:
self.build_catalog(child)
else
key = '#%s' % id
self.catalog[key] = child

Unable to set custom cache location

Hi,
There is a problem when creating a new Client on a multiuser machine. In the Client constructor, we have the line options.cache = ObjectCache(days=1). This triggers the search for the file /tmp/suds/versions (which is not present in the path). Then because the file is missing, it will call the clear() function which will try to remove all existing files in the path. However, as this is a multiuser machine, another user ran first the script and created a cache file in the same path. And since he is the owner of the cache file, i'm getting the following error:

Traceback (most recent call last):
  File "suds/cache.py", line 269, in checkversion
    f = self.open(path)
  File "/suds/cache.py", line 263, in open
    return open(fn, *args)
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/suds/version'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "tests-suds.py", line 1052, in <module>
    _test()
  File "tests-suds.py", line 994, in _test
    sconn = TestConnection(qa=True, debug=True)
  File "tests-suds.py", line 132, in __init__
    self.wsdlclient = self._client_setup()
  File "tests-suds.py", line 151, in _client_setup
    c = Client(wsdlurl, **sslargs)
  File "suds/client.py", line 108, in __init__
    options.cache = ObjectCache(days=1)
  File "suds/cache.py", line 143, in __init__
    self.checkversion()
  File "suds/cache.py", line 275, in checkversion
    self.clear()
  File "suds/cache.py", line 249, in clear
    os.remove(os.path.join(self.location, fn))
PermissionError: [Errno 13] Permission denied: '/tmp/suds/suds-695145561.pw'

So, I tried to give the Client a new ObjectCache object, which I initialized with a different path like this:
cacheobj = ObjectCache(location='/tmp/suds-%s/' % username) c = Client(wsdlurl, cache=cacheobj)

But then I got the error:

Traceback (most recent call last):
  File "suds/cache.py", line 269, in checkversion
    f = self.open(path)
  File "suds/cache.py", line 263, in open
    return open(fn, *args)
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/suds-abenisha/version'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "tests-suds.py", line 1052, in <module>
    _test()
  File "tests-suds.py", line 994, in _test
    sconn = TestConnection(qa=True, debug=True)
  File "tests-suds.py", line 132, in __init__
    self.wsdlclient = self._client_setup()
  File "tests-suds.py", line 149, in _client_setup
    cacheobj = ObjectCache(location='/tmp/suds-%s/' % username)
  File "suds/cache.py", line 143, in __init__
    self.checkversion()
  File "suds/cache.py", line 275, in checkversion
    self.clear()
  File "suds/cache.py", line 244, in clear
    for fn in os.listdir(self.location):
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/suds-abenisha/'

Also, I think the latter won't work anyway because Client initialize a new ObjectCache object no matter what I give it.

What is the reason for having this self.checkversion() function?

Python3.8 DocumentReader bug

in the dowloader of the suds reader there is an issue where the documentReader opens a new url that is not cached. It tries to download the url data, however the open function of the documentStore resolves that url and returns content instead of the file-handle. This is a bytestream. this bytestream has no read function. therefore when fp is not empty it generates an exception.

current code

    def download(self, url):
        store = DocumentStore()
        fp = store.open(url)
        if fp is None:
            fp = self.options.transport.open(Request(url))
        content = fp.read()
        fp.close()
        ctx = self.plugins.document.loaded(url=url, document=content)
        content = ctx.document
        sax = Parser()
        return sax.parse(string=content)

working solution

    def download(self, url):
        store = DocumentStore()
        fp = store.open(url)
        if fp is None:
            fp = self.options.transport.open(Request(url))
            content = fp.read()
            fp.close()
        else:
            content = fp
        ctx = self.plugins.document.loaded(url=url, document=content)
        content = ctx.document
        sax = Parser()
        return sax.parse(string=content)

The store.open() function can either return the bytestream (can be empty) or generate an exception. it has no option to return a file-handle. I am by far no expert on suds, can anyone verify this problem and help with a proper solution?

Exception: No ports defined: Service - wdsl without binding, how to handle?

hi
running this code


from suds.client import Client as SudsClient
client = SudsClient("https://testwslegalmobile.solutiondocondemand.com/Service.svc?singlewsdl")
answer = client.service.Login(
        wspassword="xxx",
        loginParams={
            "username":"username",
            "password":"password"
        }
    )


i obtain

Exception: No ports defined: Service

ah a print(client) give me


Suds ( https://github.com/cackharot/suds-py3 )  version: 1.4.1.0 IN  build: 20200421

Service ( Service ) tns="http://tempuri.org/"
   Prefixes (3)
      ns0 = "http://schemas.datacontract.org/2004/07/WSLegalMobile.Models"
      ns1 = "http://schemas.datacontract.org/2004/07/WSLegalMobile.ModelsRequest"
      ns2 = "http://schemas.microsoft.com/2003/10/Serialization/"
   Ports (0):
--------------------------------------------------------------------------------


same result using soapui windows client,i think the problem is related with the wsdl, there is any binding in the wsdl code, how to handle this situation?

thanks

managing security with Handlerchain

I have to retrieve data from a webservice that requires a Handlerchain aside from User and Password

The security description, suitable for java, is the following

In the handler class, a SOAPHeader must be built up with an element ยซUsernameTokenยป. In that element, two elements "Username" and "Password" are added, which contain the client's username and password, respectively. The handler class must be declared in a SOAP Handler XML file, and the service class annotated with @Handlerchain. The annotation must contain a file attribute that points to handler-chain.xml.

Is there a way to handle it in SUDS?

my system:

suds-py3==1.4.4.1
Win 10
Python 3.8.5

suds-py3: Headers passed into suds.client.Client() are not used in WSDL and XSD requests

Hi, friends!
Fix the problem from the title please. See this problem for suds

Here is my code for example:

wsdl = 'http://10.77.42.63:8081/ua/wsdl/UnifiedApi.wsdl'
url = 'http://10.77.42.63:8081/ua/soap'
client = Client(wsdl,location=url,username='usr',password='pswd',headers={"foo": "bar"})

Request parameters in ...\Python\Python38\Lib\site-packages\suds\transport\http.py def open(self, request):

URL:http://10.77.42.63:8081/ua/wsdl/UnifiedApi.wsdl
HEADERS: {'Authorization': 'Basic dXNyOnBzd2Q='}
MESSAGE:
None

So header {"foo": "bar"} was lost.
For my exe-program I solved the problem by forcibly adding header in the same http.py: headers ['foo'] = 'bar'

Thanks!

AttributeError: 'NoneType' object has no attribute 'promotePrefixes'

When I send a soap11 request, I throw the above error. Here is my request code:

#encoding:utf-8

from suds.client import Client

url = "http://webservice.cingta.com/Calculator/soap11/description/"
headers = {
    "Content-Type": 'application/soap+xml; charset="UTF-8"'
}
client2 = Client(url, headers=headers, faults=False, timeout=15)

result = client2.service.extract_remote_addr()
print(result)

importing `suds.Object` class in mx.literal results in `TypeNotFound` later

Hi, Thank you for maintaining this very useful library! I'm encountering the following situation and have discovered a workaround. However, I believe that either I am just too ignorant of WSDL or that there may be an unwanted condition in the code. I'm simultaneously curious how it could be the case that this is an issue since it's been present since November 2015.

The situation

  1. I am working with a SOAP service publishing this WSDL.
  2. I am creating a Subscriber object (WSDL line 2064) using the suds.client.Client.factory.create() instance method.
  3. The factory returns a suds.sudsobjects.Object instance
  4. I then pass this object through to a Service method call
  5. Later on, when trying to build the bodycontent, the binding marshaller (a mx.literal.Literal in this case) attempts to "start" the object.
    1. The start method checks if the content value is a suds.Object instance.
    2. However, it is not. It is the suds.sudsobjects.Object from step 3.
    3. The result of this is that the GraphResolver is not appropriately configured with the known type for the Subscriber.
  6. Future attempts to resolve elements declared in the Subscriber (but not the base APIObject type) will fail with TypeNotFound.

The patch

To get around this, I added the following code to my initialization code. I'm unfamiliar with the code and I have no idea what other issues this could cause. I searched through the suds codebase and see very few references to Object, and this one in literal.py appears to be the only one to suds.Object.

from suds.sudsobject import Object as ActualObject
import suds.mx.literal
suds.mx.literal.Object = ActualObject

What Next?

If this is not an issue, but my own ignorance, then that's great! I'm sorry for taking up your time! If not, I hope this issue report was helpful.

HTTP error 415: content type error

Hi, I get the following errors when calling a locally hosted WCF service. Hope you can help. When I use Postman to call the service I have to add content-type application/soap+xml to the headers, so I'm guessing that's the problem. How do I get suds to use that header?

Traceback (most recent call last):
File "C:\Users...\AppData\Local\Programs\Python\Python38-32\lib\site-packages\suds\transport\http.py", line 78, in send
fp = self.u2open(u2request)
File "C:\Users...\AppData\Local\Programs\Python\Python38-32\lib\site-packages\suds\transport\http.py", line 119, in u2open
return url.open(u2request, timeout=tm)
File "C:\Users...\AppData\Local\Programs\Python\Python38-32\lib\urllib\request.py", line 531, in open
response = meth(req, response)
File "C:\Users...\AppData\Local\Programs\Python\Python38-32\lib\urllib\request.py", line 640, in http_response
response = self.parent.error(
File "C:\Users...\AppData\Local\Programs\Python\Python38-32\lib\urllib\request.py", line 569, in error
return self._call_chain(*args)
File "C:\Users...\AppData\Local\Programs\Python\Python38-32\lib\urllib\request.py", line 502, in _call_chain
result = func(*args)
File "C:\Users...\AppData\Local\Programs\Python\Python38-32\lib\urllib\request.py", line 649, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 415: Cannot process the message because the content type 'text/xml; charset=utf-8' was not the expected type 'application/soap+xml; charset=utf-8'.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users...\AppData\Local\Programs\Python\Python38-32\lib\site-packages\suds\client.py", line 652, in send
reply = transport.send(request)
File "C:\Users...\AppData\Local\Programs\Python\Python38-32\lib\site-packages\suds\transport\http.py", line 178, in send
return HttpTransport.send(self, request)
File "C:\Users...\AppData\Local\Programs\Python\Python38-32\lib\site-packages\suds\transport\http.py", line 86, in send
raise TransportError(e.msg, e.code, e.fp)
suds.transport.TransportError: Cannot process the message because the content type 'text/xml; charset=utf-8' was not the expected type 'application/soap+xml; charset=utf-8'.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users...\OneDrive - Packnology, Inc\Development\Projects\Packwise\AWS Greengrass\test.py", line 6, in
result = client.service.GetMachineRodsPM()
File "C:\Users...\AppData\Local\Programs\Python\Python38-32\lib\site-packages\suds\client.py", line 559, in call
return client.invoke(args, kwargs)
File "C:\Users...\AppData\Local\Programs\Python\Python38-32\lib\site-packages\suds\client.py", line 618, in invoke
result = self.send(soapenv)
File "C:\Users...\AppData\Local\Programs\Python\Python38-32\lib\site-packages\suds\client.py", line 664, in send
result = self.failed(binding, e)
File "C:\Users...\AppData\Local\Programs\Python\Python38-32\lib\site-packages\suds\client.py", line 726, in failed
raise Exception((status, reason))
Exception: (415, "Cannot process the message because the content type 'text/xml; charset=utf-8' was not the expected type 'application/soap+xml; charset=utf-8'.")

Connection Pooling support?

I have a need to use keep alive and connection pooling. So when I open new calls to a soap service, the requests library in use attempts to reuse already existing connections.

I have looked over the code. It's a little beyond me. So I am asking here is this feature is actually present. The manual does not mention it, apart from caching the wsdl's..
From my inspection, it looks like a non connection-pool library is used and that does not implement connection pooling.

After looking though the code more, it looks like implementing a connection-pool solution would be quite involved, likely beyond me.
Could I have a comment form a key developer on this topic and the likely best path to implement this feature?

My initial reaction is to move it to urllib3 as it does support connection pooling.

How to pass XML string to SOAP call using Suds for Python3

Using suds-py3.

When loading the following WSDL:

https://clientdev.inteflow.com.au/inteport/DecisionGateway.asmx?WSDL

I get:

(DecisionWebGatewaySoap12)
         Methods (38):
            [...]
            ExecuteXMLRequest(_sRequestXML _sRequestXML, )

The types list contains all this, but nothing called _sRequestXML (which should be treated as a string, I reckon):

   Types (141):
      AccessGroup
      Address
      ns3:AddressInformation
      Applicant
      ns2:Array
      ArrayOfAccessGroup
      ArrayOfApplicant
      ns3:ArrayOfAttachment
      ArrayOfCriteria
      ns3:ArrayOfCustomField
      ns3:ArrayOfDocumentPDF
      ns3:ArrayOfDocumentStatus
      ns3:ArrayOfFormDataXfdfField
      ArrayOfMerchantCommission
      ArrayOfMerchantOperator
      ArrayOfMerchantParameter
      ArrayOfMerchantProductGroup
      ArrayOfMerchantProductv2
      ArrayOfOperatorAccessGroup
      ArrayOfOperatorMerchant
      ArrayOfOperatorProductGroup
      ns3:ArrayOfRecipientStatus
      ArrayOfString
      ns3:ArrayOfString
      ns3:ArrayOfTabStatus
      ArrayOfURL
      ns3:Attachment
      Authentication
      ns3:AuthenticationStatus
      BasicInsuranceProduct
      BasicMerchant
      BasicMerchantOperator
      BasicOperator
      CompanyDetails
      Contact
      CreateInsuranceProductResponseData
      CreateMerchantResponseData
      Criteria
      ns3:CustomField
      ns3:CustomFieldType
      ns3:CustomTabType
      ns3:DOBInformation
      DateFormat
      DefaultValue
      ns3:DeliveryMethod
      ns3:DocuSignEnvelopeInformation
      ns3:DocumentPDF
      ns3:DocumentStatus
      ns3:DocumentType
      ns2:ENTITIES
      ns2:ENTITY
      ns3:EnvelopeStatus
      ns3:EnvelopeStatusCode
      ns3:EventResult
      ns3:EventStatusCode
      ExecuteResponse
      FinanceRequest
      Financial
      ns3:FormData
      ns3:FormDataXfdf
      ns3:FormDataXfdfField
      ns2:ID
      ns3:IDCheckInformation
      ns2:IDREF
      ns2:IDREFS
      IndividualDetails
      LimitedLoginResponseData
      Merchant
      MerchantCommission
      MerchantDetails
      MerchantOperator
      MerchantParameter
      MerchantProductGroup
      MerchantProductv2
      ns2:NCName
      ns2:NMTOKEN
      ns2:NMTOKENS
      ns2:NOTATION
      ns2:Name
      Operator
      OperatorAccessGroup
      OperatorDetails
      OperatorFlag
      OperatorMerchant
      OperatorProductGroup
      Options
      Payload
      PayloadSubmit
      ns2:QName
      ns3:RecipientStatus
      ns3:RecipientStatusCode
      ns3:RecipientStatusEsignAgreementInformation
      ns3:RecipientTypeCode
      RequestData
      RequestResponseData
      ResponseData
      ns3:SSN4Information
      SecondaryLogin
      ns3:SigningLocationCode
      StatusCheck
      ns1:StringArray
      ns2:Struct
      ns3:TabStatus
      ns3:TabTypeCode
      URL
      ns3:VaultingDetails
      ns2:anyURI
      ns2:arrayCoordinate
      ns2:base64
      ns2:base64Binary
      ns2:boolean
      ns2:byte
      ns2:date
      ns2:dateTime
      ns2:decimal
      ns2:double
      ns2:duration
      ns2:float
      ns2:gDay
      ns2:gMonth
      ns2:gMonthDay
      ns2:gYear
      ns2:gYearMonth
      ns2:hexBinary
      ns2:int
      ns2:integer
      ns2:language
      ns2:long
      ns2:negativeInteger
      ns2:nonNegativeInteger
      ns2:nonPositiveInteger
      ns2:normalizedString
      ns2:positiveInteger
      ns2:short
      ns2:string
      ns2:time
      ns2:token
      ns2:unsignedByte
      ns2:unsignedInt
      ns2:unsignedLong
      ns2:unsignedShort

Then, when I do:

v = client.service.ExecuteXMLRequest("<inteflow><something>value</something></inteflow>")

The SOAP string I passed to ExecuteXMLRequest is not set as the value of ns1:ExecuteXMLRequest. Instead, the element is empty:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://decisionintellect.com/inteport/">
   <SOAP-ENV:Header/>
   <ns0:Body>
      <ns1:ExecuteXMLRequest/>
   </ns0:Body>
</SOAP-ENV:Envelope>

I need Suds to produce an envelope like this instead:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://decisionintellect.com/inteport/">
   <SOAP-ENV:Header/>
   <ns0:Body>
      <ns1:ExecuteXMLRequest>
            <ns1:_sRequestXML>
                  <inteflow><something>value</something></inteflow>
            </ns1:_sRequestXML>
      </ns1:ExecuteXMLRequest>
   </ns0:Body>
</SOAP-ENV:Envelope>

Is there a problem with the WSDL?
Should I pass the parameter in some other way?

Full example:

import ssl

from suds.client import Client

if hasattr(ssl, '_create_unverified_context'):
    ssl._create_default_https_context = ssl._create_unverified_context

url = 'https://clientdev.inteflow.com.au/inteport/DecisionGateway.asmx?WSDL'
client = Client(url)
client.set_options(port='DecisionWebGatewaySoap12')

print(client)

v = client.service.ExecuteXMLRequest("<inteflow><something>value</something></inteflow>")
print(client.last_sent())

print(v)

Inidcate SOAP version?

There is any way to indicate the SOAP version, in better words, How can indicate what version of XML are going to be read?

zeep

Hi! I'd been maintaining a suds fork for a few years (which fixed different bugs compared to this fork, but also had its own bugs too).

A few months back, I came across zeep. It's a true successor to suds, and the authors did a really good job on python3 support, and lots of bug-fixing and enhancements.

I ended up dropping my suds fork in favour of this since the quality and reliability is a lot higher, and have started reaching out to other suds maintainers and pointing them in that direction. I'd like to gradually try and help the "we have 10 forks each with different fixes" situation, and have a single standard tool used by the entire ecosystem.

I know that dumping one's own work is usually quite hard, but I'm wondering how you'd feel about pointing users to zeep in future, so that new and existing project can gradually move over.

I really hope you don't take this the wrong way, I'm aware that it's a controversial thing to propose.

queryObject method fails with exception "date data has invalid format "2010-11-08T00:00:00"

In the process of transitioning from python 2.7 to python 3.7 and recently switched to suds-py3. I noticed that when testing code that is known to work in python 2.7, I am getting exception error on 'client.service.queryObject()' with error message "date data has invalid format "2010-11-08T00:00:00". Any ideas how to update the date handling here?

client = Client(url)
client.options.location = None
client.service.authenticate(userid, pstr)

employees = client.service.queryObject('Employee', '')

HEAD is broken

HEAD is broken. There are several broken imports, which are triggered by merely running python setup.py build.

HEAD~1 is ok. I'd recommend a reversion.

wrong namespace prefix in SOAP request

I had the same issue as refrenced in this stackoverflow. Alex Miro explained the issue and provided a work around on suds. I believe it will also work on suds-py3. I tried the same solution on my program and it worked perfectly. Something I had been struggling with for a while.

quote:

I use python/suds to implement a client and I get wrong namespace prefixes in the sent SOAP header for a spefic type of parameters defined by element ref= in the wsdl.

The .wsdl is referencing a data types .xsd file, see below. The issue is with the function GetRecordAttributes and its first argument of type gbt:recordReferences.

File: browse2.wsdl

<xsd:schema targetNamespace="http://www.grantadesign.com/10/10/Browse" xmlns="http://www.grantadesign.com/10/10/Browse" xmlns:gbt="http://www.grantadesign.com/10/10/GrantaBaseTypes" elementFormDefault="qualified" attributeFormDefault="qualified"> <xsd:import schemaLocation="grantabasetypes2.xsd" namespace="http://www.grantadesign.com/10/10/GrantaBaseTypes"/> <xsd:element name="GetRecordAttributes"> <xsd:complexType> <xsd:sequence> <xsd:element ref="gbt:recordReferences"> </xsd:element>

Referenced File : grantabasetypes2.xsd

<element name="recordReferences"> <complexType> <sequence> <element name="record" minOccurs="0" maxOccurs="unbounded" type="gbt:MIRecordReference"/> </sequence> </complexType> </element>

SOAP Request sent by suds:

<SOAP-ENV:Envelope xmlns:ns0="http://www.grantadesign.com/10/10/GrantaBaseTypes" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns2="http://www.grantadesign.com/10/10/Browse" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> <SOAP-ENV:Header/> <ns1:Body> <ns2:GetRecordAttributes> <ns2:recordReferences> <ns0:record> </ns0:record> </ns2:recordReferences> </ns2:GetRecordAttributes> </ns1:Body> </SOAP-ENV:Envelope>

Problem : ns2:recordReferences has wrong prefix, should be ns0:recordReferences since it belongs to the namespace ...GrantaBaseTypes defined in the .xsd.

This happens for all arguments defined by ref= in the wsdl. How can this be automatically fixed?

Note: I checked that the "good" prefix is accepted by the service by manually sending the xml SOAP request via curl.

UPDATE

I meddled with SUDS source code and the following empirical fix forces all elements with ref= attribute to assume the ref-ed namespace (previously, they take on the schema root namespace or whatever tns is):

File: /suds/xsd/sxbase.py

class SchemaObject(object):
....
    def namespace(self, prefix=None):
         ns = self.schema.tns

         #FIX BEGIN
         if self.ref and self.ref in self.schema.elements.keys():
            ns = self.ref
         #FIX END

end quote

401 error while connecting to EWS

I am connecting to EWS, but I get 401 error
urllib.error.HTTPError: HTTP Error 401: Anonymous Request Disallowed

Below is the code
ssl._create_default_https_context = ssl._create_unverified_context
logging.basicConfig(level=logging.INFO)
logging.getLogger('suds.client').setLevel(logging.DEBUG)
url = "https://xxx.xxx.xxx.com/EWS/Services.wsdl"
username = 'DOMAIN\USER'
password = 'PASS'
ntlm = WindowsHttpAuthenticated(username=username,password=password)
client = Client(url=url,transport=ntlm)

Client serialization is not readable in plain text

  • Code:
from suds.client import Client
client = Client('http://www.webservicex.com/globalweather.asmx?WSDL')
print(client)
  • Expected output (as in suds for Python2): properly formated tree in plain text
Service ( GlobalWeather ) tns="http://www.webserviceX.NET"
   Prefixes (0)
   Ports (2):
      (GlobalWeatherSoap)
         Methods (2):
            GetCitiesByCountry(xs:string CountryName)
            GetWeather(xs:string CityName, xs:string CountryName)
         Types (0):
      (GlobalWeatherSoap12)
         Methods (2):
            GetCitiesByCountry(xs:string CountryName)
            GetWeather(xs:string CityName, xs:string CountryName)
         Types (0):
  • Actual output in suds-py3: HTML spaghetty
Service ( GlobalWeather ) tns="http://www.webserviceX.NET"<p>   Prefixes (0)<p>   Ports (2):<p>      (GlobalWeatherSoap)<p>         Methods (2):<p>            GetCitiesByCountry(xs:string CountryName, )<p>            GetWeather(xs:string CityName, xs:string CountryName, )<p>         Types (0):<p>      (GlobalWeatherSoap12)<p>         Methods (2):<p>            GetCitiesByCountry(xs:string CountryName, )<p>            GetWeather(xs:string CityName, xs:string CountryName, )<p>         Types (0):<hr/>

The problem seems to be that ServiceDefinition.description() ignores the html parameter. I worked around the issue it in my client by patching the library with the method from the Python2 version:

from suds.servicedefinition import ServiceDefinition
def suds_description_override(self):
    """
    Get a textual description of the service for which this object represents.
    @return: A textual description.
    @rtype: str
    """
    s = []
    indent = (lambda n: '\n%*s' % (n * 3, ' '))
    s.append('Service ( %s ) tns="%s"' % (self.service.name, self.wsdl.tns[1]))
    s.append(indent(1))
    s.append('Prefixes (%d)' % len(self.prefixes))
    for p in self.prefixes:
        s.append(indent(2))
        s.append('%s = "%s"' % p)
    s.append(indent(1))
    s.append('Ports (%d):' % len(self.ports))
    for p in self.ports:
        s.append(indent(2))
        s.append('(%s)' % p[0].name)
        s.append(indent(3))
        s.append('Methods (%d):' % len(p[1]))
        for m in p[1]:
            sig = []
            s.append(indent(4))
            sig.append(m[0])
            sig.append('(')
            sig.append(', '.join("%s %s" % (self.xlate(p[1]), p[0]) for p
                                 in m[1]))
            sig.append(')')
            try:
                s.append(''.join(sig))
            except Exception:
                pass
        s.append(indent(3))
        s.append('Types (%d):' % len(self.types))
        for t in self.types:
            s.append(indent(4))
            s.append(self.xlate(t[0]))
    s.append('\n\n')
    return ''.join(s)
ServiceDefinition.description = suds_description_override

how to use import doctor to load schema from a local file

actually i use


imp = Import('http://www.w3.org/2001/XMLSchema', location='http://www.w3.org/2001/XMLSchema.xsd')
imp.filter.add('http://tempuri.org/')
suds_client = SudsClient("https://mywebservices?wsdl", doctor=ImportDoctor(imp))

but this endpoint http://www.w3.org/2001/XMLSchema.xsd sometime cannot be reached from my network.

i tried to download locally and load with these syntaxs,

imp = Import('http://www.w3.org/2001/XMLSchema', location='XMLSchema.xsd')
imp = Import('http://www.w3.org/2001/XMLSchema', location='file://XMLSchema.xsd')

but no one works.

the schema can be loaded from a file?

thanks.

RecursionError in suds.sax.attribute

RecursionError at /...
maximum recursion depth exceeded while calling a Python object
/home/.../virtualenv/lib/python3.5/site-packages/suds/client.py in __call__
                            return client.invoke(args, kwargs)

/home/.../virtualenv/lib/python3.5/site-packages/suds/client.py in invoke
                        result = self.send(soapenv)

/home/.../virtualenv/lib/python3.5/site-packages/suds/client.py in send
                                soapenv = soapenv.plain()

/home/.../virtualenv/lib/python3.5/site-packages/suds/sax/document.py in plain
                        s.append(self.root().plain())

/home/.../virtualenv/lib/python3.5/site-packages/suds/sax/element.py in plain
                        for a in [unicode(a) for a in self.attributes]:

/home/.../virtualenv/lib/python3.5/site-packages/suds/sax/element.py in <listcomp>
                        for a in [unicode(a) for a in self.attributes]:

/home/.../virtualenv/lib/python3.5/site-packages/suds/sax/attribute.py in __str__
173.                        return unicode(self).encode('utf-8')

(last file/line repeating many times... sorry, output taken from Django debug screen)

Unicode string handling in Windows

Hello,

Thank you for publishing the package. I am migrating from suds, written for Python < 3.0. Decided to try your package and now I am having difficulties installing it in Python 3.2.

All my work is done on Windows 7.

What I noticed is that, in general, scripts containing unicode manipulations fail to compile in IDLE. As an example, files attribute.py and text.py fail.

As a workaround, I started making some changes in sax/text.py and setup.py. For instance, I replaced

joined = u''.join((self, other))

with

joined = ''.join((self, other))

and made the corresponding change in setup.py.

Then I realized that more changes will be necessary.

I understand that some modules may be written by different people - like the 2 modules above were written by Jeff Ortel probably to run on Linux. Do you plan on modifying/generalizing the package to make it work on Windows?

Best regards,
~trackvsb

Not working with NTLM Auth

This Version is not working with NTLM Auth because it uses the package python-ntlm, which is not compatible with python3.

A working fix would be replacing line 94 in file transport.https:

from ntlm import HTTPNtlmAuthHandler

with

from ntlm3 import HTTPNtlmAuthHandler

So it uses the python-ntlm3 Package, which works with python3.

I've already created a pull-request for that: #20

& is detected as special character but not escaped in some cases

& is special/reserved character for the XML so should be escaped in the all cases.
Currently suds-py3 library detects that data need to be escaped but does not escape &. It is reproducible with a following content:

  • &amp;
  • &lt;
  • &gt;
  • &quot;
  • &apos;

For example according to the XML specification string "&lt;" shall be escaped to "&amp;lt;".
Please refer to online escapers like https://www.freeformatter.com/xml-escape.html or example written in golang:

//go 1.6.2

package main  
import (
    "fmt"
    "encoding/xml"
    "bytes"
)
	
func main() { 
    var buf bytes.Buffer
    xml.Escape(&buf,[]byte("&lt;test"))
    fmt.Printf(buf.String()) // output here is &amp;lt;test
}

Please also look at this example (needsEncoding returns True):

import suds
encoder = suds.sax.Encoder()
encoder.needsEncoding('&lt;test') # output is True
encoder.encode('&lt;test') # output is '&lt;test' but should be &amp;lt;

It is limited in the sax/enc.py file:

encodings = (
        ('&(?!(amp|lt|gt|quot|apos);)', '&amp;'),
        ('<', '&lt;'),
        ('>', '&gt;'),
        ('"', '&quot;'),
        ("'", '&apos;')
    )

Rondom (mostly too long) response times when using static IP

Hi. Please consider following simple code:

from suds.client import Client

client = Client(url=WSDL_PATH, timeout=15)
client.set_options(location=TARGET_HOST)

request_data = client.factory.create('RequestName')

response = client.service.methodName(request_data)

Everything works perfect and fast when the target device (target_host) is connected to network and my pc is connected to the (same) network. But when I set a static IP on my pc and connect directly to the host device with cable (i.e. neither device nor pc have internet access but both can access each other by ip), something strange happens. Of course the script still works, but the response time is sometimes instant (as expected) and sometimes it takes 10 seconds. But most of the time it takes even more or it just fails due to timeout. There is no rule - every time it is different. Normally I would expect it to work instantly since there is no middle-device, just two devices connected directly. In facet, when I ping target host from pc (from command line) the response is always instant, so I am almost certain this is python/suds fault.

For comparison if I construct the soap request 'manually', open the socket with target host ip and then send the request I get instant response. That suggests that it is something in suds or some package it relies on.

suds.TypeNotFound: Type not found: 'Key'

with this wsdl endpoint

https://testsdc2csolution.solutiondocondemand.com/Basic/RepositoryService.svc?wsdl

i'm not able to send data to the createDocument method,

that works using soapui.

image

this is the code. i try to add a doctor adding all the namespace, but nothing changed, the problem still

suds.TypeNotFound: Type not found: 'Key'

this is the python3 code with everything updated




imp = Import('http://tempuri.org/Imports')
imp.filter.add('https://tempuri.org/')
imp.filter.add('https://schemas.microsoft.com/2003/10/Serialization/')
imp.filter.add('https://docs.oasis-open.org/ns/cmis/messaging/200908/')
imp.filter.add('https://docs.oasis-open.org/ns/cmis/core/200908/')
imp.filter.add('https://schemas.microsoft.com/2003/10/Serialization/Arrays')
imp.filter.add('https://schemas.datacontract.org/2004/07/WcfConservazione')
imp.filter.add('https://schemas.datacontract.org/2004/07/SdC_ConservazioneSDK')
imp.filter.add('https://schemas.datacontract.org/2004/07/SdC_ConservazioneSDK.SdC')
imp.filter.add('https://schemas.datacontract.org/2004/07/SdC_ConservazioneSDK.SdCInput')
doctor = ImportDoctor(imp)


client = Client("https://testsdc2csolution.solutiondocondemand.com/Basic/RepositoryService.svc?wsdl", username=CONSERVAZIONE_USERNAME, password=CONSERVAZIONE_PASSWORD, doctor=doctor)
client.set_options(wsse=security)
print(client)

c_stream = file_to_b64bytes("assets/pdv/packagePdV.zip")
c_length = len(c_stream)

proprieta1 = client.factory.create('ns7:KeyValueOfstringanyType')
print(proprieta1)
proprieta1.Key = "PdV_VerificaFirmaFiles"
proprieta1.Value = False

proprieta2 = client.factory.create('ns7:KeyValueOfstringanyType')
proprieta2.Key = "Firma_OggettiProduttore"
proprieta2.Value = False

content_stream = client.factory.create('ns0:ContentStream')
content_stream.filename = "packagePdV.zip"
content_stream.length = c_length
content_stream.stream = c_stream

risposta = client.service.createDocument(
    repositoryId=1,
    properties=[proprieta1,proprieta2],
    contentStream=content_stream
)




the data structure looks good

this is the log


C:\Users\Andrea-Fisso\AppData\Local\Programs\Python\Python37-32\python.exe C:/src/qa-lsd-webservices/qa-lsd-webservices/prova.py
C:\src\qa-lsd-webservices\qa-lsd-webservices\lib

Suds ( https://github.com/cackharot/suds-py3 )  version: 1.3.3.0 IN  build: 20170311

Service ( RepositoryService ) tns="http://tempuri.org/"
   Prefixes (9)
      ns0 = "http://docs.oasis-open.org/ns/cmis/core/200908/"
      ns1 = "http://docs.oasis-open.org/ns/cmis/messaging/200908/"
      ns2 = "http://schemas.datacontract.org/2004/07/SdC_ConservazioneSDK"
      ns3 = "http://schemas.datacontract.org/2004/07/SdC_ConservazioneSDK.SdC"
      ns4 = "http://schemas.datacontract.org/2004/07/SdC_ConservazioneSDK.SdCInput"
      ns5 = "http://schemas.datacontract.org/2004/07/WcfConservazione"
      ns6 = "http://schemas.microsoft.com/2003/10/Serialization/"
      ns7 = "http://schemas.microsoft.com/2003/10/Serialization/Arrays"
      ns8 = "http://tempuri.org/"
   Ports (1):
      (RepositoryServicePortBasic)
         Methods (79):
            addPdVToAntiVirusQueue(xs:string idPdV, xs:string idSetup, xs:int idAzienda, )
            cancelPdV(xs:string idPdV, xs:string motivoAnnullamento, )
            checkArchiviazionePdV(xs:string idPdV, )
            checkIndicePdV(ns7:ArrayOfKeyValueOfstringanyType properties, ns0:ContentStream contentStream, )
            checkRemoteSign(xs:string urlService, xs:string userNameFirma, xs:string passwordFirma, )
            createAzienda(ns3:AziendaSdC az, )
            createDocument(xs:string repositoryId, ns7:ArrayOfKeyValueOfstringanyType properties, ns0:ContentStream contentStream, ns0:VersioningState versioningState, ns7:ArrayOfstring policies, )
            createDocumentLocal(ns7:ArrayOfKeyValueOfstringanyType properties, xs:string pathFileZip, xs:string pathFolderEsito, )
            createLavoro(ns3:LavoroSdC l, )
            createPdA(xs:string idLavoro, ns3:OpzioniSdC options, )
            createPdD(xs:string idSetup, xs:int idAzienda, ns3:UtenteSdC userRichiedente, ns7:ArrayOfstring elencoIdPdV, ns3:ArrayOfDocTipologiaSdC elencoIdDoc, )
            createPdDInfo(xs:string idSetup, xs:int idAzienda, ns3:UtenteSdC userRichiedente, ns4:RequestPdDParam requestPdD, )
            createRdV(xs:string idSetup, xs:int idAzienda, )
            createSoggetto(ns3:SoggettoSdC s, )
            createUser(ns3:UtenteSdC user, )
            deletePendingRequest(xs:string idRequest, )
            deleteUser(xs:string idUser, )
            exportDoc(xs:string idSetup, xs:int idAzienda, ns3:DocTipologiaSdC idDoc, )
            exportIndexPdV(xs:string idPdV, )
            exportRdAV(xs:string idRdAV, )
            exportRdV(xs:string idRdV, )
            exportSearchDoc(xs:string idSetup, xs:int idAzienda, xs:string jsonQuery, ns4:ExportSearchDocParam exportParam, ns2:PagingCriteria criteria, )
            getAllAntiVirusQueue(xs:string idSetup, xs:int idAzienda, xs:string stato, ns2:PagingCriteria criteria, )
            getAllAntiVirusQueueCount(xs:string idSetup, xs:int idAzienda, xs:string stato, )
            getAllAziende(xs:string idSetup, ns2:PagingCriteria criteria, )
            getAllAziendeCount(xs:string idSetup, )
            getAllDocument(xs:string idSetup, xs:int idAzienda, xs:string jsonQuery, ns2:PagingCriteria criteria, )
            getAllDocumentCount(xs:string idSetup, xs:int idAzienda, xs:string jsonQuery, )
            getAllLavori(xs:string idSetup, xs:int idAzienda, xs:string descrizione, ns2:PagingCriteria criteria, )
            getAllLavoriCount(xs:string idSetup, xs:int idAzienda, xs:string descrizione, )
            getAllLog(xs:string idSetup, xs:int idAzienda, xs:dateTime dataInizio, xs:dateTime dataFine, xs:string levelLog, ns2:PagingCriteria criteria, )
            getAllLogCount(xs:string idSetup, xs:int idAzienda, xs:dateTime dataInizio, xs:dateTime dataFine, xs:string levelLog, )
            getAllLogPdV(xs:string idPdV, ns2:PagingCriteria criteria, )
            getAllLogPdVCount(xs:string idPdV, )
            getAllPdA(xs:string idSetup, xs:int idAzienda, ns4:FilterPdAParam filter, ns2:PagingCriteria criteria, )
            getAllPdACount(xs:string idSetup, xs:int idAzienda, ns4:FilterPdAParam filter, )
            getAllPdD(xs:string idSetup, xs:int idAzienda, ns4:FilterPdDParam filter, ns2:PagingCriteria criteria, )
            getAllPdDCount(xs:string idSetup, xs:int idAzienda, ns4:FilterPdDParam filter, )
            getAllPdV(xs:string idSetup, xs:int idAzienda, xs:long idTipologia, xs:dateTime dataInizio, xs:dateTime dataFine, xs:boolean annullato, xs:boolean rdvGenerato, xs:boolean conservato, ns2:PagingCriteria criteria, )
            getAllPdVCount(xs:string idSetup, xs:int idAzienda, xs:long idTipologia, xs:dateTime dataInizio, xs:dateTime dataFine, xs:boolean annullato, xs:boolean rdvGenerato, xs:boolean conservato, )
            getAllPendingRequest(xs:string idSetup, xs:int idAzienda, ns4:FilterPendingRequestParam requestParam, xs:boolean filterByUser, ns2:PagingCriteria criteria, )
            getAllRdAV(xs:string idSetup, xs:int idAzienda, ns7:ArrayOfstring elencoIdPdV, xs:dateTime dataInizio, xs:dateTime dataFine, xs:string idSoggettoRdC, ns2:PagingCriteria criteria, )
            getAllRdAVCount(xs:string idSetup, xs:int idAzienda, ns7:ArrayOfstring elencoIdPdV, xs:dateTime dataInizio, xs:dateTime dataFine, xs:string idSoggettoFirma, )
            getAllRdV(xs:string idSetup, xs:int idAzienda, ns7:ArrayOfstring elencoIdPdV, xs:dateTime dataInizio, xs:dateTime dataFine, xs:string idSoggettoRdC, ns2:PagingCriteria criteria, )
            getAllRdVCount(xs:string idSetup, xs:int idAzienda, ns7:ArrayOfstring elencoIdPdV, xs:dateTime dataInizio, xs:dateTime dataFine, xs:string idSoggettoRdC, )
            getAllSoggetti(xs:string ruolo, xs:string ragSociale, xs:string nomeCognome, ns2:PagingCriteria criteria, )
            getAllSoggettiCount(xs:string ruolo, xs:string ragSociale, xs:string nomeCognome, )
            getAllUser(xs:string idSetup, xs:int idAzienda, ns2:PagingCriteria criteria, )
            getAllUserCount(xs:string idSetup, xs:int idAzienda, )
            getAntiVirusElementFromPdV(xs:string idPdV, )
            getAzienda(xs:string idAzienda, )
            getCurrentUser()
            getDocumentAntivirusChecks(xs:string idSetup, xs:int idAzienda, ns3:DocTipologiaSdC idDoc, )
            getLavoro(xs:string idLavoro, )
            getPdV(xs:string idPdV, )
            getPdVAttachments(xs:string idPdV, )
            getPendingOperationTypes()
            getPendingRequest(xs:string idRequest, )
            getRemainingTimestamps(xs:string idSoggetto, xs:string idSetup, xs:int idAzienda, )
            getReportPdA(xs:string idSetup, xs:int idAzienda, ns4:ReportPdARequestParam reportParam, )
            getReportPdV(xs:string idSetup, xs:int idAzienda, ns4:ReportPdVRequestParam reportParam, )
            getRepositories()
            getRepositoryInfo(xs:string repositoryId, )
            getReservedExtensions()
            getSoggettiAzienda(xs:string idSetup, xs:int idAzienda, )
            getSoggetto(xs:string idSoggetto, )
            getUser(xs:string idUser, )
            recoverPdV(xs:string idPdV, xs:string motivoRipristino, )
            removePdVFromAntiVirusQueue(xs:string idPdV, )
            requestCreateDocumentFile(ns7:ArrayOfKeyValueOfstringanyType properties, xs:string fileId, )
            requestCreatePdD(xs:string idSetup, xs:int idAzienda, ns3:UtenteSdC userRichiedente, ns4:RequestMassivePdDParam requestPdD, )
            resetPendingRequest(xs:string idRequest, xs:boolean forceReset, )
            setSoggettiAzienda(xs:string idAzienda, ns7:ArrayOfstring elencoIdSoggetti, xs:string idSoggettoFirma, )
            unlockPdASchedule(xs:string idLavoro, )
            unlockRdVSchedule(xs:string idSetup, xs:int idAzienda, )
            updateAzienda(ns3:AziendaSdC az, )
            updateLavoro(ns3:LavoroSdC l, )
            updateSoggetto(ns3:SoggettoSdC s, )
            updateUser(ns3:UtenteSdC user, )
         Types (88):
            ns0:AclPropagation
            ns0:AllowableActionsKey
            ns3:AntivirusCheckSdC
            ns3:ArrayOfAziendaSdC
            ns0:ArrayOfBaseObjectTypeId
            ns3:ArrayOfDocAntivirusCheckSdC
            ns3:ArrayOfDocSdC
            ns3:ArrayOfDocTipologiaPdVSdC
            ns3:ArrayOfDocTipologiaSdC
            ns7:ArrayOfKeyValueOfstringanyType
            ns3:ArrayOfLavoroSdC
            ns3:ArrayOfLogSdC
            ns3:ArrayOfPdASdC
            ns3:ArrayOfPdDSdC
            ns3:ArrayOfPdVAntivirusSdC
            ns3:ArrayOfPdVPdDPreSdC
            ns3:ArrayOfPdVSdC
            ns0:ArrayOfPermissionDefinition
            ns0:ArrayOfPermissionMapping
            ns3:ArrayOfQueueOpSdC
            ns3:ArrayOfQueueOpTypeSdC
            ns3:ArrayOfRdAVSdC
            ns3:ArrayOfRdVSdC
            ns3:ArrayOfReportPdASdC
            ns3:ArrayOfReportPdVSdC
            ns1:ArrayOfRepositoryEntry
            ns3:ArrayOfSoggettoLavoroSdC
            ns3:ArrayOfSoggettoSdC
            ns2:ArrayOfSortingCriteria
            ns3:ArrayOfUtentePermessoSdC
            ns3:ArrayOfUtenteSdC
            ns7:ArrayOflong
            ns7:ArrayOfstring
            ns3:AziendaSdC
            ns0:BaseObjectTypeId
            ns0:CapabilityAcl
            ns0:CapabilityChanges
            ns0:CapabilityContentStreamUpdates
            ns0:CapabilityJoin
            ns0:CapabilityQuery
            ns0:CapabilityRendition
            ns0:ContentStream
            ns2:CostantiSdC.TipoFirmaFile
            ns3:DocAntivirusCheckSdC
            ns3:DocSdC
            ns3:DocTipologiaPdVSdC
            ns3:DocTipologiaSdC
            ns4:ExportSearchDocParam
            ns4:FilterPdAParam
            ns4:FilterPdDParam
            ns4:FilterPendingRequestParam
            ns3:LavoroSdC
            ns3:LogSdC
            ns3:OpzioniSdC
            ns2:PagingCriteria
            ns3:PdASdC
            ns3:PdDDownloadSdC
            ns3:PdDSdC
            ns3:PdVAntivirusSdC
            ns3:PdVPdDPreSdC
            ns3:PdVSdC
            ns0:PermissionDefinition
            ns0:PermissionMapping
            ns3:QueueOpSdC
            ns3:QueueOpTypeSdC
            ns3:RdAVSdC
            ns3:RdVSdC
            ns3:RemainingTimestampsSdC
            ns4:ReportPdARequestParam
            ns3:ReportPdASdC
            ns4:ReportPdVRequestParam
            ns3:ReportPdVSdC
            ns0:RepositoryCapabilities
            ns1:RepositoryEntry
            ns5:RepositoryService.ErrorData
            ns4:RequestMassivePdDParam
            ns4:RequestPdDParam
            ns3:SoggettoLavoroSdC
            ns3:SoggettoSdC
            ns2:SortingCriteria
            ns0:SupportedPermissions
            ns3:UtentePermessoSdC
            ns3:UtenteSdC
            ns0:VersioningState
            ns6:char
            ns6:duration
            ns6:guid
            ns0:repositoryInfo
--------------------------------------------------------------------------------
(KeyValueOfstringanyType){
   Key = None
   Value = None
 }
Traceback (most recent call last):
  File "C:/src/qa-lsd-webservices/qa-lsd-webservices/prova.py", line 64, in <module>
    contentStream=content_stream
  File "C:\Users\Andrea-Fisso\AppData\Local\Programs\Python\Python37-32\lib\site-packages\suds\client.py", line 559, in __call__
    return client.invoke(args, kwargs)
  File "C:\Users\Andrea-Fisso\AppData\Local\Programs\Python\Python37-32\lib\site-packages\suds\client.py", line 612, in invoke
    soapenv = binding.get_message(self.method, args, kwargs)
  File "C:\Users\Andrea-Fisso\AppData\Local\Programs\Python\Python37-32\lib\site-packages\suds\bindings\binding.py", line 120, in get_message
    content = self.bodycontent(method, args, kwargs)
  File "C:\Users\Andrea-Fisso\AppData\Local\Programs\Python\Python37-32\lib\site-packages\suds\bindings\document.py", line 64, in bodycontent
    p = self.mkparam(method, pd, value)
  File "C:\Users\Andrea-Fisso\AppData\Local\Programs\Python\Python37-32\lib\site-packages\suds\bindings\document.py", line 103, in mkparam
    tags.append(self.mkparam(method, pdef, item))
  File "C:\Users\Andrea-Fisso\AppData\Local\Programs\Python\Python37-32\lib\site-packages\suds\bindings\document.py", line 106, in mkparam
    return Binding.mkparam(self, method, pdef, object)
  File "C:\Users\Andrea-Fisso\AppData\Local\Programs\Python\Python37-32\lib\site-packages\suds\bindings\binding.py", line 289, in mkparam
    return marshaller.process(content)
  File "C:\Users\Andrea-Fisso\AppData\Local\Programs\Python\Python37-32\lib\site-packages\suds\mx\core.py", line 60, in process
    self.append(document, content)
  File "C:\Users\Andrea-Fisso\AppData\Local\Programs\Python\Python37-32\lib\site-packages\suds\mx\core.py", line 73, in append
    self.appender.append(parent, content)
  File "C:\Users\Andrea-Fisso\AppData\Local\Programs\Python\Python37-32\lib\site-packages\suds\mx\appender.py", line 102, in append
    appender.append(parent, content)
  File "C:\Users\Andrea-Fisso\AppData\Local\Programs\Python\Python37-32\lib\site-packages\suds\mx\appender.py", line 243, in append
    Appender.append(self, child, cont)
  File "C:\Users\Andrea-Fisso\AppData\Local\Programs\Python\Python37-32\lib\site-packages\suds\mx\appender.py", line 182, in append
    self.marshaller.append(parent, content)
  File "C:\Users\Andrea-Fisso\AppData\Local\Programs\Python\Python37-32\lib\site-packages\suds\mx\core.py", line 72, in append
    if self.start(content):
  File "C:\Users\Andrea-Fisso\AppData\Local\Programs\Python\Python37-32\lib\site-packages\suds\mx\literal.py", line 87, in start
    raise TypeNotFound(content.tag)
suds.TypeNotFound: Type not found: 'Key'

Process finished with exit code 1

any suggestion please?

thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.