猿问

suds Send None属性

我正在尝试调用需要Null(None)属性但将suds删除的服务。我需要发送..


<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>

但suds删除了IntersectingRoad对象,仅发送


<ns1:Body>

  <ns0:QueryIntersection>

     <ns0:subjectRoad>

        <ns2:RoadName>BURKE</ns2:RoadName>

        <ns2:RoadType>ROAD</ns2:RoadType>

     </ns0:subjectRoad>

  </ns0:QueryIntersection>

如果我在IntersectingRoad对象中设置值之一,它将发送它并正常工作,但None也是有效的请求。这是我正在使用的代码的一部分...


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

请帮忙!


胡说叔叔
浏览 134回答 1
1回答

慕村9548890

Suds具有用于传递可选参数的特殊null()函数,因为None被视为缺少值。我认为您的情况将如下所示:from suds import nullInt1 = client.factory.create('ns2:IntersectingRoad')Int1.RoadName = null()Int1.RoadType = null()
随时随地看视频慕课网APP

相关分类

Python
我要回答