c#webservice中怎么把对方传过来的inputstream类型转成string类型?
对方是传过来的是inputstream类型,我在c#中怎么接受并解析成string类型?
[解决办法]
http://blog.csdn.net/hanqunfeng/article/details/4364583
参考这里
[解决办法]
[WebMethod] public void SendXml() { // 获得客户端RAW HttpRequest var inputStream = HttpContext.Current.Request.InputStream; // 定义Response返回的格式是:Json var response = HttpContext.Current.Response; response.ContentType = "text/json"; //var strXml = ""; //using (var sr = new StreamReader(inputStream)) // strXml = sr.ReadToEnd(); try { DataTable data = new DataTable(); using (var xr = XmlReader.Create(inputStream)) data.ReadXml(xr); // 将读入Xml的DataTable的行数返回客户端 string count = "/"" + data.Rows.Count + "/""; response.BinaryWrite(System.Text.Encoding.UTF8.GetBytes(count)); } catch (Exception ex) { response.BinaryWrite(System.Text.Encoding.UTF8.GetBytes(ex.Message)); } }