Python Spyne-WSDL服务器-验证根目录没有匹配的全局声明
我正在尝试使用python spyne库创建soap服务器。我真的不明白如何配置服务器来接收发送的数据,因为我收到了错误 请提供一些帮助,提示和反馈来解决这个问题 当我发布粘贴在下面的代码时,我得到:Python Spyne-WSDL服务器-验证根目录没有匹配的全局声明,python,soap,wsdl,suds,spyne,Python,Soap,Wsdl,Suds,Spyne,我正在尝试使用python spyne库创建soap服务器。我真的不明白如何配置服务器来接收发送的数据,因为我收到了错误 请提供一些帮助,提示和反馈来解决这个问题 当我发布粘贴在下面的代码时,我得到: No matching global declaration available for the validation root. 当我使用肥皂水发送一些数据时,我得到: imp = Import('http://schemas.xmlsoap.org/soap/encoding/',
No matching global declaration available for the validation root.
当我使用肥皂水发送一些数据时,我得到:
imp = Import('http://schemas.xmlsoap.org/soap/encoding/',
location='http://schemas.xmlsoap.org/soap/encoding/')
imp.filter.add('http://localhost:8000/sms/receive/')
client = suds.client.Client('http://localhost:8000/sms/receive/')
print client
data = dict(id=1231412,
name="tester",
operator="nokia",
to="4879293213",
text="4879293213",
numberOfParts=1,
)
print client.service.ReceiveSms(data)
suds.TypeNotFound: Type not found: 'to'
这是我的soap服务器将接收的查询
<env:Header/>
<env:Body>
<ns1:ReceiveSms xmlns:ns1="http://com.blablabla.webservice.receiver/webservice">
<Sms_1>
<id>25094332348431</id>
<from>48123123123</from>
<operator>P4</operator>
<to>481231231234</to>
<text>test</text>
<numberOfParts>1</numberOfParts>
</Sms_1>
</ns1:ReceiveSms>
</env:Body>
</env:Envelope>
XML响应:
<?xml version='1.0' encoding='UTF-8'?>
<senv:Envelope
xmlns:senv="http://schemas.xmlsoap.org/soap/envelope/">
<senv:Body>
<senv:Fault>
<faultcode>senv:Client.SchemaValidationError</faultcode>
<faultstring><string>:2:0:ERROR:SCHEMASV:SCHEMAV_CVC_ELT_1: Element '{http://localhost:8000/types/}receiveSms': No matching global declaration available for the validation root.</faultstring>
<faultactor></faultactor>
</senv:Fault>
</senv:Body>
</senv:Envelope>
senv:Client.SchemaValidationError
字符串:2:0:错误:SCHEMASV:SCHEMAV\u CVC\u ELT\u 1:元素'{http://localhost:8000/types/}receiveSms”:没有可用于验证根的匹配全局声明。
假设url是正确的,并且正确定义了响应
对象,则以下操作应该有效:
client = suds.client.Client('http://localhost:8000/sms/receive/?wsdl')
resp = client.factory.create('{spyne.examples.hello}Response')
resp.id = 5
# (...)
print client.service.ReceiveSms(resp)
我给您的建议是,始终从最简单的情况开始,并以小步骤进行迭代。乍一看:
Element'{http://localhost:8000/types/}receiveSms”:没有可用于验证根的匹配全局声明。
--它说的是receiveSms
,但您的定义是receiveSms
,我确实将tns值更改为正确值,并且:Sms_1”:不应使用此元素。应该是({}Sms_1)。你明白了吗?我正在处理一个类似的问题,试图理解如何将WSDL或soap信封映射到spyne@rpc函数是的,但我现在没有访问源代码的权限。我将在周一检查它。我做了一些更新,我得到:senv:Client.SchemaValidationError:3:0:ERROR:SCHEMASV:SCHEMAV_ELEMENT_CONTENT:ELEMENT'Sms_1':不需要此元素。应该是({}Sms_1)。当我在Application()中关闭lxml验证器时,我会得到一个函数Sms()对象的列表,但我无法从中获取任何数据
<?xml version='1.0' encoding='UTF-8'?>
<senv:Envelope
xmlns:senv="http://schemas.xmlsoap.org/soap/envelope/">
<senv:Body>
<senv:Fault>
<faultcode>senv:Client.SchemaValidationError</faultcode>
<faultstring><string>:2:0:ERROR:SCHEMASV:SCHEMAV_CVC_ELT_1: Element '{http://localhost:8000/types/}receiveSms': No matching global declaration available for the validation root.</faultstring>
<faultactor></faultactor>
</senv:Fault>
</senv:Body>
</senv:Envelope>
client = suds.client.Client('http://localhost:8000/sms/receive/?wsdl')
resp = client.factory.create('{spyne.examples.hello}Response')
resp.id = 5
# (...)
print client.service.ReceiveSms(resp)