WCF消息WriteMessage时提示反序列化错误(在线等)
正在做一个WCF自定义消息编码,继承了MessageEncoder,配置文件已经完成
public override Message ReadMessage(ArraySegment<byte> buffer, BufferManager bufferManager, string contentType)
{
byte[] data = this.compressor.Decompress(buffer.Array);
ArraySegment<byte> bytes = buffer = new ArraySegment<byte>(data);
byte[] totalBytes = bufferManager.TakeBuffer(bytes.Count);
Array.Copy(bytes.Array, 0, totalBytes, 0, bytes.Count);
ArraySegment<byte> byteArray = new ArraySegment<byte>(totalBytes, 0, bytes.Count);
bufferManager.ReturnBuffer(byteArray.Array);
Message msg = innerEncoder.ReadMessage(byteArray, bufferManager, contentType);
return msg;
}
{<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
<s:Header>
<a:Action s:mustUnderstand="1">http://tempuri.org/IService1/GetData</a:Action>
<a:MessageID>urn:uuid:ed9f87a4-e78d-49e4-979e-67cab9e6b593</a:MessageID>
<a:ReplyTo>
<a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
</a:ReplyTo>
<a:To s:mustUnderstand="1">http://localhost:8731/Design_Time_Addresses/Gridsum.Service/Service1/</a:To>
</s:Header>
<s:Body>
<GetData xmlns="http://tempuri.org/">
<value>999</value>
</GetData>
</s:Body>
</s:Envelope>}
{<s:Envelope xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:s="http://www.w3.org/2003/05/soap-envelope">
<s:Header>
<a:Action s:mustUnderstand="1">http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher/fault</a:Action>
<a:RelatesTo>urn:uuid:dd5e4d13-e9b7-4364-bac7-14e35ea0f57e</a:RelatesTo>
</s:Header>
<s:Body>
<s:Fault>
<s:Code>
<s:Value>s:Sender</s:Value>
<s:Subcode>
<s:Value xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher">a:DeserializationFailed</s:Value>
</s:Subcode>
</s:Code>
<s:Reason>
<s:Text xml:lang="zh-CN">格式化程序尝试对消息反序列化时引发异常: 对操作“GetData”的请求消息正文进行反序列化时出现错误。根级别上的数据无效。 第 1 行,位置为 571。</s:Text>
</s:Reason>
</s:Fault>
</s:Body>
</s:Envelope>}