2012-01-16 12 views
2

SUDSを使用して正しいSOAPリクエストを生成しようとすると問題が発生します。 特定のXML要素については、私は名前空間を使用して属性を指定する必要があります。Python SUDS - 適切なSOAPリクエストを生成できません

ns0:type 

は、オリジナルの仕様は次のとおりです。

(ParameterType){ 
    Name = 
     (NameType){ 
     value = None 
     _required = "" 
     } 
    Description = None 
    Value = 
     (ValueType){ 
     Text = None 
     XmlDoc = None 
     _type = "" 
     } 
} 

だから私はこのXMLを取得する:

<ns0:parameters> 
    <ns0:Input> 
     <ns0:Parameter> 
      <ns0:Name required="true">Param</ns0:Name> 
      <ns0:Value type="xs:Text"> 
      <ns0:Text>1</ns0:Text> 
      </ns0:Value> 
     </ns0:Parameter> 
    </ns0:Input> 
</ns0:parameters> 

何私はこれを入手する必要があります:

<ns0:parameters> 
    <ns0:Input> 
     <ns0:Parameter> 
      <ns0:Name required="true">Param</ns0:Name> 
      <ns0:Value ns0:type="xs:Text"> 
      <ns0:Text>1</ns0:Text> 
      </ns0:Value> 
     </ns0:Parameter> 
    </ns0:Input> 
</ns0:parameters> 

私はプラグインを使ってみましたが、 ":"チャーが気に入らないと思います。コードは次のとおりです。

class MyPlugin(MessagePlugin): 
    def marshalled(self, context): 
     foo = context.envelope.getChild('Body').getChild('ns0:executeProcess').getChild('ns0:parameters').getChild('ns0:Input').getChild('ns0:Parameter').getChild('ns0:Value') 
     foo.attributes.append(Attribute("ns0:type", "Text")) 

私はこれをどのように達成することができますか?ありがとうございました。

さらに詳しい情報:泡0.4.1 - のpython 2.4

答えて

3

私は、適切なプラグインの使用が見つかりました:

class MyPlugin(MessagePlugin): 
def marshalled(self, context): 
    inputElement = context.envelope.getChild('Body').getChild('ns0:executeProcess').getChild('ns0:parameters').getChild('ns0:Input') 
    parametrosElements = inputElement.getChildren() 
    for i in range(len(parametrosElements)): 
     valueElement = parametrosElements[i].getChild('ns0:Value') 
     valueElement.attributes.append(Attribute("ns0:type", "Text")) 
関連する問題