14 years ago
Set Object Field to NULL in SOAP Request
Hi,
I have been at this for sometime but can't seem to figure out how to set a field in an object reference to null in a soap request. Kindly see an example soap below:
The above throws an exception:
I have tried leaving the '?' or an empty tag and it still does not work.
Cheers
Henry
I have been at this for sometime but can't seem to figure out how to set a field in an object reference to null in a soap request. Kindly see an example soap below:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:adm="http://my/namespace/">
<soapenv:Body>
<adm:WebMethod>
<adm:reference>
<adm:Field1></adm:Field1>
<adm:ModelName>test</adm:ModelName>
<adm:DateAdded></adm:DateAdded>
<adm:DateModified></adm:DateModified>
</adm:reference>
</adm:WebMethod>
</soapenv:Body>
</soapenv:Envelope>
The above throws an exception:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<soap:Fault>
<faultcode>soap:Client</faultcode>
<faultstring>System.Web.Services.Protocols.SoapException: Server was unable to read request. ---> System.InvalidOperationException: There is an error in XML document (14, 52). ---> System.FormatException: Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).
at System.Guid..ctor(String g)
at System.Xml.XmlConvert.ToGuid(String s)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read4_NullableOfGuid(Boolean checkType)
...
</faultstring>
<detail/>
</soap:Fault>
</soap:Body>
</soap:Envelope>
I have tried leaving the '?' or an empty tag and it still does not work.
Cheers
Henry