如何解决如何使用 Spyne 和 Zeep 在 Django 上测试 Soap 服务
我尝试在 django 上使用 zeep 对 SOAP 服务进行测试(使用 Spyne),但总是需要运行 runserver,但需要在没有 runserver 的情况下执行,因为需要使用测试数据库而不是默认数据库。
我像这样使用:
def test_obtenerListaAcciones(self):
# get actions
# this server need to be up to work,but need to be execute test without work this.
wsdl = 'http://127.0.0.1:8000/soap/getactions/'
client = zeep.Client(wsdl=wsdl)
headerArr = {}
settings = Settings(strict=False,xml_huge_tree=True,extra_http_headers=headerArr,raw_response=True)
client = Client(wsdl,settings=settings)
action = self.test_create_actions()
requestData = {
}
res = client.service.getactions(**requestData)
解决方法
我已经解决了使用相同的服务器客户端,不需要使用其他像Zeep这样的客户端,只需要一个Spyne的客户端。
解决方案在这里:
https://github.com/arskom/spyne/blob/master/spyne/test/interop/test_django.py
这个方法与DJango完美结合:
from spyne.client.django import DjangoTestClient
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。