我创建了一个通用方法来序列化包含soap请求/响应信息的对象以保存在sql表中。出于某种原因,<
和>
似乎存储为<
和>
。
这是方法,
public static void webServiceLogging<T>(T obj,
string messageType, string messageAction, string messageXML, RemoteEndpointMessageProperty endpoint)
{
OperationContext context = OperationContext.Current;
MessageProperties messageProperties = context.IncomingMessageProperties;
XmlSerializer serializer = new XmlSerializer(typeof(T));
StringWriter writer = new StringWriter();
serializer.Serialize(writer, obj);
WebServiceLog serviceLog = new WebServiceLog();
string payloadXml = serviceLog.MessageBody = writer.ToString();
payloadXml = payloadXml.Replace(payloadXml.Substring(0, payloadXml.IndexOf("?>") + 2), "");
serviceLog.MessageType = messageType;
serviceLog.MessageAction = messageAction;
serviceLog.MessageXml = messageXML;
serviceLog.SenderIpAddress = endpoint.Address;
serviceLog.MessageIdentifier = endpoint.Port.ToString();
serviceLog.MessageBody = string.Format(payloadXml);
SubmitWebServiceLog(serviceLog);
}
我可能做错了什么?