Python Spyne SOAP服务器不需要此元素。应为({http://}元素名)

2024-05-23 14:30:53 发布

您现在位置:Python中文网/ 问答频道 /正文

我收到一个错误,该元素不是预期的。在

Expected is {http://com.blablabla.fbs.webservice.receiver/webservice}Sms_1 ).

我不明白这是什么,又是另一天我在努力解决它。在

请给我一些提示或建议,可以引导我解决这个问题。在

发送的XML

^{pr2}$

错误信息

senv:Client.SchemaValidationError<string>:3:0:ERROR:SCHEMASV:SCHEMAV_ELEMENT_CONTENT: Element 'Sms_1': This element is not expected. Expected is ( {http://com.blablabla.fbs.webservice.receiver/webservice}Sms_1 ).

代码:

class sms(ComplexModel):
    _type_info = {
        "text": Unicode,
        'from': Unicode,
        "id": Long,
        "operator": Unicode,
        "to": Unicode,
        "numberOfParts": Integer,
    }


class ReceiverService(ServiceBase):

    @srpc(Array(sms), _returns=Unicode)
    def ReceiveSms(Sms_1):
        for data in Sms_1:
            test = data.get_deserialization_instance()
            print test.operator
        return Sms_1

application = Application([ReceiverService],
    tns='http://com.blablabla.fbs.webservice.receiver/webservice',
    name="ReceiverService",
    in_protocol=Soap11(validator="lxml"),
    out_protocol=Soap11()
    )

hello_app = csrf_exempt(DjangoApplication(application))

Tags: comwebhttpdataisserviceunicodesms
1条回答
网友
1楼 · 发布于 2024-05-23 14:30:53

您的请求文件错误。你失踪了

  1. Sms_1标记中的命名空间前缀。
  2. 对象定义中的命名空间声明。

以下是正确的对象声明:

class sms(ComplexModel):
    __namespace__ = 'http://com.blablabla.fbs.webservice.receiver/webservice'
    _type_info = {
        "text": Unicode,
        'from': Unicode,
        "id": Long,
        "operator": Unicode,
        "to": Unicode,
        "numberOfParts": Integer,
    }

这里有一个固定的请求文档:

^{pr2}$

相关问题 更多 >