如何解决使用Python访问Web服务
我一直试图使用SUDS和Zeep连接到Web服务。它们都不起作用,并引发不同的错误。
服务器使用的是wsHTTP_endpoint和AXMS_endpoint,我可以连接到后面的服务器,但是该端点无法为我提供准确的访问权限,因此我需要wsHTTP端点。
AXMS的工作代码:
from suds.client import Client
client = Client(wsdl)
x =client.service['AXMS'].Method({'datapoint':23})
我对SUDS所做的尝试:
from suds.client import Client
client = Client(wsdl)
x =client.service['wsHttp_Endpoint'].Method({'datapoint':23})
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'.")
我什至尝试了client.set_options(headers = {'Content-Type': 'application/soap+xml;charset=UTF-8'})
但是随后我收到一个错误的请求错误。 Exception: (400,'Bad Request')
我对Zeep所做的尝试(与上面的zeep客户端代码相同):
from zeep import Client
from zeep.wsse.username import UsernameToken
client = Client(wsdl)
error: The message could not be processed. This is most likely because the action XXXXX is incorrect or because the message contains an invalid
or expired security context token or because there is a mismatch between
bindings. The security context token would be invalid if the
service aborted the channel due to inactivity.
To prevent the service from aborting idle sessions prematurely increase the Receive timeout on the service endpoint's binding.
这给我装订错误。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。