2016-07-21 4 views
0

私は石鹸のAPIのための石鹸クライアントを作成しようとしています。
私はこれにPythons suds liabraryを使用しています。私はこれでタグと値のペアを追加するにはどうすればよいpython soap apiを使用してsuds:複雑な変数を作成

>>> id_info = client.factory.create("ns0:ArrayOfTagValuePair") 
>>> id_info 
(ArrayOfTagValuePair){ 
    TagValuePair[] = <empty> 
} 

<pay:idInfo> 
    <api:TagValuePair> 
     <api:tag>phoneNumber</<api:tag> 
     <api:value>tel:+11234567890</value><api:value> 
    </api:TagValuePair> 
</pay:idInfo> 

後はidInfoのタイプです:
私は石鹸requstに次のような出力が得られます複雑な変数を作成したいです?

答えて

0

は、次の試してみてください。次のドキュメント参照してください

class ArrayOfTagValuePair(suds.plugin.DocumentPlugin): 
    """Plugin to add element to AccountAssignment that is not defined in WSDL.""" 
    def __init__(self, *args): 
     self.args = args 

    def parsed(self, context): 
     complexTypes = context.document.getRoot().getChild('types').getChild('schema').getChildren('complexType') 
     # Get the complex type with attribute 'name' == 'ArrayOfTagValuePair'. 
     for ct in complexTypes: 
      if ct.get('name') == 'ArrayOfTagValuePair': 
       array_TagValuePair = ct 

     sequenceElements = array_TagValuePair.getChild('complexContent').getChild('extension').getChild('sequence') 

     for key in self.args: 
      sequenceElements.append(e) 


def TagValuePair(self): 
    module_name = 'WS3Trans' 
    service_name = 'TagValuePair' 
    service_url = '%s/%s/%s.asmx?WSDL' %(self.webservice_url, module_name, service_name) 
    client = suds.client.Client(service_url, plugins=[ArrayOfTagValuePair('tag', 'value')]) 
    return client 

here & here

関連する問題