internal static IMessage DeserializeMessage(String mimeType, Stream xstm, bool methodRequest, IMessage msg, Header[] h) { InternalRemotingServices.RemotingTrace("DeserializeMessage"); InternalRemotingServices.RemotingTrace("MimeType: " + mimeType); CoreChannel.DebugOutXMLStream(xstm, "Deserializing"); Stream fmtStm = null; bool bin64encode = false; bool doHeaderBodyAsOne = true; if (string.Compare(mimeType, BinaryMimeType, StringComparison.Ordinal) == 0) { doHeaderBodyAsOne = true; } if (string.Compare(mimeType, SOAPMimeType, StringComparison.Ordinal) == 0) { doHeaderBodyAsOne = false; } if (bin64encode == false) { fmtStm = xstm; } else { InternalRemotingServices.RemotingTrace("***************** Before base64 decode *****"); long Position = xstm.Position; MemoryStream inStm = (MemoryStream)xstm; byte[] byteArray = inStm.ToArray(); xstm.Position = Position; String base64String = Encoding.ASCII.GetString(byteArray, 0, byteArray.Length); byte[] byteArrayContent = Convert.FromBase64String(base64String); MemoryStream memStm = new MemoryStream(byteArrayContent); fmtStm = memStm; InternalRemotingServices.RemotingTrace("***************** after base64 decode *****"); } Object ret; IRemotingFormatter fmt = MimeTypeToFormatter(mimeType, false); if (doHeaderBodyAsOne == true) { ret = ((BinaryFormatter)fmt).UnsafeDeserializeMethodResponse(fmtStm, null, (IMethodCallMessage)msg); } else { InternalRemotingServices.RemotingTrace("Content"); InternalRemotingServices.RemotingTrace("***************** Before Deserialize Headers *****"); InternalRemotingServices.RemotingTrace("***************** After Deserialize Headers *****"); InternalRemotingServices.RemotingTrace("***************** Before Deserialize Message *****"); if (methodRequest == true) { MethodCall mc = new MethodCall(h); InternalRemotingServices.RemotingTrace("***************** Before Deserialize Message - as MethodCall *****"); fmt.Deserialize(fmtStm, new HeaderHandler(mc.HeaderHandler)); ret = mc; } else { IMethodCallMessage mcm = (IMethodCallMessage)msg; MethodResponse mr = new MethodResponse(h, mcm); InternalRemotingServices.RemotingTrace("***************** Before Deserialize Message - as MethodResponse *****"); fmt.Deserialize(fmtStm, new HeaderHandler(mr.HeaderHandler)); ret = mr; } InternalRemotingServices.RemotingTrace("***************** After Deserialize Message *****"); } // Workaround to make this method verifiable IMessage resMessage = (IMessage)ret; InternalRemotingServices.RemotingTrace("CoreChannel::DeserializeMessage OUT"); CoreChannel.DebugMessage(resMessage); return(resMessage); }