2013-05-27 42 views
1

我想調用一個需要Null(無)屬性但泡沫去除它們的服務。我需要發送..泡沫發送無屬性

<ns1:Body> 
    <ns0:QueryIntersection> 
    <ns0:intersectingRoad> 
     <ns2:RoadName xsi:nil="true"/> 
     <ns2:RoadType xsi:nil="true"/> 
    </ns0:intersectingRoad> 
    <ns0:subjectRoad> 
     <ns2:RoadName>BURKE</ns2:RoadName> 
     <ns2:RoadType>ROAD</ns2:RoadType> 
    </ns0:subjectRoad> 
    </ns0:QueryIntersection> 

但泡沫去除IntersectingRoad對象,只發送

<ns1:Body> 
    <ns0:QueryIntersection> 
    <ns0:subjectRoad> 
     <ns2:RoadName>BURKE</ns2:RoadName> 
     <ns2:RoadType>ROAD</ns2:RoadType> 
    </ns0:subjectRoad> 
    </ns0:QueryIntersection> 

如果我設置在IntersectingRoad值的一個對象,將其發送和正常工作,但無也是一個有效的請求。 這是我使用的代碼的摘錄...

Int1 = client.factory.create('ns2:IntersectingRoad') 
Int1.RoadName = None 
Int1.RoadType = None 

Int2 = client.factory.create('ns2:SubjectRoad') 
Int2.RoadName = "BURKE" 
Int2.RoadType = "ROAD" 

try: 
    Ints = client.service.QueryIntersection(Int1,Int2,) 
except Exception as e: 
    print e.message 

任何幫助,請!

回答

7

Suds有特殊的用於傳遞可選參數的null()函數,因爲None被視爲缺少值。

我覺得你的情況是這樣的:

from suds import null 

Int1 = client.factory.create('ns2:IntersectingRoad') 
Int1.RoadName = null() 
Int1.RoadType = null()