如何从Web服务读取对网页的XML响应? [英] How to read XML response to a webpage from Web Service ?

查看:61
本文介绍了如何从Web服务读取对网页的XML响应?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





以下是我完整的SOAP Fromat。如何向Webservice方法发出请求并读取响应。我可以调用该方法但无法读取响应。





以下是SOAP 1.1请求和响应的示例。显示的占位符需要替换为实际值。



 POST /RechargeAll.asmx HTTP / 1.1 
主持人:myserverAPI.net
Content-Type:text / xml; charset = utf-8
内容长度:长度
SOAPAction:http://myserverAPI.net/RechargeMobile


< soap:envelope xmlns: xsi =http://www.w3.org/2001/XMLSchema-instancexmlns:xsd =http://www.w3.org/2001/XMLSchemaxmlns:soap =http://schemas.xmlsoap .ORG /肥皂/信封/>
< soap:header>
< mobilesoapheader xmlns =http://myserverAPI.net/>
< strusername> string< / strusername>
< strpassword> string< / strpassword>
< strcode> string< / strcode>
< / mobilesoapheader>
< / soap:header>
< soap:body>
< rechargemobile xmlns =http://myserverAPI.net/>
< refnumber> string< / refnumber>
< custmobilenumber> string< / custmobilenumber>
< rechargetype> string< / rechargetype>
< opearatoralias> string< / opearatoralias>
< regionalias> string< / regionalias>
< amount> double< / amount>
< ipaddress> string< / ipaddress>
< / rechargemobile>
< / soap:body>
< / soap:envelope>
HTTP / 1.1 200 OK
内容类型:text / xml; charset = utf-8
内容长度:长度


< soap:envelope xmlns:xsi =http://www.w3.org/2001/XMLSchema-实例xmlns:xsd =http://www.w3.org/2001/XMLSchemaxmlns:soap =http://schemas.xmlsoap.org/soap/envelope/>
< soap:body>
< rechargemobileresponse xmlns =http://myserverAPI.net/>
< rechargemobileresult> string< / rechargemobileresult>
< / rechargemobileresponse>
< / soap:body>
< / soap:envelope>









帮助我,提前致谢..

解决方案

如何阅读从Web服务返回的xml数据 [ ^ ]



DataSet .ReadXml方法 [ ^ ]



问候..:笑:


//创建Web服务对象。

WebService ws = new WebService();



//创建数据集对象。

DataSet ds = new DataSet( );



//调用Web服务方法并返回xml输出并存储在xml元素对象中。

XmlElement xE = ws.Emplo yeeList();



XmlNodeReader xNR = new XmlNodeReader(xE);



// xml数据存储在数据集中。

ds.ReadXml(xNR);





您可以在网络中使用数据集页。

Hi,

Below is my complete SOAP Fromat. How can i make request to Webservice method and read response. Iam able to call the method but unable to read the response.


The following is a sample SOAP 1.1 request and response. The placeholders shown need to be replaced with actual values.

POST /RechargeAll.asmx HTTP/1.1
Host: myserverAPI.net
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://myserverAPI.net/RechargeMobile"


<soap:envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:header>
    <mobilesoapheader xmlns="http://myserverAPI.net/">
      <strusername>string</strusername>
      <strpassword>string</strpassword>
      <strcode>string</strcode>
    </mobilesoapheader>
  </soap:header>
  <soap:body>
    <rechargemobile xmlns="http://myserverAPI.net/">
      <refnumber>string</refnumber>
      <custmobilenumber>string</custmobilenumber>
      <rechargetype>string</rechargetype>
      <opearatoralias>string</opearatoralias>
      <regionalias>string</regionalias>
      <amount>double</amount>
      <ipaddress>string</ipaddress>
    </rechargemobile>
  </soap:body>
</soap:envelope>
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length


<soap:envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:body>
    <rechargemobileresponse xmlns="http://myserverAPI.net/">
      <rechargemobileresult>string</rechargemobileresult>
    </rechargemobileresponse>
  </soap:body>
</soap:envelope>





Help me, Thanks in advance..

解决方案

how to read xml data returned from a web service[^]

DataSet.ReadXml Method[^]

Regards..:laugh:


// create web service object.
WebService ws = new WebService();

// create Data Set object.
DataSet ds = new DataSet();

// call to the web service method and that returns the xml output and store in xml element object.
XmlElement xE = ws.EmployeeList();

XmlNodeReader xNR = new XmlNodeReader(xE);

// the xml data store in dataset.
ds.ReadXml(xNR);


You can use dataset in a web page.


这篇关于如何从Web服务读取对网页的XML响应?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆