我正在尝试使用RobotFramework测试SOAP1.2服务。到目前为止,我们只使用RobotFramework的suds库测试了SOAP1.1服务,并且suds与SOAP1.2不兼容。
向后兼容是新服务的一个选项,但最好是有一个更长期的解决方案。我不是一个有经验的程序员,虽然我可以编辑代码,如果被告知要编辑什么和在哪里。
在我们对使用suds的SOAP1.2服务的测试中发生的情况是: suds无法解释它从webservice获得的响应,并给出这个错误: SAXParseException::159:229: mismatched tag
soap消息很好,在SoapUI中使用它是没有问题的。
我在网上找到了一些片段,它们建议我可以让suds库在我的RobotFramework测试中使用SOAP1.2。但我几乎没有编程经验,也不知道如何将这些代码片段合并到suds中。有人在这段代码上评论说,这解决了他使用RobotFramework和suds的问题。
有没有人愿意解释一下我是如何工作的?我自己好像想不出来。任何建议都将不胜感激。
from suds.client import Client
from suds.bindings import binding
import logging
USERNAME = 'username'
PASSWORD = 'password'
# Just for debugging purposes.
logging.basicConfig(level=logging.INFO)
logging.getLogger('suds.client').setLevel(logging.DEBUG)
# Telnic's SOAP server expects a SOAP 1.2 envelope, not a SOAP 1.1 envelope
# and will complain if this hack isn't done.
binding.envns = ('SOAP-ENV', 'http://www.w3.org/2003/05/soap-envelope')
client = Client('client.wsdl',
username=USERNAME,
password=PASSWORD,
headers={'Content-Type': 'application/soap+xml'})
# This will now work just fine.
client.service.someRandomMethod()
https://stackoverflow.com/questions/53633191
复制相似问题