Python SUDS - getting 415 exception when calling SOAP method

from suds.client import Client url = r'http://*********?singleWsdl' c = Client(url) 

The queries are working fine so far, but when I execute the statement below, I get the error message indicated at the end. Please, help.

 c.service.Method_Name('parameter1', 'parameter2') 

Error message:

Exception: (415, u'Cannot process the message because the content type \ "Text / XML; charset = utf-8 \ 'was not the expected type \' Multiple / related; type =" application / choir + XML "\ '' )

+5
source share
1 answer

Content-Type header for multipart / related; type = "application / xop + xml" is the type used by MTOM, the message format used to efficiently send attachments to / from web services.

I'm not sure why the error claims to be waiting for it, because the solution I found for my situation was to override the Content-Type header for "application / soap + xml; charset = UTF-8".

Example:

 soap_client.set_options(headers = {'Content-Type': 'application/soap+xml;charset=UTF-8'}) 

If you are able, you can also try checking the MTOM encoding in the web service configuration and changing it.

0
source

Source: https://habr.com/ru/post/1238233/


All Articles