首页 新闻 会员 周边

asp 如何访问 Webservice 并返回数据

0
悬赏园豆:50 [已关闭问题] 关闭于 2011-06-06 21:47

假如有一个网页,上面有接口,要怎样访问那个网页上的接口并返回数据。

求各位高手教教小弟,在下不胜感激....求详解。 要求是asp的

问题补充:

asp  访问 Web Service 接口  我写的代码如下,为什么 总是提示“500 内部服务器错误--您查找的资源存在问题,因而无法显示。”

我需要访问的 Web Service 接口 URLhttp://data.1ts.cn/flightCmd.asmx?op=AVCMD 代码如下:

<%
SoapRequest="<xml version="&chr(34)&"1.0"&chr(34)&"encoding="&chr(34)&"utf-8"&chr(34)&"?>"&_
"<soap:Envelope xmlns:xsi="&chr(34)&"http://www.w3.org/2001/XMLSchema-instance"&chr(34)&""&_
"xmls:xsd="&chr(34)&"http://www.w3.org/2001/XMLSchema"&chr(34)&""&_
"xmls:soap="&chr(34)&"http://schemas.xmlsoap.org/soap/envelope/"&chr(34)&">"&_
"<soap:Body>"& _
"<AVCMD xmlns="&chr()34&"LvxooI"&chr(34)&">"&_
"<user>"&user&"</user>"&_
"<pwd>"&pwd&"</pwd>"&_
"<org>"&org&"</org>"&_
"<dst>"&dst&"</dst>"&_
"<dt>"&dt&"</dt>"&_
"<carrier>"&carrier&"</carrier>"&_
"</AVCMD>"&_
"</soap:Body>"&_
"</soap:Envelope>"
Response.Write(xmlhttp.Status)
%>

测试总是不能返回  200

道勤2016的主页 道勤2016 | 初学一级 | 园豆:30
提问于:2011-06-02 12:14
< >
分享
所有回答(2)
0
邀月 | 园豆:25475 (高人七级) | 2011-06-02 12:31
首先非常感谢您提供的答案,不过我是个新手能不能给我写个例子
以下是 SOAP 1.2 请求和响应示例。所显示的占位符需替换为实际值。POST /flightCmd.asmx HTTP/1.1
Host: data.1ts.cn
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "LvxooI/AVCMD"





string
string
string
string
dateTime

string



HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length






支持(0) 反对(0) 道勤2016 | 园豆:30 (初学一级) | 2011-06-02 12:41
0

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;
using WindowsFormsApplication1.cn.com.wxws;
using System.Threading;
using System.IO;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
       

        public Form1()
        {
            InitializeComponent();
        }

 private void button1_Click(object sender, EventArgs e)
        {
            CookieContainer c = new CookieContainer();
            Service pop = new Service();

            pop.CookieContainer = c;

            // 登录
            string infor = pop.UserLogin("xxx", "xxx");

            // 返回文件列表
            FileQuery fi = new FileQuery();
            fi = pop.fileSummary("bihoo");

            string list = "";
            for (int i = 0; i < fi.ResultElements.Length; i++)
            {
                list += i.ToString() + " : " + fi.ResultElements[i].FileName + "\r\n";
            }
            MessageBox.Show(list);
        }

}

这是我写的一个调用接口的例子,你可以借鉴一下

.豆包 | 园豆:235 (菜鸟二级) | 2011-06-02 15:14
asp.net 我也知道一点,是吧WebService 当做一个 类处理。
我现在需要的是ASP的,刚好我又不会asp……不过我还是要谢谢你。
支持(0) 反对(0) 道勤2016 | 园豆:30 (初学一级) | 2011-06-02 15:19
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册