0

I'm using Spyne to create simple webservie, and when i call that sample service i get following error :

faultType: <Fault senv:Client.SchemaValidationError: :10:0:ERROR:SCHEMASV:SCHEMAV_CVC_ELT_1: Element 'testMethod': No matching global declaration available for the validation root.>


************************************************************************
*** Outgoing SOAP ******************************************************
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/1999/XMLSchema"
>
<SOAP-ENV:Body>
<testMethod SOAP-ENC:root="1">
<name xsi:type="xsd:string">john</name>
</testMethod>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>



*** Incoming SOAP ******************************************************
<?xml version='1.0' encoding='UTF-8'?>
<senv:Envelope xmlns:senv="http://schemas.xmlsoap.org/soap/envelope  /"><senv:Body><senv:Fault>  <faultcode>senv:Client.SchemaValidationError</faultcode> <faultstring>:10:0:ERROR:SCHEMASV:SCHEMAV_CVC_ELT_1: Element 'testMethod': No matching global declaration available for the validation root.</faultstring><faultactor></faultactor></senv:Fault></senv:Body></senv:Envelope>

SERVICE

views.py

class ServiceWsTest(ServiceBase):
    __namespace__ = "appname"

    @rpc(Unicode, _returns=Unicode)
    def testMethod(self, name):
        return "Hello {}" .format(name)

ws_test = csrf_exempt(DjangoApplication(Application([ServiceWsTest],
     'appname',
     in_protocol=Soap11(validator='lxml'),
     out_protocol=Soap11(cleanup_namespaces=True),
     #interface=Wsdl11(),
)))

urls.py

 url(r'^sample/service', DjangoView.as_view(
            services=[ServiceWsTest], tns='appname',
            in_protocol=Soap11(validator='lxml'), 
            out_protocol=Soap11(cleanup_namespaces=True))),

Service call using soappy

from SOAPpy import WSDL, SOAPProxy
server = SOAPProxy('http://IP ADDRESS/sandbox/sample/service/')
server.testMethod('john')

If I use suds, everything is working fine.

client = suds.client.Client("http://IP ADDRESS/sandbox/sample/service.wsdl", cache=None)
client.service.testMethod('jane')

Hello jane

Please advise

Asif
  • 479
  • 2
  • 6
  • 12

1 Answers1

0

Soappy's request has two issues:

  1. It's not using the correct namespace. testMethod tag must be in "appname" namespace. As there's no null namespace declaration (xmlns="appname") in the document, the actual namespace of the tag is undefined.

  2. It's using rpc encoding style (there are xsi:type attributes), whereas in the WSDL generated by Spyne, it explicitly says to use document encoding.

Don't use soappy, just use suds. To my knowledge, soappy hasn't been maintained for years.

Burak Arslan
  • 7,671
  • 2
  • 15
  • 24