我试图深入挖掘SOAP和WSDL的概念。我正在使用Python的spyne,并且已经成功地实现了文档中描述的hello示例--基本上,我有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这样的libs。
我通过邮递员寄来的身体看起来如下:
<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>你知道我做错了什么吗?
发布于 2021-04-06 07:34:05
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/" ...https://stackoverflow.com/questions/66959312
复制相似问题