首页 新闻 赞助 找找看

XMLHTTP调用远程接口问题

0
悬赏园豆:50 [已关闭问题] 关闭于 2012-05-08 08:48

错误页面如下:

 

 

代码如下:

 1 protected void bt_zc_Click(object sender, EventArgs e)
 2     {
 3 
 4         string HttpUrl = "http://myshchq.gicp.net/cri/member/reg";
 5 
 6       string JsonData = {"address":"贵阳市南明区","birthday":"1987-06-15","cardnum":"520224198706153215","country":"中国","email":"52535252@qq.com","hotelid":"","password":"123456","province":"贵阳","tel":"13533333333","uname":"张三","usex":"","utype":"1"} ;
 7         
 8         string user = "other";
 9         string pwd = "admin";
10         byte[] byteArray = Encoding.UTF8.GetBytes(user + ":" + pwd);
11         string Auth = Convert.ToBase64String(byteArray);
12 
13         JsonResult = SendPostService(HttpUrl, JsonData, Auth);
14 
15         lab2.Text = "原始结果:" + JsonResult;
16     }
17 
18     protected string SendPostService(string HttpUrl, string JsonData, string Auth)
19     {
20         XMLHTTP xmlHttp = new XMLHTTP();
21         xmlHttp.open("post", HttpUrl, false, null, null);
22         xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
23         xmlHttp.setRequestHeader("auth:", Auth);
24         xmlHttp.send(JsonData);
25         return xmlHttp.responseText;
26     }
夜、 ̄微ミ凉.、的主页 夜、 ̄微ミ凉.、 | 菜鸟二级 | 园豆:220
提问于:2012-05-04 11:01
< >
分享
所有回答(1)
0

如果是用模擬用戶,請看看這裡。http://www.cnblogs.com/Teco/archive/2012/04/24/2467954.html

你上面是沒有權限,web.config中需要配置。不知道能不能解決到呢。

無限遐想 | 园豆:3740 (老鸟四级) | 2012-05-04 11:15

常识过试用模拟用户,但是还是会报这样的错误,很是纠结...

支持(0) 反对(0) 夜、 ̄微ミ凉.、 | 园豆:220 (菜鸟二级) | 2012-05-04 11:22

@夜、 ̄微ミ凉.、: 權限 不夠吧。給一個管理員的用戶試一下。

支持(0) 反对(0) 無限遐想 | 园豆:3740 (老鸟四级) | 2012-05-04 11:23

@無限遐想: 我直接使用的是administrator最高权限了。我上次做过类似的接口,也是用的这个方法,就没问题。

支持(0) 反对(0) 夜、 ̄微ミ凉.、 | 园豆:220 (菜鸟二级) | 2012-05-04 11:25
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册