对方是传过来的是inputstream类型,我在c#中怎么接受并解析成string类型?
------解决方案--------------------
http://blog.csdn.net/hanqunfeng/article/details/4364583
参考这里
------解决方案--------------------
- C# code
[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)); } }