arskom / spyne

A transport agnostic sync/async RPC library that focuses on exposing services with a well-defined API using popular protocols.
http://spyne.io
Other
1.13k stars 313 forks source link

No Envelope element was found! #636

Closed ghost closed 4 years ago

ghost commented 4 years ago

Hey sorry to bother you. I'm having a problem trying to make a WSDL server. This is my code,

import logging
logger = logging.getLogger(__name__)

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

from spyne.application import Application
from spyne.decorator import rpc
from spyne.service import ServiceBase
from spyne.model.complex import ComplexModel
from spyne.model.binary import ByteArray
from spyne.model.primitive import Unicode
from spyne.server.wsgi import WsgiApplication
from spyne.protocol.soap import Soap12
from spyne import String, Iterable

tns = 'http://127.0.0.1'

class documentResponse(ComplexModel):
    msg = Unicode
    hash = ByteArray

class HelloWorld(ServiceBase):
    @rpc(String,  _returns=Iterable(String))
    def echoTest(ctx, mensaje):
        yield u'%s' % mensaje

        return resp

application = Application([HelloWorld], tns=tns,
                          in_protocol=Soap12(),
                          out_protocol=Soap12())

gib_application = WsgiApplication(application)

from wsgiref.simple_server import make_server

server = make_server('0.0.0.0', 8000, gib_application)
server.serve_forever()

And this is the error that i got.

<soap12env:Envelope xmlns:soap12env="http://www.w3.org/2003/05/soap-envelope">
   <soap12env:Body>
      <soap12env:Fault>
         <soap12env:Reason>
            <soap12env:Text xml:lang="en">No {http://www.w3.org/2003/05/soap-envelope}Envelope element was found!</soap12env:Text>
         </soap12env:Reason>
         <soap12env:Role/>
         <soap12env:Code>
            <soap12env:Value>soap12env:Sender</soap12env:Value>
            <soap12env:Subcode>
               <soap12env:Value>SoapError</soap12env:Value>
            </soap12env:Subcode>
         </soap12env:Code>
      </soap12env:Fault>
   </soap12env:Body>
</soap12env:Envelope>

And this is the console log

192.168.1.9 - - [01/Feb/2020 18:44:28] "GET /?wsdl HTTP/1.1" 200 2668
DEBUG:spyne.server.wsgi:Add http header 'accept_encoding' = ['gzip,deflate']
DEBUG:spyne.server.wsgi:Add http header 'soapaction' = ['"echoTest"']
DEBUG:spyne.server.wsgi:Add http header 'host' = ['0.0.0.0:8000']
DEBUG:spyne.server.wsgi:Add http header 'connection' = ['Keep-Alive']
DEBUG:spyne.server.wsgi:Add http header 'user_agent' = ['Apache-HttpClient/4.1.1 (java 1.5)']
DEBUG:spyne.protocol._base:PMORPH Skipped: <spyne.protocol.soap.soap12.Soap12 object at 0x000002190A125F88> is NOT polymorphic
DEBUG:spyne.protocol._base:<spyne.protocol.soap.soap12.Soap12 object at 0x000002190A125F88> attrcache size: 0
DEBUG:spyne.protocol.xml:?[1;31mResponse?[0m b'<soap12env:Envelope xmlns:soap12env="http://www.w3.org/2003/05/soap-envelope">\n  <soap12env:Body>\n    <soap12env:Fault>\n      <soap12env:Reason>\n        <soap12env:Text xml:lang="en">No {http://www.w3.org/2003/05/soap-envelope}Envelope element was found!</soap12env:Text>\n      </soap12env:Reason>\n      <soap12env:Role></soap12env:Role>\n      <soap12env:Code>\n        <soap12env:Value>soap12env:Sender</soap12env:Value>\n        <soap12env:Subcode>\n          <soap12env:Value>SoapError</soap12env:Value>\n        </soap12env:Subcode>\n      </soap12env:Code>\n    </soap12env:Fault>\n  </soap12env:Body>\n</soap12env:Envelope>\n'
DEBUG:spyne:gc.collect() took around 10ms.
192.168.1.9 - - [01/Feb/2020 18:44:41] "POST / HTTP/1.1" 500 561

I have installed Python 3.7.4 spyne 2.13.11a0 lxml 4.4.2

Thanks.