asp.net如何读取显示网页传回的带soap协议的xml文档数据

我说我行就是行 2013-04-26 10:42:57
请求的网页传回的代码如下,就是不知道如何读取并在前台页面显示

<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"

soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"

xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<get_promotion_listResponse xmlns="PROMOTION">
<promotion_list xsi:nil="true" soapenc:arrayType="xsd:anyType[165]" xsi:type="soapenc:Array">
<promotion>
<id xsi:type="xsd:int">338</id>
<promotion_name xsi:type="xsd:string">1</promotion_name>
<merchant_name xsi:type="xsd:string">1</merchant_name>
<logo_url xsi:type="xsd:string">1</logo_url>
<start_time xsi:type="xsd:date">2007-03-26</start_time>
<end_time xsi:type="xsd:date">2014-03-26</end_time>
<introduction xsi:type="xsd:string">1</introduction>
<category xsi:type="xsd:string">其他</category>
<certification xsi:type="xsd:string">未申请</certification>
<thanks_list xsi:nil="true" soapenc:arrayType="xsd:anyType[1]" xsi:type="soapenc:Array">
<thanks>
<id xsi:type="xsd:int">1002</id>
<name xsi:type="xsd:string">sephora CPS 成果</name>
<price xsi:type="xsd:float">5%</price>
<type xsi:type="xsd:string">ec</type>
</thanks>
</thanks_list>
</promotion>
</promotion_list>
</get_promotion_listResponse>
</soap:Body>
</soap:Envelope>
...全文
274 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
吾非大神 2013-04-26
  • 打赏
  • 举报
回复
soap:Envelope 这个挺讨厌的我觉着,没法反序列化 用#7楼的法子呗
kiss筱魔 2013-04-26
  • 打赏
  • 举报
回复
webservice的话,你输出什么,添加这个服务器引用后得到你webservice输出的结果
md5e 2013-04-26
  • 打赏
  • 举报
回复
引用 9 楼 dingzongyinnihao 的回复:
我是否可以用linq to xml查询
可以啊,但我不熟linq
  • 打赏
  • 举报
回复
我是否可以用linq to xml查询
md5e 2013-04-26
  • 打赏
  • 举报
回复
md5e 2013-04-26
  • 打赏
  • 举报
回复
string txt="<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +" xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " +" soap:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"> " +" <soap:Body> " +" <get_promotion_listResponse xmlns=\"PROMOTION\"> " +"<promotion_list xsi:nil=\"true\" soapenc:arrayType=\"xsd:anyType[165]\" xsi:type=\"soapenc:Array\"> " +" <promotion> " +" <id xsi:type=\"xsd:int\">338</id> " +" <promotion_name xsi:type=\"xsd:string\">1</promotion_name> " +" <merchant_name xsi:type=\"xsd:string\">1</merchant_name> " +" <logo_url xsi:type=\"xsd:string\">1</logo_url> " +" <start_time xsi:type=\"xsd:date\">2007-03-26</start_time> " +" <end_time xsi:type=\"xsd:date\">2014-03-26</end_time> " +" <introduction xsi:type=\"xsd:string\">1</introduction> " +" <category xsi:type=\"xsd:string\">其他</category> " +" <certification xsi:type=\"xsd:string\">未申请</certification> " +" <thanks_list xsi:nil=\"true\" soapenc:arrayType=\"xsd:anyType[1]\" xsi:type=\"soapenc:Array\"> <thanks> " +" <id xsi:type=\"xsd:int\">1002</id> " +" <name xsi:type=\"xsd:string\">sephora CPS 成果</name> " +" <price xsi:type=\"xsd:float\">5%</price> " +" <type xsi:type=\"xsd:string\">ec</type> " +" </thanks> " +" </thanks_list> " +" </promotion> " +" </promotion_list>" +" </get_promotion_listResponse> " +"</soap:Body>" +"</soap:Envelope> "; XmlDocument doc = new XmlDocument(); doc.LoadXml(txt); XmlNode songNode = doc.FirstChild.FirstChild.FirstChild.FirstChild; if (songNode != null) { foreach (XmlNode promotion in songNode.ChildNodes) { Response.Write("<br/>==========产品============<br/>"); foreach(XmlNode item in promotion.ChildNodes) { if (!item.FirstChild.HasChildNodes) { Response.Write(item.Name + "=" + item.InnerText + "</br>"); } else { foreach (XmlNode thanks in item.ChildNodes) { Response.Write(item.Name + "=" + item.InnerText + "</br>"); Response.Write("<br/>==========thanks===========<br/>"); foreach (XmlNode thanksItem in thanks.ChildNodes) { Response.Write(thanksItem.Name + "=" + thanksItem.InnerText + "</br>"); } } } } } } Response.End();
大腹 2013-04-26
  • 打赏
  • 举报
回复
那你直接添加服务引用,引用这个url呗,应该可以生成服务代理才对
  • 打赏
  • 举报
回复
通过访问接口的url(http://xxx.cgi)
大腹 2013-04-26
  • 打赏
  • 举报
回复
你访问的接口是什么样子的? 是webservice?还是wcf?还是其它? 你是如何访问这个接口的? 按理说基于soap协议的接口应该是webservice/wcf的,你可以添加服务引用的呀!
  • 打赏
  • 举报
回复
是一个查询数据接口,上面的是返回的xml数据,但与平时的xml又不太相同,所以不知如何读取<promotion>与</promotion>之间的数据,希望高手帮忙解决下
ganfeihong 2013-04-26
  • 打赏
  • 举报
回复
请求的是一个网页是一个WebService吗?楼主又是想显示什么信息呢?
  • 打赏
  • 举报
回复
怎么没人回帖呢?

62,025

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧