请求个WEBService调用问题.

henryfan1 2005-08-02 11:14:01
小弟刚在学WebService.
我通过MSXML.XMLHTTPRequest来访问WebService是没有问题.
但我通过.net的HttpWebRequest来访问WebService在获取WebResponse时就出现(用XMLHTTP.XMLHttpRequest是微软自己装的类)
403错误(已禁止)
两个都是调用同一个WebService.
...全文
211 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
brando_beat 2005-08-04
  • 打赏
  • 举报
回复
看着星星闪眼
henryfan1 2005-08-02
  • 打赏
  • 举报
回复
//
// TODO: 在此处添加代码以启动应用程序
MSXML.XMLHTTPRequest request = new MSXML.XMLHTTPRequestClass();
request.open("post","http://localhost/WebService2/Service1.asmx",false,Type.Missing,Type.Missing);
request.setRequestHeader("Content-Type","text/xml; charset=utf-8");
request.setRequestHeader("SOAPAction","http://tempuri.org/HelloWorld1");
string saop="<?xml version=\"1.0\" encoding=\"utf-8\"?>"
+"<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>"
+"<HelloWorld1 xmlns=\"http://tempuri.org/\">"
+"<ee>asdasdasdasdas</ee>"
+"</HelloWorld1>"
+"</soap:Body>"
+"</soap:Envelope>";
request.send(saop);
Console.Write( request.responseText);
Console.Read();
--------------------------------------------------------------------------
XMLHTTP.XMLHttpRequest quest = new XMLHTTP.XMLHttpRequest();
quest.Open("post","http://localhost/WebService2/Service1.asmx",false,"","");
quest.SetRequestHeader("Content-Type","text/xml; charset=utf-8");
quest.SetRequestHeader("SOAPAction","http://tempuri.org/HelloWorld1");
quest.Send(saop);
Console.Write(quest.GetResponseText());
Console.Read();

MSXML.XMLHTTPRequest(COM) 和XMLHTTP.XMLHttpRequest(.NET类库)都是软微提供的.
用XMLHTTP.XMLHttpRequest就出现禁止访问,不知道是不是和IIS有关.
henryfan1 2005-08-02
  • 打赏
  • 举报
回复
楼上那位大侠.
我是想用.NET的调用其他平台写的WEBSERVICE.
通过MSXML的COM是可以调用,但我不想在.NET里用非托管组件.
所以使用.net的HttpWebRequest来实现,但请求完后获取HttpWebResponse出现了访问禁止的错误.
孟子E章 2005-08-02
  • 打赏
  • 举报
回复
http://sz.luohuedu.net/xml/ShowList.asp?id=6

12,162

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 Web Services
社区管理员
  • Web Services社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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