requests.exceptions.HTTPError:415客户端错误使用python zeep时不支持的媒体类型
我使用PythonZeep来消费Web服务。我已经使用了soapui,并且能够使用webservice。当我使用下面的代码时,它会生成HTTP错误。如何查看SOAP请求内容以实际检查请求中发送的内容requests.exceptions.HTTPError:415客户端错误使用python zeep时不支持的媒体类型,python,zeep,Python,Zeep,我使用PythonZeep来消费Web服务。我已经使用了soapui,并且能够使用webservice。当我使用下面的代码时,它会生成HTTP错误。如何查看SOAP请求内容以实际检查请求中发送的内容 class MyLoggingPlugin(Plugin): def ingress(self, envelope, http_headers, operation): return envelope, http_headers def egress(self,
class MyLoggingPlugin(Plugin):
def ingress(self, envelope, http_headers, operation):
return envelope, http_headers
def egress(self, envelope, http_headers, operation, binding_options):
http_headers['Content-Type'] = 'text/xml; charset=utf-8;'
return envelope, http_headers
requests.packages.urllib3.disable_warnings()
session = Session()
session.verify = False
session.auth = HTTPBasicAuth('xxxxxxx', 'xxxxx')
client =
Client('https://xxxx.com:44383/sap/bc/srt/rfc/sap/zws_send_emailid/101/zws_send_emailid/binding_1',
transport=Transport(session=session),plugins=[MyLoggingPlugin()])
不确定你是否还需要答案 实际上,您可以修改插件以查看实际的xml,如下所示:
from lxml import etree
class MyLoggingPlugin(Plugin):
def ingress(self, envelope, http_headers, operation):
# to see whats coming in
print(etree.tostring(envelope, pretty_print=True))
return envelope, http_headers
def egress(self, envelope, http_headers, operation, binding_options):
http_headers['Content-Type'] = 'text/xml; charset=utf-8;'
# to see whats going out
print(etree.tostring(envelope, pretty_print=True))
return envelope, http_headers
希望这有帮助。如果答案对您有帮助,请接受。否则让我们知道问题的答案。