从Stream读取时WCF服务抛出错误 - 读取流时抛出异常

时间:2018-02-07 14:35:16

标签: c# .net web-services wcf wcf-rest

Hello这是我的服务代码 - 我想读取客户端传递的XMl,但是在开始读取它的throw错误时 - 读取流时抛出异常。

    [WebMethod]
    public bool processEvent(Stream XMLDoc)
    {
        string logPath = string.Empty;
        processEventResult result = new processEventResult();
        try
        {
            logPath = ConfigurationManager.AppSettings["ServiceLogPath"];

            using (StreamReader reader = new StreamReader(XMLDoc))
            {
                while (!reader.EndOfStream)
                {
                    string xmlString = reader.ReadToEnd();
                    XmlDocument xDoc = new XmlDocument();
                    xDoc.LoadXml(xmlString);
                    string returnValue = xDoc.OuterXml;
                }
            }
        }
     }

 public interface IDMSService
   {
    [OperationContract(Action = "urn:ProcessEvent")]
    [WebInvoke(Method = "POST", UriTemplate = "processEvent",BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Xml, ResponseFormat = WebMessageFormat.Xml)]
    processEventResult processEvent(Stream XMLDoc);
  }

0 个答案:

没有答案