1
일부 정보를 검색하기 위해 zeep과 함께 zeep을 사용하고 있습니다. client.service.ServiceName
의 응답은 python 데이터 구조, 즉 e.i리스트를 반환하지만 그 항목은 파이썬 데이터 구조가 아니라 lxml.etree._Element
입니다. zeep이 xml과 반대로 중첩 된 파이썬 사전을 반환 할 수있는 방법이 있는지 알려주시겠습니까?python zeep 중첩 된 응답이 파이썬 데이터 구조가 아닙니다.
# python 2.7
import zeep
from lxml import etree
print zeep.__version__ # '0.23.0'
history = zeep.plugins.HistoryPlugin()
client = zeep.Client(wsdl=wsdl,
wsse=UsernameToken(username, password),
plugins=[history])
projectId, cardUniqueId, cardType, userLoginId = ('3', '111', 'XXX', 'myuser')
cards = client.service.getCard(projectId, cardUniqueId, cardType, userLoginId)
print(type(cards)) # <type 'list'>
print(cards) # [<Element {http://kanbancard.webservices.kanban.app.digite.com/}fields at 0x7f706d69e640>]
print(type(cards[0])) # <type 'lxml.etree._Element'>
client.service.getCard
의 응답은 다음과 같습니다 : 여기
print(etree.tounicode(history.last_received['envelope'], pretty_print=True))
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ns:getCardResponse xmlns:ns="http://kanbancard.webservices.kanban.app.digite.com/">
<ns:fields>
<ns:field ns:name="cardNumber">XYZ</ns:field>
<ns:field ns:name="name">foobar</ns:field>
<ns:field ns:name="description">foobar</ns:field>
<ns:field ns:name="priority">High</ns:field>
<ns:field ns:name="classOfService">Standard Class</ns:field>
<ns:field ns:name="cardSize">1</ns:field>
<ns:field ns:name="dateIdentified">2017-01-19T04:07:53Z</ns:field>
<ns:field ns:name="ExternalCardId">XYZ</ns:field>
<ns:field ns:name="currentSwimId">1632088</ns:field>
<ns:field ns:name="currentQueueId">2322634</ns:field>
</ns:fields>
</ns:getCardResponse>
</soapenv:Body>
</soapenv:Envelope>
WSLD : 짧은 zeep에서
<wsdl:operation name="getCard">
<wsdl:input message="axis2:getCardRequestMessage">
</wsdl:input>
<wsdl:output message="axis2:getCardResponseMessage">
</wsdl:output>
</wsdl:operation>
<xs:element name="getCardRequest">
<xs:complexType>
<xs:sequence>
<xs:element name="projectId" nillable="false" type="xs:string"/>
<xs:element name="cardUniqueId" nillable="false" type="xs:string"/>
<xs:element name="cardType" nillable="false" type="xs:string"/>
<xs:element name="userLoginId" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="getCardResponse">
<xs:complexType>
<xs:sequence>
<xs:any maxOccurs="unbounded" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<wsdl:message name="getCardResponseMessage">
<wsdl:part name="part1" element="axis2:getCardResponse">
</wsdl:part>
<wsdl:message name="getCardRequestMessage">
<wsdl:part name="part1" element="axis2:getCardRequest">
</wsdl:part>
</wsdl:message>
<wsdl:message name="getCardResponseMessage">
<wsdl:part name="part1" element="axis2:getCardResponse">
</wsdl:part>
</wsdl:message>
이에 대한 해결책을 찾았을 사용하는 것입니다? 나는 똑같은 문제로 어려움을 겪고있다. – Oliver