static private DeserializeSoapResponseMessage ( Stream inputStream, IMessage requestMsg, |
||
inputStream | Stream | |
requestMsg | IMessage | |
h | ||
bStrictBinding | bool | |
return | IMessage |
private IMessage DeserializeMessage(IMethodCallMessage mcm, ITransportHeaders headers, Stream stream) { IMessage message; string str2; string str3; Header[] h = new Header[] { new Header("__TypeName", mcm.TypeName), new Header("__MethodName", mcm.MethodName), new Header("__MethodSignature", mcm.MethodSignature) }; string contentType = headers["Content-Type"] as string; HttpChannelHelper.ParseContentType(contentType, out str2, out str3); if (string.Compare(str2, "text/xml", StringComparison.Ordinal) == 0) { message = CoreChannel.DeserializeSoapResponseMessage(stream, mcm, h, this._strictBinding); } else { int count = 0x400; byte[] buffer = new byte[count]; StringBuilder builder = new StringBuilder(); for (int i = stream.Read(buffer, 0, count); i > 0; i = stream.Read(buffer, 0, count)) { builder.Append(Encoding.ASCII.GetString(buffer, 0, i)); } message = new ReturnMessage(new RemotingException(builder.ToString()), mcm); } stream.Close(); return(message); }
} // SerializeMessage // helper function to deserialize the message private IMessage DeserializeMessage(IMethodCallMessage mcm, ITransportHeaders headers, Stream stream) { IMessage retMsg; Header[] h = new Header[3]; h[0] = new Header("__TypeName", mcm.TypeName); h[1] = new Header("__MethodName", mcm.MethodName); h[2] = new Header("__MethodSignature", mcm.MethodSignature); String contentTypeHeader = headers["Content-Type"] as String; String contentTypeValue, charsetValue; HttpChannelHelper.ParseContentType(contentTypeHeader, out contentTypeValue, out charsetValue); if (String.Compare(contentTypeValue, CoreChannel.SOAPMimeType, false, CultureInfo.InvariantCulture) == 0) { // deserialize the message retMsg = CoreChannel.DeserializeSoapResponseMessage(stream, mcm, h, _strictBinding); } else { // an error has occurred int bufferSize = 1024; byte[] buffer = new byte[bufferSize]; StringBuilder sb = new StringBuilder(); int readCount = stream.Read(buffer, 0, bufferSize); while (readCount > 0) { sb.Append(Encoding.ASCII.GetString(buffer, 0, readCount)); readCount = stream.Read(buffer, 0, bufferSize); } retMsg = new ReturnMessage(new RemotingException(sb.ToString()), mcm); } // Close the stream since we're done with it (especially important if this // happened to be a network stream) stream.Close(); return(retMsg); } // DeserializeMessage