使用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 (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...