dateTime fields are included in the SOAP message, even when they have no value (fields of other data types are not included - which is desired behavior)
Using SUDS : 0.3.1
Server is WCF (.NET)
Extract from the xsd: (sorry no public available wsdl, and not sure if I can distribute all wsdl / xsd)
<xs:complexType name="WorkOrder"> xs:sequence <xs:element minOccurs="0" name="ActionTaken" nillable="true" type="xs:string" /> <xs:element minOccurs="0" name="CompletedDateTime" nillable="true" type="xs:dateTime" /> <xs:element minOccurs="0" name="CustomerId" nillable="true" type="xs:int" /> <xs:element minOccurs="0" name="ExpirationDate" nillable="true" type="xs:dateTime" /> <xs:element minOccurs="0" name="Id" nillable="true" type="xs:int" /> <xs:element minOccurs="0" name="RegisteredDateTime" nillable="true" type="xs:dateTime" /> <xs:element minOccurs="0" name="ServiceDateTime" nillable="true" type="xs:dateTime" /> <xs:element minOccurs="0" name="WorkOrderServices" nillable="true" type="tns:WorkOrderServiceCollection" /> <xs:element minOccurs="0" name="WorkOrderStatusId" nillable="true" type="xs:int" /> </xs:sequence> </xs:complexType>
Code:
from suds.client import Client url = 'http://blah.blah.svc?wsdl' client = Client(url) authen = client.factory.create('ns3:AuthenticationHeader') print authen authen.UserName = 'XXX' authen.Proof = 'XXX' wo = client.factory.create('ns4:WorkOrder') wo.Id = 3202 try: res = client.service.ReopenWorkOrder(wo, soapheaders=authen) except Exception, e: print e print client.last_sent()
message (from client.last_sent())
<?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/ http://schemas.xmlsoap.org/soap/encoding/ " xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance http://www.w3.org/2001/XMLSchema-instance " xmlns:tns="http://blah.blah/Security http://blah.blah/Security " xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/ http://schemas.xmlsoap.org/soap/envelope/ "> SOAP-ENV:Header tns:AuthenticationHeader tns:ProofXXX</tns:Proof> tns:UserNameXXX</tns:UserName> </tns:AuthenticationHeader> </SOAP-ENV:Header> <SOAP-ENV:Body xmlns:tns="http://blah.blah/Workforce http://blah.blah/Workforce "> tns:ReopenWorkOrder tns:workOrder tns:CompletedDateTime</tns:CompletedDateTime> tns:ExpirationDate</tns:ExpirationDate> tns:Id3202</tns:Id> tns:RegisteredDateTime</tns:RegisteredDateTime> tns:ServiceDateTime</tns:ServiceDateTime> tns:WorkOrderServices tns:Items/ </tns:WorkOrderServices> </tns:workOrder> </tns:ReopenWorkOrder> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
Thanks, GEraint.