Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 从RESTfulWebService获取响应_C#_Asp.net_Web Services - Fatal编程技术网

C# 从RESTfulWebService获取响应

C# 从RESTfulWebService获取响应,c#,asp.net,web-services,C#,Asp.net,Web Services,我有下面的代码连接到Web服务并查询API以获得成功的结果。但我面临两个问题 我无法捕获XML格式的响应 我无法从页面重定向回返回URL 请帮助蒂亚 字符串Url=“” string方法=”“; 字符串组=”; 字符串FormName=“”; 字符串返回_url=“”; Url=”https://abc.com/ws/"; Method=“getRates”; Group=“rates”; FormName=“form1”; return_url=“~/app/Public/PaymentTes

我有下面的代码连接到Web服务并查询API以获得成功的结果。但我面临两个问题

  • 我无法捕获XML格式的响应

  • 我无法从页面重定向回返回URL

  • 请帮助蒂亚

    字符串Url=“”

    string方法=”“;
    字符串组=”;
    字符串FormName=“”;
    字符串返回_url=“”;
    Url=”https://abc.com/ws/";
    Method=“getRates”;
    Group=“rates”;
    FormName=“form1”;
    return_url=“~/app/Public/PaymentTest.aspx?DR={DR}”;
    NameValueCollection FormFields=新的NameValueCollection();
    添加(“用户名”、“xxx”);
    添加(“密码”、“xxxx”);
    表单字段。添加(“pin”、“xxxx”);
    添加(“目的地国”、“肯尼亚”);
    添加(“返回url”,返回url);
    回答。写(“”);
    Write(string.Format(“,FormName));
    Write(string.Format(“,FormName,“post”,Url+Group+“/”+Method));
    对于(int i=0;i
    将返回xml加载到数据集中(注意:returnds),然后我检索xml响应,如下所示:

    int i = 0;
    string current = null;
    for (i = 0; i <= returnds.Tables(0).Rows.Count - 1; i++) {
      if (Information.IsDBNull(returnds.Tables(0).Rows(i)("ValueOfXML")) == true) {
        current = "";} 
    else {
        current = Convert.ToString(returnds.Tables(0).Rows(i)("ValueOfXML"));
      }
    }
    
    inti=0;
    字符串电流=空;
    
    对于(i=0;i您似乎正在尝试创建一个只包含HTML的解决方案。(您使用ASP.NET生成HTML是一种干扰)。您需要在onload上编写额外的javascript—您可能不想提交表单,这将告诉浏览器您已完成页面操作。您需要进行javascript web服务调用,jquery方式比原始的XmlHttp更简单

    参考:

    int i = 0;
    string current = null;
    for (i = 0; i <= returnds.Tables(0).Rows.Count - 1; i++) {
      if (Information.IsDBNull(returnds.Tables(0).Rows(i)("ValueOfXML")) == true) {
        current = "";} 
    else {
        current = Convert.ToString(returnds.Tables(0).Rows(i)("ValueOfXML"));
      }
    }