/// <summary> /// 创建请求消息实例。 /// </summary> /// <param name="xmlContent">xml内容。</param> /// <returns>请求消息。</returns> public IRequestMessageBase CreateRequestMessage(string xmlContent) { var document = XDocument.Parse(xmlContent); var root = document.Element("xml"); if (root == null) { throw new ArgumentException("找不到根元素 xml。"); } var requestMessageType = GetRequestMessageType(root); return((IRequestMessageBase)_messageFormatterFactory.GetFormatter(requestMessageType).Deserialize(root)); }
/// <summary> /// 根据相应消息得到xml内容。 /// </summary> /// <param name="responseMessage">响应消息实例。</param> /// <returns>xml内容。</returns> public string GetXmlByReponseMessage(IResponseMessage responseMessage) { return(_messageFormatterFactory.GetFormatter(responseMessage.MessageType).Serialize(responseMessage)); }