Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do spyne rpc decorated methods consume soap envelope
    primarykey
    data
    text
    <p>I'm trying to write a simple soap server. I know how the soap envelope will look like (predefined). For each request that the server will serve, I know the optional soap headers, the name of the method, and parameters, and also I know what the soap response will look like (in other words, the WSDL is defined).</p> <p>What I'm trying to understand is what my spyne service should look like (inheriting from ServiceBase), to consume it.</p> <p>Here's an example of the soap request I'm expecting:</p> <pre><code>&lt;?xml version='1.0' encoding='UTF-8'?&gt; &lt;soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://resources.mydomain.com/soap/1.1"&gt; &lt;soap:Header&gt; &lt;ns:myinfo&gt;someinfo&lt;/ns:myinfo&gt; &lt;/soap:Header&gt; &lt;soap:Body&gt; &lt;ns:MyMethod&gt; &lt;ns:mymethodparam&gt;somevalue&lt;/ns:mymethodparam&gt; &lt;/ns:MyMethod&gt; &lt;/soap:Body&gt; &lt;/soap:Envelope&gt; </code></pre> <p>At the moment, what I'm doing is just sending the above envelope via curl. The response I get is:</p> <pre><code>&lt;?xml version='1.0' encoding='UTF-8'?&gt; &lt;tns:Envelope xmlns:tns="http://schemas.xmlsoap.org/soap/envelope/"&gt; &lt;tns:Body&gt; &lt;tns:Fault&gt; &lt;faultcode&gt;senv:Client.ResourceNotFound&lt;/faultcode&gt; &lt;faultstring&gt;Requested resource '{http://resources.mydomain.com/soap/1.1}MyMethod' not found&lt;/faultstring&gt; &lt;faultactor&gt;&lt;/faultactor&gt; &lt;/tns:Fault&gt; &lt;/tns:Body&gt; &lt;/tns:Envelope&gt; </code></pre> <p>The code I'm using, as suggested by Burak Arslan is: example.py:</p> <pre><code>from spyne.model.primitive import Boolean, Unicode, Integer from spyne.model.complex import ComplexModelBase from spyne.model.complex import ComplexModel from spyne.model.complex import ComplexModelMeta from spyne.service import ServiceBase from spyne.decorator import rpc import logging class MyHeader(ComplexModel): myinfo = Unicode class MyMethodRequest(ComplexModel): mymethodparam = Unicode class SomeService(ServiceBase): __in_header__ = MyHeader @rpc(MyMethodRequest, _body_style='bare') def MyMethod(request): print "I got:", request.mymethodparam </code></pre> <p>And the code I use to start the server is: test_run.py:</p> <pre><code>from spyne.application import Application from spyne.protocol.soap import Soap11 from spyne.server.wsgi import WsgiApplication from wsgiref.simple_server import make_server import logging logging.basicConfig(level=logging.DEBUG) logging.info('listening to http://127.0.0.1:8000') application = Application([SomeService], 'http://schemas.xmlsoap.org/soap/envelope/', in_protocol=Soap11(), out_protocol=Soap11()) wsgi_application = WsgiApplication(application) server = make_server('127.0.0.1', 8000, wsgi_application) server.serve_forever() </code></pre> <p>Another thing I'm not sure about is if I got the WSDL setup correctly (in the right location in the project), but as far as I understand (and I could be completely off, I'm new to soap and spyne), this should not really matter, as long as I build the API accordingly (using spyne). Am I correct?</p> <p>I'm making the request with curl:</p> <pre><code>curl --header "content-type: text/soap+xml; charset=utf-8" --data @example.xml http://127.0.0.1:8000 </code></pre> <p>Any pointers on what am I doing wrong? Thank you so much!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload