Axel
Axel

Reputation: 1

SOAP Spyne Requested Resource not found WSDL

thats why I try to begin with Hello World application.. not really successfully. I created a server with SPYNE in python. I always get bad response "Requested Resource say_helloResponse not found. If I delete the request "say_helloResponse", it wont find other other resources as well. I dont get the point.. Can you please help?

main.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):
        """Docstrings for service methods appear as documentation in the wsdl.
        <b>What fun!</b>
        @param name the name to say hello to
        @param times the number of times to say hello
        @return the completed array
        """

        for i in range(times):
            yield u'Hello, %s' % name


application = Application([HelloWorldService], 'spyne.examples.hello.soap',
                          in_protocol=Soap11(validator='lxml'),
                          out_protocol=Soap11(polymorphic=True))

wsgi_application = WsgiApplication(application)


if __name__ == '__main__':
    import logging

    from wsgiref.simple_server import make_server

    logging.basicConfig(level=logging.DEBUG)
    logging.getLogger('spyne.protocol.xml').setLevel(logging.DEBUG)

    logging.info("listening to http://127.0.0.1:8008")
    logging.info("wsdl is at: http://localhost:8008/?wsdl")

    server = make_server('127.0.0.1', 8008, wsgi_application)
    server.serve_forever()

wsdl

<wsdl:definitions targetNamespace="spyne.examples.hello.soap" name="Application">
<wsdl:types>
<xs:schema targetNamespace="spyne.examples.hello.soap" elementFormDefault="qualified">
<xs:complexType name="stringArray">
<xs:sequence>
<xs:element name="string" type="xs:string" minOccurs="0" maxOccurs="unbounded" nillable="true"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="say_hello">
<xs:sequence>
<xs:element name="name" type="xs:string" minOccurs="0" nillable="true"/>
<xs:element name="times" type="xs:integer" minOccurs="0" nillable="true"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="say_helloResponse">
<xs:sequence>
<xs:element name="say_helloResult" type="tns:stringArray" minOccurs="0" nillable="true"/>
</xs:sequence>
</xs:complexType>
<xs:element name="stringArray" type="tns:stringArray"/>
<xs:element name="say_hello" type="tns:say_hello"/>
<xs:element name="say_helloResponse" type="tns:say_helloResponse"/>
</xs:schema>
</wsdl:types>
<wsdl:message name="say_hello">
<wsdl:part name="say_hello" element="tns:say_hello"/>
</wsdl:message>
<wsdl:message name="say_helloResponse">
<wsdl:part name="say_helloResponse" element="tns:say_helloResponse"/>
</wsdl:message>
<wsdl:service name="HelloWorldService">
<wsdl:port name="Application" binding="tns:Application">
<wsdlsoap11:address location="http://localhost:8008/"/>
</wsdl:port>
</wsdl:service>
<wsdl:portType name="Application">
<wsdl:operation name="say_hello" parameterOrder="say_hello">
<wsdl:documentation>
Docstrings for service methods appear as documentation in the wsdl. <b>What fun!</b> @param name the name to say hello to @param times the number of times to say hello @return the completed array
</wsdl:documentation>
<wsdl:input name="say_hello" message="tns:say_hello"/>
<wsdl:output name="say_helloResponse" message="tns:say_helloResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="Application" type="tns:Application">
<wsdlsoap11:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="say_hello">
<wsdlsoap11:operation soapAction="say_hello" style="document"/>
<wsdl:input name="say_hello">
<wsdlsoap11:body use="literal"/>
</wsdl:input>
<wsdl:output name="say_helloResponse">
<wsdlsoap11:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
</wsdl:definitions>

Request

<?xml version='1.0' encoding='UTF-8'?>
<senv:Envelope xmlns:tns="spyne.examples.hello.soap" xmlns:senv="http://schemas.xmlsoap.org/soap/envelope/">
  <senv:Body>
    <tns:say_helloResponse>
      <tns:say_helloResult>
        <tns:string>Hello, Dave</tns:string>
        <tns:string>Hello, Dave</tns:string>
        <tns:string>Hello, Dave</tns:string>
        <tns:string>Hello, Dave</tns:string>
        <tns:string>Hello, Dave</tns:string>
      </tns:say_helloResult>
    </tns:say_helloResponse>
  </senv:Body>
</senv:Envelope>

Response


<?xml version='1.0' encoding='UTF-8'?>
<soap11env:Envelope xmlns:soap11env="http://schemas.xmlsoap.org/soap/envelope/"><soap11env:Body><soap11env:Fault><faultcode>soap11env:Client.ResourceNotFound</faultcode><faultstring>Requested resource '{spyne.examples.hello.soap}say_helloResponse' not found</faultstring><faultactor></faultactor></soap11env:Fault></soap11env:Body></soap11env:Envelope>

I did not find any similar problems in web, in ground I need python handle soap requests

Upvotes: 0

Views: 154

Answers (1)

Axel
Axel

Reputation: 1

The request was false in ground, because it was the expected response.

Here is the correct request:

<?xml version='1.0' encoding='UTF-8'?>
<senv:Envelope xmlns:tns="spyne.examples.hello.soap" xmlns:senv="http://schemas.xmlsoap.org/soap/envelope/">
<senv:Header> <RequestHeader>
</RequestHeader>
</senv:Header>
<senv:Body>
<tns:say_hello>
<tns:name>Axel</tns:name>
<tns:times>5</tns:times>
</tns:say_hello>
</senv:Body>
</senv:Envelope> 

Upvotes: 0

Related Questions