我在django運行一個soap服務器。python django soaplib回答classmodel問題
是否有可能創建一個soap方法,該方法返回一個soaplib classmodel實例,但不包含< {方法名稱}響應> < {方法名稱} Result>標記?
例如,這裏是我的SOAP服務器的代碼部分:
# -*- coding: cp1254 -*-
from soaplib.core.service import rpc, DefinitionBase, soap
from soaplib.core.model.primitive import String, Integer, Boolean
from soaplib.core.model.clazz import Array, ClassModel
from soaplib.core import Application
from soaplib.core.server.wsgi import Application as WSGIApplication
from soaplib.core.model.binary import Attachment
class documentResponse(ClassModel):
__namespace__ = ""
msg = String
hash = String
class MyService(DefinitionBase):
__service_interface__ = "MyService"
__port_types__ = ["MyServicePortType"]
@soap(String, Attachment, String ,_returns=documentResponse,_faults=(MyServiceFaultMessage,) , _port_type="MyServicePortType" )
def sendDocument(self, fileName, binaryData, hash):
binaryData.file_name = fileName
binaryData.save_to_file()
resp = documentResponse()
resp.msg = "Saved"
resp.hash = hash
return resp
,並響應這樣的:
<senv:Body>
<tns:sendDocumentResponse>
<tns:sendDocumentResult>
<hash>14a95636ddcf022fa2593c69af1a02f6</hash>
<msg>Saved</msg>
</tns:sendDocumentResult>
</tns:sendDocumentResponse>
</senv:Body>
但我需要一個像這樣的迴應:
<senv:Body>
<ns3:documentResponse>
<hash>A694EFB083E81568A66B96FC90EEBACE</hash>
<msg>Saved</msg>
</ns3:documentResponse>
</senv:Body>
爲了得到我上面提到的第二個響應,我應該做什麼樣的配置?
在此先感謝。
u.unver34你能分享一下你的工作嗎? – Priyeshj
當然,我沒有使用上述方法,我找到了不同的方法。根據一些關鍵字,我用django soap服務器的返回點替換了那些不需要的標籤和所有響應方案樹。 –