读书人

C#写的WebService端怎么得到客户端调用

发布时间: 2012-08-01 17:53:40 作者: rapoo

C#写的WebService端如何得到客户端调用时传来的XML数据?
StreamReader srd = new StreamReader(HttpContext.Current.Request.InputStream);
string strReq = srd.ReadToEnd();

尝试了这样子拿不到的样子?哪位大侠分享一下?

[解决办法]

C# code
   var xml = @"<duliye>  <news>  <id>1</id>  <title>介绍</title>  <content>    介绍介绍介绍介绍介绍介绍介绍  </content>  </news>  <news>  <id>2</id>  <title>团队</title>  <content>    我们的团队我们的团队  </content>  </news>  <news>  <id>3</id>  <title>大事件</title>  <content>    2008年7月      2010年9月   </content>  </news></duliye>";            var doc = new XmlDocument();            doc.LoadXml(xml);            var node = doc.SelectSingleNode("/duliye/news[child::id[text()=2]]");//找到id=2的news节点,之后你就可以去它的ChildNodes里取你想要的内容了            Console.WriteLine(string.Format(@"news:            Id={0}            title={1}            content={2}", node.ChildNodes[0].InnerText, node.ChildNodes[1].InnerText, node.ChildNodes[2].InnerText));
[解决办法]
现在的REST WCF的可以做到。。。而且如果数据格式好的话,你可以直接拿到反序列化的Order对象。
在WCF里是WebOperation.Current.IncomingRequest, webservcie的话,我试试。。。

http://blog.csdn.net/fangxinggood/archive/2011/03/14/6247297.aspx

读书人网 >C#

热点推荐