Topic by Shreyas Pandhari
Content
Hi,
While consuming a third party cloud wsdl using C#, I get an exception: Error in deserializing body of reply message for operation '<operation_name>'.
InnerException: System.InvalidOperationException
HResult=-2146233079
Message=There is an error in XML document (1, 3619).
Source=System.Xml
StackTrace:
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
at System.ServiceModel.Dispatcher.XmlSerializerOperationFormatter.DeserializeBody(XmlDictionaryReader reader, MessageVersion version, XmlSerializer serializer, MessagePartDescription returnPart, MessagePartDescriptionCollection bodyParts, Object[] parameters, Boolean isRequest)
InnerException: System.FormatException
HResult=-2146233033
Message=Input string was not in a correct format.
Source=mscorlib
StackTrace:
at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
at System.Number.ParseInt64(String value, NumberStyles options, NumberFormatInfo numfmt)
at System.Int64.Parse(String s, NumberStyles style, IFormatProvider provider)
at System.Xml.XmlConvert.ToInt64(String s)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderOpportunityService.Read58_Opportunity(Boolean isNullable, Boolean checkType)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderOpportunityService.Read108_getOpportunityResponse()
at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer26.Deserialize(XmlSerializationReader reader)
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
As per the investigation so far from my end, .NET client is not able to deserialise the xml response we are getting from the external service. After analysing the incoming response using Fidller tool, it is noticed that deserialization process fails at the empty tags which we are getting from fusion (while using a specific operation). For example, the exception occurs at the empty tags like
<ns3:DescriptionText xsi:nil="true"/>
<ns3:PrimaryContactEmailAddress xsi:nil=”true” />
<ns3:FormattedAddress xsi:nil="true"/>
There is no issue with the tags that do not contain the xsi:nil="true" attribute. As far as known, such tags are not standard xml tags and .NET client is failing to interpret the response structure.
Is there any way we can control the incoming xml response, remove the unwanted attributes from xml element tag in .NET client and overcome this error? The other application too is a cloud application so manipulating the response like we can do in on-premise application is out of scope.
Thanks,
Shreyas
Version
Feb 14