【发布时间】:2009-07-27 14:10:55
【问题描述】:
我有一个返回以下类型的网络服务:
<xsd:complexType name="TaggerResponse">
<xsd:sequence>
<xsd:element name="msg" type="xsd:string"></xsd:element>
</xsd:sequence>
<xsd:attribute name="status" type="tns:Status"></xsd:attribute>
</xsd:complexType>
该类型包含一个元素 (msg) 和一个属性 (status)。
为了与 Web 服务通信,我使用 SOAPpy 库。以下是 Web 服务返回的示例结果(SOAP 消息):
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<SOAP-ENV:TagResponse>
<parameters status="2">
<msg>text</msg>
</parameters>
</SOAP-ENV:TagResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Python 将此消息解析为:
<SOAPpy.Types.structType parameters at 157796908>: {'msg': 'text'}
如您所见,该属性已丢失。我应该怎么做才能获得“status”的值?
【问题讨论】:
标签: python web-services soap wsdl soappy