如题.
我要访问对方提供的一个地址以获得返回的xml.对方给我的代码是java的,其中有:
HttpClient client = new HttpClient(); client.getState().setCredentials(
new AuthScope("localhost", 8080, null),
new UsernamePasswordCredentials(username, password)
);他用java里的httpClient,我在c#里该怎么做?
用webrequest么 ?那怎么设置用户/密码?
我要访问对方提供的一个地址以获得返回的xml.对方给我的代码是java的,其中有:
HttpClient client = new HttpClient(); client.getState().setCredentials(
new AuthScope("localhost", 8080, null),
new UsernamePasswordCredentials(username, password)
);他用java里的httpClient,我在c#里该怎么做?
用webrequest么 ?那怎么设置用户/密码?
解决方案 »
- win8应用调用web service的enValidateImage,在线等,立马结分。
- 加括号中内容的意思是?HttpWebRequest hwrq =(HttpWebRequest)wrq
- 如何将.NET做的COM组件在别的机子上注册
- 如何根据变量的取值,在数据库的表中取得相应字段的值?我没有试成功。
- TCP/IP 问题 达人请进
- 截取端口的数据问题
- 如何设定DataGrid的Cell的格式(比如:decimal 值为15.1,在DataGrid中就为15.10。15.0213为15.02。
- 我从Form继承了一个窗口,在显示时,如何把标题栏隐藏掉?
- 在做计算器的时候有点问题?请大家帮忙
- 如何将多文档程序中子文档嵌入到toolStripContainer的中间面板中(在线等)??
- 隔段时间.net程序就抱错的问题
- 散分的四个问题,上网找了两天的资料未能解决,寻求各位帮助,谢谢,在线等……
System.Net.HttpWebResponse response = request.GetResponse();
UsernamePasswordCredentials(username, password)
可以这么简单的用("http://localhost:8080/default.jsp?username=aaa&password=bbb");
代替么?楼上可确信啊?
WebRequest HttpWReq = WebRequest.Create("http://localhost:8080/default.jsp");
Byte[] byte1 = System.Text.Encoding.GetEncoding("GB2312").GetBytes("username=aaa&password=bbb");
HttpWReq.ContentType = "application/x-www-form-urlencoded";
HttpWReq.ContentLength = byte1.Length;//XMLDoc.OuterXml.Length;
HttpWReq.Method = "POST";
System.IO.Stream StreamData = HttpWReq.GetRequestStream();
StreamData.Write(byte1,0,byte1.Length);
StreamData.Close();
WebResponse HttpWRes = HttpWReq.GetResponse();
System.IO.Stream receiveStream = HttpWRes.GetResponseStream();
myCache.Add(new Uri("http://www.test.com/"),"Digest", new NetworkCredential(UserName,SecurelyStoredPassword,Domain));wReq.Credentials = myCache;