Web服务错误“反序列化操作的回复消息正文出错”

时间:2015-05-11 20:29:35

标签: c# web-services wcf

尝试为HP Operations Orchestration调用Web服务时,我收到以下错误消息。看来WSDL没有正确格式化响应,或者我没有正确处理响应。我在网上看到的大多数内容都指的是邮件大小太小。情况似乎并非如此。我已经改为只使用var而且没有帮助。有什么想法吗?

致电:var h = OOSRClient.getFlowRunHistoryByRunId(1);

例外:

System.ServiceModel.CommunicationException was caught
  HResult=-2146233087
  Message=Error in deserializing body of reply message for operation 'getFlowRunHistoryByRunId'.
  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.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 TestOO.OOSR.WSCentralService.getFlowRunHistoryByRunId(getFlowRunHistoryByRunIdRequest request)
       at TestOO.OOSR.WSCentralServiceClient.TestOO.OOSR.WSCentralService.getFlowRunHistoryByRunId(getFlowRunHistoryByRunIdRequest request) in c:\Users\slippi3\Documents\Visual Studio 2013\Projects\TestOO\TestOO\Service References\OOSR\Reference.cs:line 7526
       at TestOO.OOSR.WSCentralServiceClient.getFlowRunHistoryByRunId(Int64 runId) in c:\Users\slippi3\Documents\Visual Studio 2013\Projects\TestOO\TestOO\Service References\OOSR\Reference.cs:line 7532
       at TestOO.Controllers.HomeController.Index() in c:\Users\slippi3\Documents\Visual Studio 2013\Projects\TestOO\TestOO\Controllers\HomeController.cs:line 118
  InnerException: System.InvalidOperationException
       HResult=-2146233079
       Message=There is an error in XML document (1, 1287).
       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.InvalidCastException
            HResult=-2147467262
            Message=Cannot assign object of type System.Object[] to an object of type TestOO.OOSR.WSRunHistoryDetailsExtend[].
            Source=ma3ir41a
            StackTrace:
                 at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderWSCentralService.Read90_Item()
                 at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer45.Deserialize(XmlSerializationReader reader)
                 at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
            InnerException: 

以下是回复:

<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
    <ns1:getFlowRunHistoryByRunIdResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://wscentralservice.services.dharma.iconclude.com">

<getFlowRunHistoryByRunIdReturn soapenc:arrayType="xsd:anyType[1]" xsi:type="soapenc:Array" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
<getFlowRunHistoryByRunIdReturn xsi:type="ns2:WSRunHistoryDetailsExtend" xmlns:ns2="http://iconclude.com/webservices/rss/v2.0/soap">
<uuid xsi:type="xsd:string">1111ac59-6bbe-47fa-841f-94e56c1b2111</uuid>
<flowRevision xsi:type="xsd:string">4</flowRevision>
<runHistoryId xsi:type="xsd:long">1</runHistoryId>
<runName xsi:type="xsd:string"></runName>
<userId xsi:type="xsd:string">AA\AAAAAAA</userId>
<status xsi:type="xsd:string">Resolved</status>
<startTime xsi:type="xsd:long">1302621361380</startTime>
<duration xsi:type="xsd:long">100</duration>
<numSteps xsi:type="xsd:int">5</numSteps>
<scheduledBy xsi:type="xsd:string" xsi:nil="true"/>
</getFlowRunHistoryByRunIdReturn>
</getFlowRunHistoryByRunIdReturn>
</ns1:getFlowRunHistoryByRunIdResponse>
</soapenv:Body>
</soapenv:Envelope>

1 个答案:

答案 0 :(得分:0)

WSDL类生成的问题及其预期的问题。构建我自己的类来处理它。