none
Error in Deserializing body of reply message for operation 'operation'

    Question

  • Good Afternoon,

    I am working on creating a program that manages one of IBM DataPower appliances.  The appliance has a soap xml-management interface you can use to perform a number of tasts.  I can get some of them to work, but some of even the basic ones don't work, failing to deserialize the response.  As far as I can tell, the appliance is returning good responses, but my client is failing to deserialize the response.

    Since the appliance is on a private network there is no way someone here could test it unless they have one of these as well.  However, here is the .net project (I'm using VS 2008 w/.net 3.5 SP1) and here is metadata I used to build a class with svcutil.exe.  Hopefully this will help with troubleshooting.

    Here is the exception detail:
    System.ServiceModel.CommunicationException was unhandled
      Message="Error in deserializing body of reply message for operation 'operation'."
      Source="mscorlib"
      StackTrace:
        Server stack trace: 
           at System.ServiceModel.Dispatcher.XmlSerializerOperationFormatter.DeserializeBody(XmlDictionaryReader reader, MessageVersion version, XmlSerializer serializer, MessagePartDescription returnPart, MessagePartDescriptionCollection bodyParts, Object[] parameters, Boolean isRequest)
           at System.ServiceModel.Dispatcher.XmlSerializerOperationFormatter.DeserializeBody(XmlDictionaryReader reader, MessageVersion version, String action, MessageDescription messageDescription, Object[] parameters, Boolean isRequest)
           at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeBodyContents(Message message, Object[] parameters, Boolean isRequest)
           at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeReply(Message message, Object[] parameters)
           at System.ServiceModel.Dispatcher.ProxyOperationRuntime.AfterReply(ProxyRpc& rpc)
           at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
           at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
           at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
           at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
           at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
        Exception rethrown at [0]: 
           at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
           at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
           at xmlmgmt.operation(operationRequest request)
           at xmlmgmtClient.xmlmgmt.operation(operationRequest request) in C:\Documents and Settings\mikery\Desktop\DPSoapClient2\DPSoapClient2\xml-mgmt.cs:line 116815
           at xmlmgmtClient.operation(request request) in C:\Documents and Settings\mikery\Desktop\DPSoapClient2\DPSoapClient2\xml-mgmt.cs:line 116822
           at DPSoapClient2.DPSoapGetStatus.printActiveUsers() in C:\Documents and Settings\mikery\Desktop\DPSoapClient2\DPSoapClient2\DPSoapGetStatus.cs:line 135
           at DPSoapClient2.DPSoapGetStatus..ctor() in C:\Documents and Settings\mikery\Desktop\DPSoapClient2\DPSoapClient2\DPSoapGetStatus.cs:line 43
           at DPSoapClient2.Program.Main(String[] args) in C:\Documents and Settings\mikery\Desktop\DPSoapClient2\DPSoapClient2\Program.cs:line 12
           at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
           at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
           at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
           at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Threading.ThreadHelper.ThreadStart()
      InnerException: System.InvalidOperationException
           Message="There is an error in XML document (7, 41)."
           Source="System.Xml"
           StackTrace:
                at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
                at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle)
                at System.ServiceModel.Dispatcher.XmlSerializerOperationFormatter.DeserializeBody(XmlDictionaryReader reader, MessageVersion version, XmlSerializer serializer, MessagePartDescription returnPart, MessagePartDescriptionCollection bodyParts, Object[] parameters, Boolean isRequest)
           InnerException: System.FormatException
                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.ParseUInt32(String value, NumberStyles options, NumberFormatInfo numfmt)
                     at System.Xml.XmlConvert.ToUInt32(String s)
                     at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderxmlmgmt.Read1182_StatusActiveUsers(Boolean isNullable, Boolean checkType)
                     at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderxmlmgmt.Read1184_AnyStatusElement(Boolean isNullable, Boolean checkType)
                     at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderxmlmgmt.Read1190_response(Boolean isNullable, Boolean checkType)
                     at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderxmlmgmt.Read1192_Item()
                     at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer1.Deserialize(XmlSerializationReader reader)
                     at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
                InnerException: 
    
    It seems clear based on this error that the problem with the return message is on line 7 char 41.  It is hard to determine exactly what line that is even with message log trace enabled.  I beleive it is failing on <ActiveUsers> or <session> and think <ActiveUsers> would be line 7 of the message assuming <env:Envelope is the first line.  Here is the message trace:

    <MessageLogTraceRecord>
    <HttpResponse xmlns="http://schemas.microsoft.com/2004/06/ServiceModel/Management/MessageTrace">
    <StatusCode>OK</StatusCode>
    <StatusDescription>Good</StatusDescription>
    <WebHeaders>
    <VsDebuggerCausalityData>uIDPo3FswlTHA9VMk2fgxkLFugUAAAAAM/rdkyUlfUSOYDFJc/V2xotMeexTWL9Et6lfzuBkD7MACQAA</VsDebuggerCausalityData>
    <SOAPAction>""</SOAPAction>
    <Host>some.ip.address:some.port</Host>
    <X-Client-IP>some.ip.address</X-Client-IP>
    <Transfer-Encoding>chunked</Transfer-Encoding>
    <Content-Type>text/xml</Content-Type>
    <Via>1.1 xml-mgmt</Via>
    </WebHeaders>
    </HttpResponse>
    <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Header xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"></s:Header>
    <env:Body>
    <dp:response xmlns:dp="http://www.datapower.com/schemas/management">
    <dp:timestamp>2009-04-22T12:46:23-07:00</dp:timestamp>
    <dp:status>
    <ActiveUsers xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns="">
    <session>164</session>
    <name>userID</name>
    <connection>saml-artifact</connection>
    <address>some.ip.address</address>
    <login>Wed Apr 22 12:46:23 2009</login>
    <domain>some_domain</domain>
    </ActiveUsers>
    </dp:status>
    </dp:response>
    </env:Body>
    </env:Envelope>
    </MessageLogTraceRecord>
    I have checked the xmlmgmt class for the definition of StatusActiveUsers and it looks good as far as I can tell, containing a definition for each element returned in the response.

    I am concerned that maybe the version of svcutil.exe or maybe even the runtime I am trying to compile this with is not actually 3.5 sp1.

    app.config is included in the above zip.

    If anybody here has any ideas that might help I would greatly appreciate it.  This is fairly new to me but I am learning a lot fast.
    Wednesday, April 22, 2009 9:34 PM

Answers

  • The problem the code is complaining is that the field "login" from the "StatusActiveUsers" class is defined as "uint" (xml-mgmt.cs, line 5725), but in the message it contains a DateTime/Timestamp value. On the schema, that field is defined with the tns:dmTimestamp type (xml-mgmt.xsd, line 11386); tns:dmTimestamp is defined as uint (xml-mgmt-base.xsd, lines 180 and 37).

    So, what is likely happening is that the metadata is not completely in sync with the implementation of the service (i.e., it may be stale). You should try to regenerate the client (e.g., using svcutil) with a current version of the metadata for the service you're trying to talk to.
    • Marked as answer by mryerse Wednesday, April 22, 2009 10:30 PM
    Wednesday, April 22, 2009 9:54 PM

All replies

  • The problem the code is complaining is that the field "login" from the "StatusActiveUsers" class is defined as "uint" (xml-mgmt.cs, line 5725), but in the message it contains a DateTime/Timestamp value. On the schema, that field is defined with the tns:dmTimestamp type (xml-mgmt.xsd, line 11386); tns:dmTimestamp is defined as uint (xml-mgmt-base.xsd, lines 180 and 37).

    So, what is likely happening is that the metadata is not completely in sync with the implementation of the service (i.e., it may be stale). You should try to regenerate the client (e.g., using svcutil) with a current version of the metadata for the service you're trying to talk to.
    • Marked as answer by mryerse Wednesday, April 22, 2009 10:30 PM
    Wednesday, April 22, 2009 9:54 PM
  • Wow, thanks for the fast reply.  You are right.  I changed the definition of login in xml-mgmt.cs from a uint to a string as a test and now it works.

    Could it be because xml-mgmt-base.xsd has the following?

      <xsd:simpleType name="dmTimestamp">
        <xsd:restriction base="tns:dmUInt32"/>
      </xsd:simpleType>

    Would that cause svcutil.exe to define it as a uint?

    The metadata has not changed since I used it to create this class.  It is static on a filesystem and only updated with firmware releases for the appliance.  They have not released a firmware update since I've created this class.  Just to be sure I created a new class from the metadata and it still has login set to uint.
    Wednesday, April 22, 2009 10:30 PM
  • Yes, that would cause svcutil to define it as an uint. dmTimestamp is defined as a "dmUInt32" as you pointed out (line 180). And on line 37, dmUInt32 is defined as an unsigned integer (see below).

      <xsd:simpleType name="dmUInt32">
        <xsd:restriction base="xsd:unsignedInt"/>
      </xsd:simpleType>
    .
    Wednesday, April 22, 2009 10:46 PM
  • Seems like it would be tough to convert a string representation of a time to an int.  I think that either this xsd needs to be updated or the timestamp returned needs to actually be an int that can be converted to a time.  I'll open a request with IBM to see if this can be updated.  In the meantime I think I'll modify the xsd so any elements with a type of dmTimeStamp to dmString.

    Thanks for your quick help.
    Wednesday, April 22, 2009 11:43 PM