Reputation: 4509
I am trying to dig deep into SOAP and WSDL concepts. I am using Python's spyne lib, and have successfully implemented the hello world example described in the doc Basically, I have the server.py and client.py files, where
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()
Now, just for the sake of experiment, I want to send via Postman a request with XML body (instead of using libs like suds
.
The body that I send via Postman looks like this:
<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>
Now I end up with the following error message:
<?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>
Any ideas what I am doing wrong ?
Upvotes: 0
Views: 4725
Reputation: 24590
The SOAP namespace is wrong. Your message has this namespace:
<soapenv:Envelope xmlns:soapenv="schemas.xmlsoap.org/soap/envelope/" ...
The correct SOAP namespace for a SOAP envelope is the one mentioned in the error message:
http://schemas.xmlsoap.org/soap/envelope/
Like this:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" ...
Upvotes: 2