[英]Python soaplib and Django
我正在尝试在Django 1.5.2中使用Python 2.7.3和soaplib 0.8.1开发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>
提前致谢
您应该使用Spyne而不是SoapLib。 由于Spyne是由soapLib构建的,因此代码的精神将保持不变,并且Spyne可以使用自己的wsdl正常工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.