0

我正在使用 Spyne 创建简单的 webservie,当我调用该示例服务时,我收到以下错误:

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>

服务

视图.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(),
)))

网址.py

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

使用肥皂的服务电话

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

如果我使用泡沫,一切正常。

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

Hello jane

请指教

4

1 回答 1

0

Soappy 的请求有两个问题:

  1. 它没有使用正确的命名空间。testMethod标签必须在“appname”命名空间中。由于文档中没有空命名空间声明 ( xmlns="appname"),因此标签的实际命名空间是未定义的。

  2. 它使用 rpc 编码样式(有xsi:type属性),而在 Spyne 生成的 WSDL 中,它明确表示要使用文档编码。

不要使用肥皂,只需使用肥皂水。据我所知,sooppy 已经好几年没有维护了。

于 2015-04-28T07:53:04.370 回答