【发布时间】:2013-12-08 11:10:39
【问题描述】:
我在 django 中运行一个肥皂服务器。
是否可以创建一个返回soaplib 类模型实例而没有 标签的soap 方法?
例如,这是我的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 你能分享什么对你有用吗?
-
当然了,上面的方法我都没用过,我找到了不同的方法。根据一些关键字,我在 django soap 服务器的返回点用我需要的树形式替换了不需要的标签和所有响应方案树。
标签: python soap xml-namespaces tns soaplib