2017-10-30 4 views
0

나는 지프와 비누에 상당히 익숙하다. 나는 비누의 기능을 클라이언트 요청을하려고합니다. 함수의 wsdl :python zeep을 사용하여 임의의 객체 생성

-<s:element name="GetRetailTransactions"> 
    -<s:complexType> 
     -<s:sequence> 
      -<s:element name="parameters" maxOccurs="1" minOccurs="0"> 
       -<s:complexType mixed="true"> 
         -<s:sequence> 
          <s:any/> 
         </s:sequence> 
       </s:complexType> 
      </s:element> 
     </s:sequence> 
    </s:complexType> 
</s:element> 

저는 zeep에서 any 유형의 객체를 만드는 방법을 완전히 이해하지 못합니다. 나는 시도했다 :

wsdl = 'http://domain/app.asmx?WSDL' 
    client = Client(wsdl=wsdl) 
    params = { 

     'RetailTransactionsParameters': { 
      'GetNotExportedOnly': '0', 
      'GetNotRetrunsOnly': '0', 
      'FromDate': '20170518', 
      'ToDate': '20170518', 
      'TransactionTypeFilter': { 
      'TransactionType': '2' 
      }, 
     }, 
    } 
    parameters = client.get_element('ns0:GetRetailTransactions') 
    param = xsd.AnyObject(parameters, parameters(params)) 
    result = client.service.GetRetailTransactions(param) 

하지만 난 얻을 오류 : 내가 요청을 성공적으로 답변을 얻을 수 있습니다 soapui에

File "/home/user/lib/python3.6/site-packages/zeep/xsd/elements/indicators.py", line 227, in render 
    if name in value: 
TypeError: argument of type 'AnyObject' is not iterable 

:

<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"> 
    <Body> 
     <GetRetailTransactions xmlns="example.com/"> 
      <parameters> 
       <RetailTransactionsParameters> 
        <GetNotExportedOnly>0</GetNotExportedOnly> 
        <GetNotRetrunsOnly>0</GetNotRetrunsOnly> 
        <FromDate>20170518</FromDate> 
        <ToDate>20170518</ToDate> 
        <TransactionTypeFilter> 
        <TransactionType>2</TransactionType> 
        </TransactionTypeFilter> 
       </RetailTransactionsParameters> 
      </parameters> 
     </GetRetailTransactions> 
    </Body> 
</Envelope> 

어쩌면 누군가가 어떻게 나를 인도 할 수 있습니다 지프로 이러한 요청을 정확하게하십시오. 미리 감사드립니다.

답변

0

오늘도 같은 문제가있었습니다. get_element 메소드는 유형을 리턴합니다. 객체를 생성하려면 객체를 인스턴스화해야합니다.

parameters = client.get_element('ns0:GetRetailTransactions')(params) 

또는 명시 적으로 설정할 수 있습니다 각 속성 : 당신은 할 수 있습니다

parameters = client.get_element('ns0:GetRetailTransactions')() 
parameters.GetNotExportedOnly = 0 
parameters.GetNotRetrunsOnly = 0 
... 

을하거나 DICT 개체를 전달할 수 있으며, zeep이 유형 http://docs.python-zeep.org/en/master/datastructures.html#creating-objects

로의 전환을한다