I'm writing console WCF-client for one WCF-WebService. When calling the service I get an error in deserializing body of request:
Error in deserializing body of reply message for operation 'GetProfiles'
Agent Code:
string userLogin = "root", userPassword = "root";
string ipaddress = "192.168.137.164";
HttpTransportBindingElement httpTransportBindingElement = new HttpTransportBindingElement();
httpTransportBindingElement.AuthenticationScheme = AuthenticationSchemes.Digest;
httpTransportBindingElement.KeepAliveEnabled = false;
httpTransportBindingElement.MaxBufferSize = int.MaxValue;
httpTransportBindingElement.MaxBufferPoolSize = int.MaxValue;
httpTransportBindingElement.MaxReceivedMessageSize = int.MaxValue;
TextMessageEncodingBindingElement textMessageEncodingBindingElement = new TextMessageEncodingBindingElement();
textMessageEncodingBindingElement.MaxReadPoolSize = int.MaxValue;
textMessageEncodingBindingElement.MaxWritePoolSize = int.MaxValue;
textMessageEncodingBindingElement.ReaderQuotas.MaxDepth = 64;
textMessageEncodingBindingElement.ReaderQuotas.MaxBytesPerRead = int.MaxValue;
textMessageEncodingBindingElement.ReaderQuotas.MaxArrayLength = int.MaxValue;
textMessageEncodingBindingElement.ReaderQuotas.MaxNameTableCharCount = int.MaxValue;
textMessageEncodingBindingElement.ReaderQuotas.MaxStringContentLength = int.MaxValue;
CustomBinding binding = new CustomBinding(textMessageEncodingBindingElement, httpTransportBindingElement);
EndpointAddress MediaEndPointAddress = new EndpointAddress("http://" + ipaddress + ":80/onvif/services");
MediaClient mediaClient = new MediaClient(binding, MediaEndPointAddress);
mediaClient.ClientCredentials.UserName.UserName = userLogin;
mediaClient.ClientCredentials.UserName.Password = userPassword;
Profile[] profiles = mediaClient.GetProfiles(); // throw excpetion
I have already watched the requests and responses with a sniffer and it's OK! The WebService has sent '200 OK'. If I have a small response from the WebService, there won't be any errors and exceptions! I haven't got WebService code. What should I do?
Stack trace:
<E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent">
<System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system">
<EventID>131075</EventID>
<Type>3</Type>
<SubType Name="Error">0</SubType>
<Level>2</Level>
<TimeCreated SystemTime="2012-01-11T11:11:12.2185609Z" />
<Source Name="System.ServiceModel" />
<Correlation ActivityID="{550193ea-8569-40e6-b794-1a0eed69a1ba}" />
<Execution ProcessName="TestingConsole.vshost" ProcessID="6128" ThreadID="9" />
<Channel />
<Computer>WS-LSH</Computer>
</System>
<ApplicationData>
<TraceData>
<DataItem>
<TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Error">
<TraceIdentifier>http://msdn.microsoft.com/ru-RU/library/System.ServiceModel.Diagnostics.ThrowingException.aspx</TraceIdentifier>
<Description>Throwing an exception.</Description>
<AppDomain>TestingConsole.vshost.exe</AppDomain>
<Exception>
<ExceptionType>System.ServiceModel.CommunicationException, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType>
<Message>Error in deserializing body of reply message for operation 'GetProfiles'. </Message>
<StackTrace>
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)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at TestingConsole.Onvif.Media.Media.GetProfiles(GetProfilesRequest request)
at TestingConsole.Onvif.Media.MediaClient.TestingConsole.Onvif.Media.Media.GetProfiles(GetProfilesRequest request)
at TestingConsole.Onvif.Media.MediaClient.GetProfiles()
at TestingConsole.Program.Main(String[] args)
at System.AppDomain._nExecuteAssembly(RuntimeAssembly 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, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
</StackTrace>
<ExceptionString>System.ServiceModel.CommunicationException: Error in deserializing body of reply message for operation 'GetProfiles'. ---> System.InvalidOperationException: There is an error in XML document (2, 6287). ---> System.Xml.XmlException: The byte 0x03 is not valid at this location. Line 2, position 6287.
at System.Xml.XmlExceptionHelper.ThrowXmlException(XmlDictionaryReader reader, String res, String arg1, String arg2, String arg3)
at System.Xml.XmlExceptionHelper.ThrowInvalidXml(XmlDictionaryReader reader, Byte b)
at System.Xml.XmlUTF8TextReader.Read()
at System.Xml.XmlDictionaryReader.ReadString(Int32 maxStringContentLength)
at System.Xml.XmlDictionaryReader.ReadString()
at System.Xml.XmlBaseReader.ReadElementString()
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderMedia.Read59_VideoSourceConfiguration(Boolean isNullable, Boolean checkType)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderMedia.Read150_Profile(Boolean isNullable, Boolean checkType)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderMedia.Read224_GetProfilesResponse()
at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer73.Deserialize(XmlSerializationReader reader)
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
--- End of inner exception stack trace ---
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)
--- End of inner exception stack trace ---</ExceptionString>
<InnerException>
<ExceptionType>System.InvalidOperationException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType>
<Message>There is an error in XML document (2, 6287).</Message>
<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)
</StackTrace>
<ExceptionString>System.InvalidOperationException: There is an error in XML document (2, 6287). ---> System.Xml.XmlException: The byte 0x03 is not valid at this location. Line 2, position 6287.
at System.Xml.XmlExceptionHelper.ThrowXmlException(XmlDictionaryReader reader, String res, String arg1, String arg2, String arg3)
at System.Xml.XmlExceptionHelper.ThrowInvalidXml(XmlDictionaryReader reader, Byte b)
at System.Xml.XmlUTF8TextReader.Read()
at System.Xml.XmlDictionaryReader.ReadString(Int32 maxStringContentLength)
at System.Xml.XmlDictionaryReader.ReadString()
at System.Xml.XmlBaseReader.ReadElementString()
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderMedia.Read59_VideoSourceConfiguration(Boolean isNullable, Boolean checkType)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderMedia.Read150_Profile(Boolean isNullable, Boolean checkType)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderMedia.Read224_GetProfilesResponse()
at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer73.Deserialize(XmlSerializationReader reader)
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
--- End of inner exception stack trace ---
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)</ExceptionString>
<InnerException>
<ExceptionType>System.Xml.XmlException, System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType>
<Message>The byte 0x03 is not valid at this location. Line 2, position 6287.</Message>
<StackTrace>
at System.Xml.XmlExceptionHelper.ThrowXmlException(XmlDictionaryReader reader, String res, String arg1, String arg2, String arg3)
at System.Xml.XmlExceptionHelper.ThrowInvalidXml(XmlDictionaryReader reader, Byte b)
at System.Xml.XmlUTF8TextReader.Read()
at System.Xml.XmlDictionaryReader.ReadString(Int32 maxStringContentLength)
at System.Xml.XmlDictionaryReader.ReadString()
at System.Xml.XmlBaseReader.ReadElementString()
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderMedia.Read59_VideoSourceConfiguration(Boolean isNullable, Boolean checkType)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderMedia.Read150_Profile(Boolean isNullable, Boolean checkType)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderMedia.Read224_GetProfilesResponse()
at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer73.Deserialize(XmlSerializationReader reader)
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
</StackTrace>
<ExceptionString>System.Xml.XmlException: The byte 0x03 is not valid at this location. Line 2, position 6287.
at System.Xml.XmlExceptionHelper.ThrowXmlException(XmlDictionaryReader reader, String res, String arg1, String arg2, String arg3)
at System.Xml.XmlExceptionHelper.ThrowInvalidXml(XmlDictionaryReader reader, Byte b)
at System.Xml.XmlUTF8TextReader.Read()
at System.Xml.XmlDictionaryReader.ReadString(Int32 maxStringContentLength)
at System.Xml.XmlDictionaryReader.ReadString()
at System.Xml.XmlBaseReader.ReadElementString()
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderMedia.Read59_VideoSourceConfiguration(Boolean isNullable, Boolean checkType)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderMedia.Read150_Profile(Boolean isNullable, Boolean checkType)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderMedia.Read224_GetProfilesResponse()
at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer73.Deserialize(XmlSerializationReader reader)
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)</ExceptionString>
</InnerException>
</InnerException>
</Exception>
</TraceRecord>
</DataItem>
</TraceData>
</ApplicationData>
I rewrite my code. Now I have got:
string soapRequest = "<s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\">" +
"<s:Header>" +
"</s:Header>" +
"<s:Body xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
"<GetProfiles xmlns=\"http://www.onvif.org/ver10/media/wsdl\"/>" +
"</s:Body>" +
"</s:Envelope>";
XmlReader envelopeReader = XmlReader.Create(new StringReader(soapRequest));
Message requestMsg = Message.CreateMessage(envelopeReader, int.MaxValue, MessageVersion.Soap12);
Message responseMsg = null;
IChannelFactory<IRequestChannel> channelFactory = binding.BuildChannelFactory<IRequestChannel>();
channelFactory.Open();
IRequestChannel channel = channelFactory.CreateChannel(MediaEndPointAddress);
channel.Open();
responseMsg = channel.Request(requestMsg);
Console.WriteLine(responseMsg.ToString());
The last string return message "Error reading body: System.Xml.XmlException: '�' contains invalid UTF8 bytes. ...}".
WebService sends non-ut8 bytes, but points "UTF-8" in header.
What can I do?
Reply Message Body
HTTP/1.1 200 OK
Server: gSOAP/2.7
Content-Type: application/soap+xml; charset=utf-8
Content-Length: 11591
Connection: close
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa5="http://www.w3.org/2005/08/addressing" xmlns:xmime5="http://www.w3.org/2005/05/xmlmime" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:ter="http://www.onvif.org/ver10/error" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:c14n="http://www.w3.org/2001/10/xml-exc-c14n#" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:tns1="http://www.onvif.org/ver10/topics" xmlns:ns1="http://www.onvif.org/ver20/analytics/wsdl" xmlns:ns2="http://www.onvif.org/ver10/schema" xmlns:ns3="http://docs.oasis-open.org/wsn/b-2" xmlns:ns4="http://docs.oasis-open.org/wsrf/bf-2" xmlns:ns5="http://docs.oasis-open.org/wsn/t-1" xmlns:ns6="http://www.onvif.org/ver10/device/wsdl" xmlns:ns7="http://www.onvif.org/ver10/events/wsdl" xmlns:ns9="http://docs.oasis-open.org/wsrf/r-2" xmlns:ns10="http://www.onvif.org/ver10/imaging/wsdl" xmlns:ns11="http://www.onvif.org/ver10/media/wsdl" xmlns:ns12="http://www.onvif.org/ver20/ptz/wsdl" xmlns:ns13="http://www.onvif.org/ver10/network/wsdl/" xmlns:ns14="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:ns16="http://www.onvif.org/ver10/analytics/wsdl/RuleEngineBinding" xmlns:ns17="http://www.onvif.org/ver10/analytics/wsdl/AnalyticsEngineBinding" xmlns:ns18="http://www.onvif.org/ver10/events/wsdl/PullPointSubscriptionBinding" xmlns:ns19="http://www.onvif.org/ver10/events/wsdl/EventBinding" xmlns:ns20="http://www.onvif.org/ver10/events/wsdl/SubscriptionManagerBinding" xmlns:ns21="http://www.onvif.org/ver10/events/wsdl/NotificationProducerBinding" xmlns:ns22="http://www.onvif.org/ver10/events/wsdl/NotificationConsumerBinding" xmlns:ns23="http://www.onvif.org/ver10/events/wsdl/PullPointBinding" xmlns:ns24="http://www.onvif.org/ver10/events/wsdl/CreatePullPointBinding" xmlns:ns25="http://www.onvif.org/ver10/events/wsdl/PausableSubscriptionManagerBinding" xmlns:ns26="http://www.onvif.org/ver10/network/wsdl/RemoteDiscoveryBinding" xmlns:ns27="http://www.onvif.org/ver10/network/wsdl/DiscoveryLookupBinding" xmlns:ns28="http://www.onvif.org/ver10/events/wsdl/EventPortType" xmlns:ns29="http://www.3svision.com.tw/2009/event/topics"> <SOAP-ENV:Header></SOAP-ENV:Header><SOAP-ENV:Body><ns11:GetProfilesResponse><ns11:Profiles token="Main_h264" fixed="true"><ns2:Name>Main h264</ns2:Name><ns2:VideoSourceConfiguration token="0"><ns2:Name>user0</ns2:Name><ns2:UseCount>0</ns2:UseCount><ns2:SourceToken>0</ns2:SourceToken><Bounds xmlns="http://www.onvif.org/ver10/schema" height="720" width="1280" y="0" x="0"></Bounds></ns2:VideoSourceConfiguration><ns2:AudioSourceConfiguration token="0"><ns2:Name>user0</ns2:Name><ns2:UseCount>0</ns2:UseCount><ns2:SourceToken>0</ns2:SourceToken></ns2:AudioSourceConfiguration><ns2:VideoEncoderConfiguration token="Main_h264"><ns2:Name>Main h264</ns2:Name><ns2:UseCount>0</ns2:UseCount><ns2:Encoding>H264</ns2:Encoding><ns2:Resolution><ns2:Width>1280</ns2:Width><ns2:Height>720</ns2:Height></ns2:Resolution><ns2:Quality>60</ns2:Quality><ns2:RateControl><ns2:FrameRateLimit>30</ns2:FrameRateLimit><ns2:EncodingInterval>15</ns2:EncodingInterval><ns2:BitrateLimit>3072</ns2:BitrateLimit></ns2:RateControl><ns2:H264><ns2:GovLength>0</ns2:GovLength><ns2:H264Profile>Baseline</ns2:H264Profile></ns2:H264><ns2:Multicast><ns2:Address><ns2:Type>IPv4</ns2:Type><ns2:IPv4Address>0.0.0.0</ns2:IPv4Address></ns2:Address><ns2:Port>0</ns2:Port><ns2:TTL>5</ns2:TTL><ns2:AutoStart>false</ns2:AutoStart></ns2:Multicast><ns2:SessionTimeout>PT0S</ns2:SessionTimeout></ns2:VideoEncoderConfiguration><ns2:AudioEncoderConfiguration token="0"><ns2:Name>user0</ns2:Name><ns2:UseCount>0</ns2:UseCount><ns2:Encoding>G7Ю11</ns2:Encoding><ns2:Bitrate>64000</ns2:Bitrate><ns2:SampleRate>8000</ns2:SampleRate><ns2:Multicast><ns2:Address><ns2:Type>IPv4</ns2:Type><ns2:IPv4Address>0.0.0.0</ns2:IPv4Address></ns2:Address><ns2:Port>0</ns2:Port><ns2:TTL>5</ns2:TTL><ns2:AutoStart>false</ns2:AutoStart></ns2:Multicast><ns2:SessionTimeout>PT0S</ns2:SessionTimeout></ns2:AudioEncoderConfiguration></ns11:Profiles><ns11:Profiles token="Sub_h264" fixed="true"><ns2:Name>Sub h264</ns2:Name><ns2:VideoSourceConfiguration token="1"><ns2:Name>user1</ns2:Name><ns2:UseCount>0</ns2:UseCount><ns2:SourceToken>0</ns2:SourceToken><Bounds xmlns="http://www.onvif.org/ver10/schema" height="720" width="1280" y="0" x="0"></Bounds></ns2:VideoSourceConfiguration><ns2:AudioSourceConfiguration token="0"><ns2:Name>user0</ns2:Name><ns2:UseCount>0</ns2:UseCount><ns2:SourceToken>0</ns2:SourceToken></ns2:AudioSourceConfiguration><ns2:VideoEncoderConfiguration token="Sub_h264"><ns2:Name>Sub h264</ns2:Name><ns2:UseCount>0</ns2:UseCount><ns2:Encoding>H264</ns2:Encoding><ns2:Resolution><ns2:Width>640</ns2:Width><ns2:Height>352</ns2:Height></ns2:Resolution><ns2:Quality>70</ns2:Quality><ns2:RateControl><ns2:FrameRateLimit>30</ns2:FrameRateLimit><ns2:EncodingInterval>15</ns2:EncodingInterval><ns2:BitrateLimit>3072</ns2:BitrateLimit></ns2:RateControl><ns2:H264><ns2:GovLength>0</ns2:GovLength><ns2:H264Profile>Baseline</ns2:H264Profile></ns2:H264><ns2:Multicast><ns2:Address><ns2:Type>IPv4</ns2:Type><ns2:IPv4Address>0.0.0.0</ns2:IPv4Address></ns2:Address><ns2:Port>0</ns2:Port><ns2:TTL>5</ns2:TTL><ns2:AutoStart>false</ns2:AutoStart></ns2:Multicast><ns2:SessionTimeout>PT0S</ns2:SessionTimeout></ns2:VideoEncoderConfiguration><ns2:AudioEncoderConfiguration token="0"><ns2:Name>user0</ns2:Name><ns2:UseCount>0</ns2:UseCount><ns2:Encoding>G711</ns2:Encoding><ns2:Bitrate>64000</ns2:Bitrate><ns2:SampleRate>8000</ns2:SampleRate><ns2:Multicast><ns2:Address><ns2:Type>IPv4</ns2:Type><ns2:IPv4Address>0.0.0.0</ns2:IPv4Address></ns2:Address><ns2:Port>0</ns2:Port><ns2:TTL>5</ns2:TTL><ns2:AutoStart>false</ns2:AutoStart></ns2:Multicast><ns2:SessionTimeout>PT0S</ns2:SessionTimeout></ns2:AudioEncoderConfiguration></ns11:Profiles><ns11:Profiles token="Motion_jpeg" fixed="true"><ns2:Name>Motion jpeg</ns2:Name><ns2:VideoSourceConfiguration token="2"><ns2:Name>user2</ns2:Name><ns2:UseCount>0</ns2:UseCount><ns2:SourceToken>0</ns2:SourceToken><Bounds xmlns="http://www.onvif.org/ver10/schema" height="720" width="1280" y="0" x="0"></Bounds></ns2:VideoSourceConfiguration><ns2:AudioSourceConfiguration token="0"><ns2:Name>user0</ns2:Name><ns2:UseCount>0</ns2:UseCount><ns2:SourceToken>0</ns2:SourceToken></ns2:AudioSourceConfiguration><ns2:VideoEncoderConfiguration token="Motion_jpeg"><ns2:Name>Motion jpeg</ns2:Name><ns2:UseCount>0</ns2:UseCount><ns2:Encoding>JPEG</ns2:Encoding><ns2:Resolution><ns2:Width>1280</ns2:Width><ns2:Height>720</ns2:Height></ns2:Resolution><ns2:QualitЭy>70</ns2:Quality><ns2:RateControl><ns2:FrameRateLimit>15</ns2:FrameRateLimit><ns2:EncodingInterval>15</ns2:EncodingInterval><ns2:BitrateLimit>3072</ns2:BitrateLimit></ns2:RateControl><ns2:Multicast><ns2:Address><ns2:Type>IPv4</ns2:Type><ns2:IPv4Address>0.0.0.0</ns2:IPv4Address></ns2:Address><ns2:Port>0</ns2:Port><ns2:TTL>5</ns2:TTL><ns2:AutoStart>false</ns2:AutoStart></ns2:Multicast><ns2:SessionTimeout>PT0S</ns2:SessionTimeout></ns2:VideoEncoderConfiguration><ns2:AudioEncoderConfiguration token="0"><ns2:Name>user0</ns2:Name><ns2:UseCount>0</ns2:UseCount><ns2:Encoding>G711</ns2:Encoding><ns2:Bitrate>64000</ns2:Bitrate><ns2:SampleRate>8000</ns2:SampleRate><ns2:Multicast><ns2:Address><ns2:Type>IPv4</ns2:Type><ns2:IPv4Address>0.0.0.0</ns2:IPv4Address></ns2:Address><ns2:Port>0</ns2:Port><ns2:TTL>5</ns2:TTL><ns2:AutoStart>false</ns2:AutoStart></ns2:Multicast><ns2:SessionTimeout>PT0S</ns2:SessionTimeout></ns2:AudioEncoderConfiguration></ns11:Profiles><ns11:Profiles token="mc_test" fixed="false"><ns2:Name>mc_test</ns2:Name><ns2:VideoSourceConfiguration token="2"><ns2:Name>Hе</ns2:Name><ns2:UseCount>0</ns2:UseCount><ns2:SourceToken>0</ns2:SourceToken><Bounds xmlns="http://www.onvif.org/ver10/schema" height="720" width="1280" y="0" x="0"></Bounds></ns2:VideoSourceConfiguration><ns2:AudioSourceConfiguration token="0"><ns2:Name>user0</ns2:Name><ns2:UseCount>0</ns2:UseCount><ns2:SourceToken>0</ns2:SourceToken></ns2:AudioSourceConfiguration><ns2:VideoEncoderConfiguration token="Motion_jpeg"><ns2:Name>јч
#јч
#peg</ns2:Name><ns2:UseCount>0</ns2:UseCount><ns2:Encoding>JPEG</ns2:Encoding><ns2:Resolution><ns2:Width>1280</ns2:Width><ns2:Height>720</ns2:Height></ns2:Resolution><ns2:Quality>70</ns2:Quality><ns2:RateControl><ns2:FrameRateLimit>15</ns2:FrameRateLimit><ns2:EncodingInterval>15</ns2:EncodingInterval><ns2:BitrateLimit>3072</ns2:BitrateLimit></ns2:RateControl><ns2:Multicast><ns2:Address><ns2:Type>IPv4</ns2:Type><ns2:IPv4Address>0.0.0.0</ns2:IPv4Address></ns2:Address><ns2:Port>0</ns2:Port><ns2:TTL>5</ns2:TTL><ns2:AutoStart>false</ns2:AutoStart></ns2:Multicast><ns2:SessionTimeout>PT0S</ns2:SessionTimeout></ns2:VideoEncoderConfiguration><ns2:AudioEncoderConfiguration token="0"><ns2:Name>user0</ns2:Name><ns2:UseCount>0</ns2:UseCount><ns2:Encoding>G711</ns2:Encoding><ns2:Bitrate>64000</ns2:Bitrate><ns2:SampleRate>8000</ns2:SampleRate><ns2:Multicast><ns2:Address><ns2:Type>IPv4</ns2:Type><ns2:IPv4Address>0.0.0.0</ns2:IPv4Address></ns2:Address><ns2:Port>0</ns2:Port><ns2:TTL>5</ns2:TTL><ns2:AutoStart>false</ns2:AutoStart></ns2:Multicast><ns2:SessionTimeout>PT0S</ns2:SessionTimeout></ns2:AudioEncoderConfiguration></ns11:Profiles><ns11:Profiles token="MACROSCOP" fixed="false"><ns2:Name>MACROSCOP</ns2:Name><ns2:VideoSourceConfiguration token="2"><ns2:Name>Hе</ns2:Name><ns2:UseCount>0</ns2:UseCount><ns2:SourceToken>0</ns2:SourceToken><Bounds xmlns="http://www.onvif.org/ver10/schema" heightЮ="720" width="1280" y="0" x="0"></Bounds></ns2:VideoSourceConfiguration><ns2:AudioSourceConfiguration token="0"><ns2:Name>user0</ns2:Name><ns2:UseCount>0</ns2:UseCount><ns2:SourceToken>0</ns2:SourceToken></ns2:AudioSourceConfiguration><ns2:VideoEncoderConfiguration token="Motion_jpeg"><ns2:Name>јч
#јч
#peg</ns2:Name><ns2:UseCount>0</ns2:UseCount><ns2:Encoding>JPEG</ns2:Encoding><ns2:Resolution><ns2:Width>1280</ns2:Width><ns2:Height>720</ns2:Height></ns2:Resolution><ns2:Quality>70</ns2:Quality><ns2:RateControl><ns2:FrameRateLimit>15</ns2:FrameRateLimit><ns2:EncodingInterval>15</ns2:EncodingInterval><ns2:BitrateLimit>3072</ns2:BitrateLimit></ns2:RateControl><ns2:Multicast><ns2:Address><ns2:Type>IPv4</ns2:Type><ns2:IPv4Address>0.0.0.0</ns2:IPv4Address></ns2:Address><ns2:Port>0</ns2:Port><ns2:TTL>5</ns2:TTL><ns2:AutoStart>false</ns2:AutoStart></ns2:Multicast><ns2:SessionTimeout>PT0S</ns2:SessionTimeout></ns2:VideoEncoderConfiguration><ns2:AudioEncoderConfiguration token="0"><ns2:Name>user0</ns2:Name><ns2:UseCount>0</ns2:UseCount><ns2:Encoding>G711</ns2:Encoding><ns2:Bitrate>64000</ns2:Bitrate><ns2:SampleRate>8000</ns2:SampleRate><ns2:Multicast><ns2:Address><ns2:Type>IPv4</ns2:Type><ns2:IPv4Address>0.0.0.0</ns2:IPv4Address></ns2:Address><ns2:Port>0</ns2:Port><ns2:TTL>5</ns2:TTL><ns2:AutoStart>false</ns2:AutoStart></ns2:Multicast><ns2:SessionTimeout>PT0S</ns2:SessionTimeout></ns2:AudioEncoderConfiguration></ns11:Profiles></ns11:GetProfilesResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
At first, if Profile class is yourth, check the contract of your Profile object - maybe it hasn't well-configured DataContract attributes. If you have dll with Profile class, provided by the service owner, maybe it is of wrong version. YOu can try enabling WCF trace and compare caught XML with contract of Profile object (use dotPeek or any other decompiler to get class code from dll)
If the response from the web serivce is 200 OK in your sniffer and is failing in your client with the above exception then its worth trying to update your proxy. There might be a situation that the wsdl has changed and the response object being recieved is not in teh expected format on your client side
Related
I try to run this tutorial: custom-asp-net-core-middleware-example
But the reponse message at the client say´s:
S
ystem.ServiceModel.ProtocolException: There is a problem with the XML that was received from the network. See inner exception for more details.
---> System.Xml.XmlException: Name cannot begin with the '/' character, hexadecimal value 0x2F. Line 1, position 74.
at System.Xml.XmlExceptionHelper.ThrowXmlException(XmlDictionaryReader reader, XmlException exception)
at System.Xml.XmlUTF8TextReader.VerifyNCName(String s)
at System.Xml.XmlUTF8TextReader.ReadQualifiedName(PrefixHandle prefix, StringHandle localName)
at System.Xml.XmlUTF8TextReader.ReadStartElement()
at System.Xml.XmlUTF8TextReader.Read()
at System.ServiceModel.Channels.Message.ReadStartBody(XmlDictionaryReader reader, EnvelopeVersion envelopeVersion, Boolean& isFault, Boolean& isEmpty)
at System.ServiceModel.Channels.ReceivedMessage.ReadStartBody(XmlDictionaryReader reader)
at System.ServiceModel.Channels.BufferedMessage..ctor(IBufferedMessageData messageData, RecycledMessageState recycledMessageState, Boolean[] understoodHeaders, Boolean understoodHeadersModified)
at System.ServiceModel.Channels.BufferedMessage..ctor(IBufferedMessageData messageData, RecycledMessageState recycledMessageState)
at System.ServiceModel.Channels.TextMessageEncoderFactory.TextMessageEncoder.ReadMessage(ArraySegment`1 buffer, BufferManager bufferManager, String contentType)
at System.ServiceModel.Channels.MessageEncoder.ReadMessageAsync(Stream stream, BufferManager bufferManager, Int32 maxBufferSize, String contentType, CancellationToken cancellationToken)
at System.ServiceModel.Channels.HttpResponseMessageHelper.ReadChunkedBufferedMessageAsync(Task`1 inputStreamTask, TimeoutHelper timeoutHelper)
--- End of inner exception stack trace ---
at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)
at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result)
at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
at System.ServiceModel.Channels.ServiceChannelProxy.TaskCreator.<>c__DisplayClass1_0.<CreateGenericTask>b__0(IAsyncResult asyncResult)
I´ve also encounterd a problem with the request-message so I´ve written my own RequestMessage but I´m not sure whether I should write my own ResponseMessage, because I do not know how it should be.
Also I´ve changed the OperationDescription to fit the tutorials code, may there be the problem?
public OperationDescription(ContractDescription contract, MethodInfo operationMethod, OperationContractAttribute contractAttribute)
{
Contract = contract;
SoapAction = contractAttribute.Name ?? operationMethod.Name;
Name = contractAttribute.Action ?? $"{contract.Namespace.TrimEnd('/')}/{contract.Name}/{Name}".Trim('/');
IsOneWay = contractAttribute.IsOneWay;
ReplyAction = contractAttribute.ReplyAction;
DispatchMethod = operationMethod;
}
We got a weird error and can't make heads or tails of it, as it is one of a gazillion of serialized calls we do every day without issues for years. Here is the google translation into English of that error message, so the real English message may be worded differently:
System.ServiceModel.Dispatcher.NetDispatcherFaultException: An error
occurred while trying to deserialize the message parameter
http://tempuri.org/: ExecuteResult. InnerException message 'Internal
error occurred. Cache overflow in DataContract. ' was. See
InnerException for details. An exception was thrown from the formatter
when attempting to deserialize - ->
System.Runtime.Serialization.SerializationException: An internal error
occurred. Cache overflow in DataContract.
And this is the full stack trace, including the original Japanese message:
System.ServiceModel.Dispatcher.NetDispatcherFaultException: メッセージ パラメーター http://tempuri.org/:ExecuteResult をシリアル化解除しようとしているときにエラーが発生しました。InnerException メッセージは '内部エラーが発生しました。DataContract のキャッシュ オーバーフローです。' でした。詳細については InnerException を参照してください。 のシリアル化を解除しようとしているときに、フォーマッタから例外がスローされました ---> System.Runtime.Serialization.SerializationException: 内部エラーが発生しました。DataContract のキャッシュ オーバーフローです。
場所 System.Runtime.Serialization.DataContract.DataContractCriticalHelper.GetIdForInitialization(ClassDataContract classContract)
場所 System.Runtime.Serialization.XmlFormatReaderGenerator.CriticalHelper.CreateObject(ClassDataContract classContract)
場所 System.Runtime.Serialization.XmlFormatReaderGenerator.CriticalHelper.GenerateClassReader(ClassDataContract classContract)
場所 System.Runtime.Serialization.XmlFormatReaderGenerator.GenerateClassReader(ClassDataContract classContract)
場所 System.Runtime.Serialization.ClassDataContract.get_XmlFormatReaderDelegate()
場所 System.Runtime.Serialization.ClassDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)
場所 System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserializeInSharedTypeMode(XmlReaderDelegator xmlReader, Int32 declaredTypeID, Type declaredType, String name, String ns)
場所 ReadPFromXml(XmlReaderDelegator , XmlObjectSerializerReadContext , XmlDictionaryString[] , XmlDictionaryString[] )
場所 System.Runtime.Serialization.ClassDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)
場所 System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserializeInSharedTypeMode(XmlReaderDelegator xmlReader, Int32 declaredTypeID, Type declaredType, String name, String ns)
場所 ReadAOPFromXml(XmlReaderDelegator , XmlObjectSerializerReadContext , XmlDictionaryString , XmlDictionaryString , CollectionDataContract )
場所 System.Runtime.Serialization.CollectionDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)
場所 System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserializeInSharedTypeMode(XmlReaderDelegator xmlReader, Int32 declaredTypeID, Type declaredType, String name, String ns)
場所 ReadAOPFromXml(XmlReaderDelegator , XmlObjectSerializerReadContext , XmlDictionaryString[] , XmlDictionaryString[] )
場所 System.Runtime.Serialization.ClassDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)
場所 System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserializeInSharedTypeMode(XmlReaderDelegator xmlReader, Int32 declaredTypeID, Type declaredType, String name, String ns)
場所 ReadOFromXml(XmlReaderDelegator , XmlObjectSerializerReadContext , XmlDictionaryString[] , XmlDictionaryString[] )
場所 System.Runtime.Serialization.ClassDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)
場所 System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserializeInSharedTypeMode(XmlReaderDelegator xmlReader, Int32 declaredTypeID, Type declaredType, String name, String ns)
場所 ReadODFromXml(XmlReaderDelegator , XmlObjectSerializerReadContext , XmlDictionaryString[] , XmlDictionaryString[] )
場所 System.Runtime.Serialization.ClassDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)
場所 System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserializeInSharedTypeMode(XmlReaderDelegator xmlReader, Int32 declaredTypeID, Type declaredType, String name, String ns)
場所 ReadORFromXml(XmlReaderDelegator , XmlObjectSerializerReadContext , XmlDictionaryString[] , XmlDictionaryString[] )
場所 System.Runtime.Serialization.ClassDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)
場所 System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserializeInSharedTypeMode(XmlReaderDelegator xmlReader, Int32 declaredTypeID, Type declaredType, String name, String ns)
場所 System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserialize(XmlReaderDelegator xmlReader, Type declaredType, String name, String ns)
場所 System.Runtime.Serialization.NetDataContractSerializer.InternalReadObject(XmlReaderDelegator xmlReader, Boolean verifyObjectName)
場所 System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)
場所 System.Runtime.Serialization.NetDataContractSerializer.ReadObject(XmlDictionaryReader reader, Boolean verifyObjectName)
場所 System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.PartInfo.ReadObject(XmlDictionaryReader reader, XmlObjectSerializer serializer)
場所 System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeParameterPart(XmlDictionaryReader reader, PartInfo part, Boolean isRequest)
--- 内部例外スタック トレースの終わり ---
Server stack trace:
場所 System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeParameterPart(XmlDictionaryReader reader, PartInfo part, Boolean isRequest)
場所 System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeBody(XmlDictionaryReader reader, MessageVersion version, String action, MessageDescription messageDescription, Object[] parameters, Boolean isRequest)
場所 System.ServiceModel.Dispatcher.OperationFormatter.DeserializeBodyContents(Message message, Object[] parameters, Boolean isRequest)
場所 System.ServiceModel.Dispatcher.OperationFormatter.DeserializeReply(Message message, Object[] parameters)
場所 System.ServiceModel.Dispatcher.ProxyOperationRuntime.AfterReply(ProxyRpc& rpc)
場所 System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
場所 System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
場所 System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
場所 System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
場所 System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
場所 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
...
What causes it, and how can it be prevented?
N.B. Looking at the source code, such an error is thrown in here.
In my webservice, I'm not able to receive the following Soap Request.
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:sila="http://sila.coop">
<SOAP-ENV:Body>
<ResponseEvent
xmlns="http://sila.coop">
<requestId>10</requestId>
<returnValue>
<returnCode>3</returnCode>
<message>command 'Reset' completed successfully</message>
<duration>PT0S</duration>
<deviceClass>8</deviceClass>
</returnValue>
<responseData><?xml version="1.0" encoding="utf-8"?><ResponseData
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sila.coop//schemata/ResponseType_1.2.xsd"></ResponseData>
</responseData>
</ResponseEvent>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Evertime I receive this Request, I get a http error 400 "Bad Request". The trace File looks the follwoing:
<E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent">
<System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system">
<EventID>131075</EventID>
<Type>3</Type>
<SubType Name="Error">0</SubType>
<Level>2</Level>
<TimeCreated SystemTime="2018-10-10T11:58:52.8850097Z" />
<Source Name="System.ServiceModel" />
<Correlation ActivityID="{62cc4254-c741-40d2-8453-8353edd65d1b}" />
<Execution ProcessName="EventReceiver.vshost" ProcessID="34400" ThreadID="17" />
<Channel />
<Computer>DELSB-3TWBR72</Computer>
</System>
<ApplicationData>
<TraceData>
<DataItem>
<TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Error">
<TraceIdentifier>http://msdn.microsoft.com/de-DE/library/System.ServiceModel.Diagnostics.ThrowingException.aspx</TraceIdentifier>
<Description>Eine Ausnahme wird ausgelöst.</Description>
<AppDomain>EventReceiver.vshost.exe</AppDomain>
<Exception>
<ExceptionType>System.ServiceModel.ProtocolException, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType>
<Message>Es ist ein Problem mit der vom Netzwerk empfangenen XML aufgetreten. Weitere Informationen finden Sie in der inneren Ausnahme.</Message>
<StackTrace>
bei System.ServiceModel.Channels.HttpInput.DecodeBufferedMessage(ArraySegment`1 buffer, Stream inputStream)
bei System.ServiceModel.Channels.HttpInput.ParseMessageAsyncResult.ContinueReading(Int32 bytesRead)
bei System.ServiceModel.Channels.HttpInput.ParseMessageAsyncResult.DecodeBufferedMessageAsync()
bei System.ServiceModel.Channels.HttpInput.ParseMessageAsyncResult.BeginParse()
bei System.ServiceModel.Channels.HttpInput.BeginParseIncomingMessage(HttpRequestMessage httpRequestMessage, AsyncCallback callback, Object state)
bei System.ServiceModel.Channels.HttpPipeline.EmptyHttpPipeline.BeginParseIncomingMessage(AsyncCallback asynCallback, Object state)
bei System.ServiceModel.Channels.HttpPipeline.EnqueueMessageAsyncResult..ctor(ReplyChannelAcceptor acceptor, Action dequeuedCallback, HttpPipeline pipeline, AsyncCallback callback, Object state)
bei System.ServiceModel.Channels.HttpPipeline.EmptyHttpPipeline.BeginProcessInboundRequest(ReplyChannelAcceptor replyChannelAcceptor, Action dequeuedCallback, AsyncCallback callback, Object state)
bei System.ServiceModel.Channels.HttpChannelListener`1.HttpContextReceivedAsyncResult`1.ProcessHttpContextAsync()
bei System.ServiceModel.Channels.HttpChannelListener`1.BeginHttpContextReceived(HttpRequestContext context, Action acceptorCallback, AsyncCallback callback, Object state)
bei System.ServiceModel.Channels.SharedHttpTransportManager.EnqueueContext(IAsyncResult listenerContextResult)
bei System.ServiceModel.Channels.SharedHttpTransportManager.OnGetContextCore(IAsyncResult listenerContextResult)
bei System.ServiceModel.Channels.SharedHttpTransportManager.OnGetContext(IAsyncResult result)
bei System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult result)
bei System.Net.LazyAsyncResult.Complete(IntPtr userToken)
bei System.Net.LazyAsyncResult.ProtectedInvokeCallback(Object result, IntPtr userToken)
bei System.Net.ListenerAsyncResult.IOCompleted(ListenerAsyncResult asyncResult, UInt32 errorCode, UInt32 numBytes)
bei System.Net.ListenerAsyncResult.WaitCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
bei System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
</StackTrace>
<ExceptionString>System.ServiceModel.ProtocolException: Es ist ein Problem mit der vom Netzwerk empfangenen XML aufgetreten. Weitere Informationen finden Sie in der inneren Ausnahme. ---> System.Xml.XmlException: Die Daten auf der obersten Ebene sind ungültig. Zeile 1, Position 1.
bei System.Xml.XmlExceptionHelper.ThrowXmlException(XmlDictionaryReader reader, String res, String arg1, String arg2, String arg3)
bei System.Xml.XmlUTF8TextReader.Read()
bei System.Xml.XmlBaseReader.IsStartElement()
bei System.Xml.XmlBaseReader.IsStartElement(XmlDictionaryString localName, XmlDictionaryString namespaceUri)
bei System.ServiceModel.Channels.ReceivedMessage.ReadStartEnvelope(XmlDictionaryReader reader)
bei System.ServiceModel.Channels.BufferedMessage..ctor(IBufferedMessageData messageData, RecycledMessageState recycledMessageState, Boolean[] understoodHeaders, Boolean understoodHeadersModified)
bei System.ServiceModel.Channels.TextMessageEncoderFactory.TextMessageEncoder.ReadMessage(ArraySegment`1 buffer, BufferManager bufferManager, String contentType)
bei System.ServiceModel.Channels.HttpInput.DecodeBufferedMessage(ArraySegment`1 buffer, Stream inputStream)
--- Ende der internen Ausnahmestapelüberwachung ---</ExceptionString>
<InnerException>
<ExceptionType>System.Xml.XmlException, System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType>
<Message>Die Daten auf der obersten Ebene sind ungültig. Zeile 1, Position 1.</Message>
<StackTrace>
bei System.Xml.XmlExceptionHelper.ThrowXmlException(XmlDictionaryReader reader, String res, String arg1, String arg2, String arg3)
bei System.Xml.XmlUTF8TextReader.Read()
bei System.Xml.XmlBaseReader.IsStartElement()
bei System.Xml.XmlBaseReader.IsStartElement(XmlDictionaryString localName, XmlDictionaryString namespaceUri)
bei System.ServiceModel.Channels.ReceivedMessage.ReadStartEnvelope(XmlDictionaryReader reader)
bei System.ServiceModel.Channels.BufferedMessage..ctor(IBufferedMessageData messageData, RecycledMessageState recycledMessageState, Boolean[] understoodHeaders, Boolean understoodHeadersModified)
bei System.ServiceModel.Channels.TextMessageEncoderFactory.TextMessageEncoder.ReadMessage(ArraySegment`1 buffer, BufferManager bufferManager, String contentType)
bei System.ServiceModel.Channels.HttpInput.DecodeBufferedMessage(ArraySegment`1 buffer, Stream inputStream)
</StackTrace>
<ExceptionString>System.Xml.XmlException: Die Daten auf der obersten Ebene sind ungültig. Zeile 1, Position 1.
bei System.Xml.XmlExceptionHelper.ThrowXmlException(XmlDictionaryReader reader, String res, String arg1, String arg2, String arg3)
bei System.Xml.XmlUTF8TextReader.Read()
bei System.Xml.XmlBaseReader.IsStartElement()
bei System.Xml.XmlBaseReader.IsStartElement(XmlDictionaryString localName, XmlDictionaryString namespaceUri)
bei System.ServiceModel.Channels.ReceivedMessage.ReadStartEnvelope(XmlDictionaryReader reader)
bei System.ServiceModel.Channels.BufferedMessage..ctor(IBufferedMessageData messageData, RecycledMessageState recycledMessageState, Boolean[] understoodHeaders, Boolean understoodHeadersModified)
bei System.ServiceModel.Channels.TextMessageEncoderFactory.TextMessageEncoder.ReadMessage(ArraySegment`1 buffer, BufferManager bufferManager, String contentType)
bei System.ServiceModel.Channels.HttpInput.DecodeBufferedMessage(ArraySegment`1 buffer, Stream inputStream)</ExceptionString>
</InnerException>
</Exception>
</TraceRecord>
</DataItem>
</TraceData>
</ApplicationData>
</E2ETraceEvent>
I'm already tried to implement a Custom Behavior with IDispatchMessageInspector, but even there I'm not able to receive the request. It gets already rejected on the Web Service listener I think. What is wrong with this XML Request? How can I handle it in my Web Service? Unfortunately I'm not able to change the client code.
I've been at this for days now and I just do not understand why this error is occurring. It's a FileLoadException for log4net v1.2.10.0, but it occurs during a XRM SDK linq query. I use log4net v1.2.12.0 in the application, and I expected a bindingRedirect to fix this but it doesn't. (The v1.2.10.0 log4net is required by a library that I use)
It looks like the XRM sdk somehow tries to serialize/deserialize assemblies. I'm not sure why it does this, I reckon the post may be relevant.
Inner Exception is null
Exception Message:
Could not load file or assembly 'log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821' or one of its dependencies.
The located assembly's manifest definition does not match the assembly reference.
(Exception from HRESULT: 0x80131040)":"log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821
Server stack trace:
at System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type)
at System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType)
at System.Reflection.RuntimeAssembly.GetCustomAttributes(Type attributeType, Boolean inherit)
at Microsoft.Xrm.Sdk.KnownTypesProvider.GetProxyTypesAttribute(Assembly assembly)
at Microsoft.Xrm.Sdk.KnownTypesProvider.RegisterAssembly(Assembly assembly)
at Microsoft.Xrm.Sdk.KnownTypesProvider.get_KnownAssemblies()
at Microsoft.Xrm.Sdk.KnownTypesProvider.get_KnownOrganizationRequestResponseTypes()
at Microsoft.Xrm.Sdk.KnownTypesResolver.ResolveName(String typeName, String typeNamespace, Type declaredType, DataContractResolver knownTypeResolver)
at System.Runtime.Serialization.XmlObjectSerializerContext.ResolveDataContractFromDataContractResolver(XmlQualifiedName typeName, Type declaredType)
at System.Runtime.Serialization.XmlObjectSerializerContext.ResolveDataContractFromKnownTypes(String typeName, String typeNs, DataContract memberTypeContract, Type declaredType)
at System.Runtime.Serialization.XmlObjectSerializerContext.IsKnownType(DataContract dataContract, Type declaredType)
at System.Runtime.Serialization.XmlObjectSerializerContext.IsKnownType(DataContract dataContract, Dictionary`2 knownDataContracts, Type declaredType)
at System.Runtime.Serialization.KnownTypeDataContractResolver.TryResolveType(Type type, Type declaredType, DataContractResolver knownTypeResolver, XmlDictionaryString& typeName, XmlDictionaryString& typeNamespace)
at Microsoft.Xrm.Sdk.KnownTypesResolver.TryResolveType(Type type, Type declaredType, DataContractResolver knownTypeResolver, XmlDictionaryString& typeName, XmlDictionaryString& typeNamespace)
at System.Runtime.Serialization.XmlObjectSerializerWriteContext.ResolveType(Type objectType, Type declaredType, XmlDictionaryString& typeName, XmlDictionaryString& typeNamespace)
at System.Runtime.Serialization.XmlObjectSerializerWriteContext.WriteResolvedTypeInfo(XmlWriterDelegator writer, Type objectType, Type declaredType)
at System.Runtime.Serialization.XmlObjectSerializerWriteContext.WriteTypeInfo(XmlWriterDelegator writer, DataContract contract, DataContract declaredContract)
at System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeWithXsiTypeAtTopLevel(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle originalDeclaredTypeHandle, Type graphType)
at System.Runtime.Serialization.DataContractSerializer.InternalWriteObjectContent(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver)
at System.Runtime.Serialization.DataContractSerializer.InternalWriteObject(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver)
at System.Runtime.Serialization.XmlObjectSerializer.WriteObjectHandleExceptions(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver)
at System.Runtime.Serialization.XmlObjectSerializer.WriteObject(XmlDictionaryWriter writer, Object graph)
at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.SerializeParameterPart(XmlDictionaryWriter writer, PartInfo part, Object graph)
at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.SerializeParameter(XmlDictionaryWriter writer, PartInfo part, Object graph)
at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.SerializeParameters(XmlDictionaryWriter writer, PartInfo[] parts, Object[] parameters)
at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.SerializeBody(XmlDictionaryWriter writer, MessageVersion version, String action, MessageDescription messageDescription, Object returnValue, Object[] parameters, Boolean isRequest)
at System.ServiceModel.Dispatcher.OperationFormatter.SerializeBodyContents(XmlDictionaryWriter writer, MessageVersion version, Object[] parameters, Object returnValue, Boolean isRequest)
at System.ServiceModel.Dispatcher.OperationFormatter.OperationFormatterMessage.OperationFormatterBodyWriter.OnWriteBodyContents(XmlDictionaryWriter writer)
at System.ServiceModel.Channels.BodyWriterMessage.OnWriteBodyContents(XmlDictionaryWriter writer)
at System.ServiceModel.Security.SecurityAppliedMessage.OnWriteBodyContents(XmlDictionaryWriter writer)
at System.ServiceModel.Security.SecurityAppliedMessage.OnWriteMessage(XmlDictionaryWriter writer)
at System.ServiceModel.Channels.BufferedMessageWriter.WriteMessage(Message message, BufferManager bufferManager, Int32 initialOffset, Int32 maxSizeQuota)
at System.ServiceModel.Channels.TextMessageEncoderFactory.TextMessageEncoder.WriteMessage(Message message, Int32 maxMessageSize, BufferManager bufferManager, Int32 messageOffset)
at System.ServiceModel.Channels.HttpOutput.SerializeBufferedMessage(Message message)
at System.ServiceModel.Channels.HttpOutput.Send(TimeSpan timeout)
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.SendRequest(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.SecurityChannelFactory`1.SecurityRequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
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 Microsoft.Xrm.Sdk.IOrganizationService.Execute(OrganizationRequest request)
at Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.ExecuteCore(OrganizationRequest request)
at Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.Execute(OrganizationRequest request)
at Microsoft.Xrm.Sdk.Client.OrganizationServiceContext.Execute(OrganizationRequest request)
at Microsoft.Xrm.Sdk.Linq.QueryProvider.RetrieveEntityCollection(OrganizationRequest request, NavigationSource source)
at Microsoft.Xrm.Sdk.Linq.QueryProvider.Execute(QueryExpression qe, Boolean throwIfSequenceIsEmpty, Boolean throwIfSequenceNotSingle, Projection projection, NavigationSource source, List`1 linkLookups, String& pagingCookie, Boolean& moreRecords)
at Microsoft.Xrm.Sdk.Linq.QueryProvider.Execute[TElement](QueryExpression qe, Boolean throwIfSequenceIsEmpty, Boolean throwIfSequenceNotSingle, Projection projection, NavigationSource source, List`1 linkLookups)
at Microsoft.Xrm.Sdk.Linq.QueryProvider.Execute[TElement](Expression expression)
at Microsoft.Xrm.Sdk.Linq.QueryProvider.GetEnumerator[TElement](Expression expression)
at Microsoft.Xrm.Sdk.Linq.Query`1.GetEnumerator()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at ClassLibrary.Class1.Method1() in C:\Users\Greg.tarr\Documents\Visual Studio 2010\Projects\RestService\ClassLibrary\Class1.cs:line 36
This is possibly caused by an incorrect / outdated reference to log4net in the project (when using an updated version), references are compiled into the assembly and a load is then attempted. Taken from here
Also make sure your PublicKeyToken is correct.
If you've updated through NuGet the token can be incorrect / not update ... as per this SO post
My WCF Service Contract method is simply defined as below:
DataTable BulkEncrypt(DataTable SSNTable);
However, I am passing a typed datatable from my client, and I get the following exception in my client:
System.ServiceModel.CommunicationException was unhandled
Message=There was an error while trying to serialize parameter http://tempuri.org/:SSNDataTable. The InnerException message was 'Type 'SSNClientApp.PersonnelDataSets+SSNTableDataTable' with data contract name 'PersonnelDataSets.SSNTableDataTable:http://schemas.datacontract.org/2004/07/SSNClientApp' is not expected. Consider using a DataContractResolver or add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.'. Please see InnerException for more details.
Source=mscorlib
StackTrace:
Server stack trace:
at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.SerializeParameterPart(XmlDictionaryWriter writer, PartInfo part, Object graph)
at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.SerializeParameter(XmlDictionaryWriter writer, PartInfo part, Object graph)
at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.SerializeParameters(XmlDictionaryWriter writer, PartInfo[] parts, Object[] parameters)
at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.SerializeBody(XmlDictionaryWriter writer, MessageVersion version, String action, MessageDescription messageDescription, Object returnValue, Object[] parameters, Boolean isRequest)
at System.ServiceModel.Dispatcher.OperationFormatter.SerializeBodyContents(XmlDictionaryWriter writer, MessageVersion version, Object[] parameters, Object returnValue, Boolean isRequest)
at System.ServiceModel.Dispatcher.OperationFormatter.OperationFormatterMessage.OperationFormatterBodyWriter.OnWriteBodyContents(XmlDictionaryWriter writer)
at System.ServiceModel.Channels.BodyWriter.WriteBodyContents(XmlDictionaryWriter writer)
at System.ServiceModel.Channels.BodyWriterMessage.OnWriteBodyContents(XmlDictionaryWriter writer)
at System.ServiceModel.Channels.Message.OnWriteMessage(XmlDictionaryWriter writer)
at System.ServiceModel.Channels.Message.WriteMessage(XmlDictionaryWriter writer)
at System.ServiceModel.Channels.BufferedMessageWriter.WriteMessage(Message message, BufferManager bufferManager, Int32 initialOffset, Int32 maxSizeQuota)
at System.ServiceModel.Channels.TextMessageEncoderFactory.TextMessageEncoder.WriteMessage(Message message, Int32 maxMessageSize, BufferManager bufferManager, Int32 messageOffset)
at System.ServiceModel.Channels.MessageEncoder.WriteMessage(Message message, Int32 maxMessageSize, BufferManager bufferManager)
at System.ServiceModel.Channels.HttpOutput.SerializeBufferedMessage(Message message)
at System.ServiceModel.Channels.HttpOutput.Send(TimeSpan timeout)
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.SendRequest(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
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 SSNClientApp.SSNCryptoSvc.ICryptoService.BulkEncryptSSN(DataTable SSNDataTable)
at SSNClientApp.SSNCryptoSvc.CryptoServiceClient.BulkEncryptSSN(DataTable SSNDataTable) in c:\documents and settings\ajayapal01\my documents\visual studio 2010\Projects\DisconnectedDemo\SSNClientApp\Service References\SSNCryptoSvc\Reference.cs:line 50
at SSNClientApp.Program.Main(String[] args) in c:\documents and settings\ajayapal01\my documents\visual studio 2010\Projects\DisconnectedDemo\SSNClientApp\Program.cs:line 18
at System.AppDomain._nExecuteAssembly(RuntimeAssembly 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, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: System.Runtime.Serialization.SerializationException
Message=Type 'SSNClientApp.PersonnelDataSets+SSNTableDataTable' with data contract name 'PersonnelDataSets.SSNTableDataTable:http://schemas.datacontract.org/2004/07/SSNClientApp' is not expected. Consider using a DataContractResolver or add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.
Source=System.Runtime.Serialization
StackTrace:
at System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeAndVerifyType(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, Boolean verifyKnownType, RuntimeTypeHandle declaredTypeHandle, Type declaredType)
at System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeWithXsiTypeAtTopLevel(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle originalDeclaredTypeHandle, Type graphType)
at System.Runtime.Serialization.DataContractSerializer.InternalWriteObjectContent(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver)
at System.Runtime.Serialization.DataContractSerializer.InternalWriteObject(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver)
at System.Runtime.Serialization.XmlObjectSerializer.WriteObjectHandleExceptions(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver)
at System.Runtime.Serialization.XmlObjectSerializer.WriteObject(XmlDictionaryWriter writer, Object graph)
at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.SerializeParameterPart(XmlDictionaryWriter writer, PartInfo part, Object graph)
InnerException:
Here is the code calling the wcf service from client:
CryptoServiceClient client = new CryptoServiceClient();
SSNTableTableAdapter adater = new SSNTableTableAdapter();
PersonnelDataSets.SSNTableDataTable ssntable = adater.GetData();
ssntable = client.BulkEncryptSSN(ssntable.DefaultView.Table) as PersonnelDataSets.SSNTableDataTable;