Python soaplib和Djang

2024-10-02 18:27:48 发布

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

我试图用django1.5.2和python2.7.3和soaplib0.8.1开发soapweb服务。 目前一切正常,但现在我需要将命名空间添加到@soapmethod响应中。在

这是我的观点:

from sms.soaplib_handler import DjangoSoapApp, soapmethod, soap_types
from django.views.decorators.csrf import csrf_exempt


class SmsGatewayService(DjangoSoapApp):

    __tns__ = 'http://mismsgw01.milano.ea.it/soap'

    @soapmethod(
        soap_types.String, 
        soap_types.String, 
        soap_types.String, 
        soap_types.Integer,
        soap_types.Boolean, 
        soap_types.Boolean, 
        soap_types.String, 
        _returns=soap_types.Any
    )
    def sendSms(
        self, 
        sendTo, 
        numSender,
        senderDescription,
        timeToLive,
        isDelivered,
        isStatistics,
        messageText
    ):

        retCode = '<retCode>OK</retCode>'

        return retCode

sms_gateway_service = csrf_exempt(SmsGatewayService())

这是我调用方法时的响应:

^{pr2}$

有人能帮我吗?如何修改soap响应?我需要一些类似的东西:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Body>
      <sendSmsResponse xmlns="http://mismsgw01.milano.ea.it/soap">
         <retCode>OK</retCode>
      </sendSmsResponse>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

提前谢谢


Tags: fromimportenvhttpstringsmscsrfsoap