[英]requests.exceptions.HTTPError: 415 Client Error Unsupported Media Type when using python zeep
I am using python zeep for consuming a webservice.我正在使用 python zeep 来使用网络服务。 I had used SOAP UI and I am able to consume the webservice.
我使用过 SOAP UI,并且能够使用 Web 服务。 when I am using the below code it generates HTTP Error.
当我使用以下代码时,它会生成 HTTP 错误。 How can I see the SOAP request content to actually check what i am sending in the request.
如何查看 SOAP 请求内容以实际检查我在请求中发送的内容。
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()])
Not sure if you still need the answer.不确定您是否还需要答案。
You can actually just modify your plugin to see the actual xml like this:您实际上可以修改您的插件以查看实际的 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
hope this helps.希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.