suds-py3 icon indicating copy to clipboard operation
suds-py3 copied to clipboard

HTTP error 415: content type error

Open packnologyusa opened this issue 3 years ago • 1 comments

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'.")

packnologyusa avatar Sep 08 '21 04:09 packnologyusa

@packnology https://suds-py3.readthedocs.io/en/latest/#options client object supports header to pass extra headers maybe you can try that?

cackharot avatar Nov 15 '21 14:11 cackharot