SOAP run failed

209 Views Asked by At

I have bellow code for SOAP

from spyne import ServiceBase, Application, rpc, Integer, String
from spyne.protocol.soap import Soap11
from spyne.server.wsgi import WsgiApplication
from wsgiref.simple_server import make_server

class OddOrEvenService(ServiceBase):

    @rpc(Integer, _returns=String)
    def oddOrEven(self, num):
        if num % 2 == 0:
            return "even"
        else:
            return "odd"
 

application = Application([OddOrEvenService], 'my.soap.app',
        in_protocol=Soap11(),
        out_protocol=Soap11(),
    )

wsgi_app = WsgiApplication(application)
server = make_server('127.0.0.1', 7789, wsgi_app)

print ("listening to http://127.0.0.1:7789")
print ("wsdl is at: http://localhost:7789/?wsdl")

server.serve_forever()

When I'm trying to run code I receive:

Traceback (most recent call last):
File "d:\Studii IT\Cursuri\First_SOAP_project.py", line 1, in <module>
from spyne import ServiceBase, Application, rpc, Integer, String
File"C:\Users\Enter83\AppData\Local\Programs\Python\Python312\Lib\site-packages\spyne\__init__.py", line 39, in <module>    
from spyne.evmgr import EventManager
File "C:\Users\Enter83\AppData\Local\Programs\Python\Python312\Lib\site-packages\spyne\evmgr.py", line 21, in <module>   
from spyne.util.oset import oset
File "C:\Users\Enter 83\AppData\Local\Programs\Python\Python312\Lib\site-packages\spyne\util\oset.py", line 3, in <module>
from spyne.util.six.moves.collections_abc import MutableSet
ModuleNotFoundError: No module named 'spyne.util.six.moves'

How is the solution of this error. Please help

I'll tried to install spyne once again but it does not work.

2

There are 2 best solutions below

1
On

To create a SOAP request or response, you typically use XML. Below, I'll provide a simple example of a SOAP request and response in XML format. Keep in mind that in practice, you'd use a programming language or library to create and parse SOAP messages, but this is a manual XML representation for illustration purposes.

A SOAP request typically consists of an XML envelope with a element containing the actual request data. Here's a simple example of a SOAP request:

<soap:Envelope
    xmlns:soap="http://www.w3.org/2003/05/soap-envelope/"
    xmlns:web="http://www.example.com/webservice">
    <soap:Header/>
    <soap:Body>
        <web:ExampleRequest>
            <web:Parameter1>Value1</web:Parameter1>
            <web:Parameter2>Value2</web:Parameter2>
        </web:ExampleRequest>
    </soap:Body>
</soap:Envelope>
0
On

I'm changed my python version 3.12.0 to 3.10.10 and ... I can run it!