我正在尝试使用 Python 2.7.3 和 soaplib 0.8.1 在 Django 1.5.2 中开发 SOAP Web 服务。目前一切正常,但现在我需要将命名空间添加到@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())
这是我调用该方法时的响应:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<sendSmsResponse>
<sendSmsResult>
<retCode>OK</retCode>
</sendSmsResult>
</sendSmsResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
任何人都可以帮助我吗?我如何修改肥皂响应?我需要有类似的东西:
<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>
提前致谢