未找到 {http://schemas.xmlsoap.org/soap/envelope/} 信封元素
No {http://schemas.xmlsoap.org/soap/envelope/}Envelope element was found
我正在尝试深入研究 SOAP 和 WSDL 概念。我正在使用 Python 的 spyne 库,并成功实现了 doc 中描述的 hello world 示例
基本上,我有 server.py 和 client.py 文件,其中
server.py
from spyne import Application, rpc, ServiceBase, Iterable, Integer, Unicode
from spyne.protocol.soap import Soap11
from spyne.server.wsgi import WsgiApplication
class HelloWorldService(ServiceBase):
@rpc(Unicode, Integer, _returns=Iterable(Unicode))
def say_hello(ctx, name, times):
...
application = Application([HelloWorldService], 'spyne.examples.hello.soap',
in_protocol=Soap11(validator='lxml'),
out_protocol=Soap11())
wsgi_application = WsgiApplication(application)
if __name__ == '__main__':
import logging
from wsgiref.simple_server import make_server
server = make_server('127.0.0.1', 8000, wsgi_application)
server.serve_forever()
现在,只是为了实验,我想通过 Postman 发送一个带有 XML 正文的请求(而不是使用像 suds
.
这样的库
我通过 Postman 发送的正文如下所示:
<soapenv:Envelope xmlns:soapenv="schemas.xmlsoap.org/soap/envelope/" xmlns:tran="spyne.examples.hello.soap">
<soapenv:Header/>
<soapenv:Body>
<tran:say_hello>
<tran:name>ASD</tran:name>
<tran:times>5</tran:times>
</tran:say_hello>
</soapenv:Body>
</soapenv:Envelope>
现在我收到以下错误消息:
<?xml version='1.0' encoding='UTF-8'?>
<soap11env:Envelope xmlns:soap11env="http://schemas.xmlsoap.org/soap/envelope/">
<soap11env:Body>
<soap11env:Fault>
<faultcode>soap11env:Client.SoapError</faultcode>
<faultstring>No {http://schemas.xmlsoap.org/soap/envelope/}Envelope element was found!</faultstring>
<faultactor></faultactor>
</soap11env:Fault>
</soap11env:Body>
</soap11env:Envelope>
知道我做错了什么吗?
SOAP 命名空间错误。您的消息具有此命名空间:
<soapenv:Envelope xmlns:soapenv="schemas.xmlsoap.org/soap/envelope/" ...
错误消息中提到的 SOAP 信封的正确 SOAP 命名空间:
http://schemas.xmlsoap.org/soap/envelope/
像这样:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" ...
我正在尝试深入研究 SOAP 和 WSDL 概念。我正在使用 Python 的 spyne 库,并成功实现了 doc 中描述的 hello world 示例 基本上,我有 server.py 和 client.py 文件,其中
server.py
from spyne import Application, rpc, ServiceBase, Iterable, Integer, Unicode
from spyne.protocol.soap import Soap11
from spyne.server.wsgi import WsgiApplication
class HelloWorldService(ServiceBase):
@rpc(Unicode, Integer, _returns=Iterable(Unicode))
def say_hello(ctx, name, times):
...
application = Application([HelloWorldService], 'spyne.examples.hello.soap',
in_protocol=Soap11(validator='lxml'),
out_protocol=Soap11())
wsgi_application = WsgiApplication(application)
if __name__ == '__main__':
import logging
from wsgiref.simple_server import make_server
server = make_server('127.0.0.1', 8000, wsgi_application)
server.serve_forever()
现在,只是为了实验,我想通过 Postman 发送一个带有 XML 正文的请求(而不是使用像 suds
.
我通过 Postman 发送的正文如下所示:
<soapenv:Envelope xmlns:soapenv="schemas.xmlsoap.org/soap/envelope/" xmlns:tran="spyne.examples.hello.soap">
<soapenv:Header/>
<soapenv:Body>
<tran:say_hello>
<tran:name>ASD</tran:name>
<tran:times>5</tran:times>
</tran:say_hello>
</soapenv:Body>
</soapenv:Envelope>
现在我收到以下错误消息:
<?xml version='1.0' encoding='UTF-8'?>
<soap11env:Envelope xmlns:soap11env="http://schemas.xmlsoap.org/soap/envelope/">
<soap11env:Body>
<soap11env:Fault>
<faultcode>soap11env:Client.SoapError</faultcode>
<faultstring>No {http://schemas.xmlsoap.org/soap/envelope/}Envelope element was found!</faultstring>
<faultactor></faultactor>
</soap11env:Fault>
</soap11env:Body>
</soap11env:Envelope>
知道我做错了什么吗?
SOAP 命名空间错误。您的消息具有此命名空间:
<soapenv:Envelope xmlns:soapenv="schemas.xmlsoap.org/soap/envelope/" ...
错误消息中提到的 SOAP 信封的正确 SOAP 命名空间:
http://schemas.xmlsoap.org/soap/envelope/
像这样:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" ...