[英]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.