C#中的Web服务应用程序- [英] Webservice application in C# -

查看:280
本文介绍了C#中的Web服务应用程序-的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我正在使用C#应用程序通过Web服务发送SMS.在我的代码执行期间,当控制权到达尝试catch块的时候,即req.GetResponse(),我收到一个错误

Hello,

I am using my C# application to send SMS through web service. During the execution of my code, when control reaches to try catch block,that is req.GetResponse() i am getting an error

Error is - "The remote server returned an error:(407)Proxy authentication required"


我写的代码是


The code what i have written is

string url = "valid url";

HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);

NetworkCredential netcredit = new NetworkCredential("username",    "password", "domain");

req.Credentials = netcredit;

System.Net.WebProxy pry = new WebProxy("192.168.1.4:1598", true);

pry.Credentials = netcredit;

req.Proxy = pry;

req.Method = "HEAD";

try
{
    HttpWebResponse res = (HttpWebResponse)req.GetResponse();
}
catch (Exception ex)
{
    MessageBox.Show(ex.Message);
    return;
}


请帮助解决此错误

rgds


Please help to solve this error

rgds

推荐答案

亲爱的朋友,

您提供的凭据不正确,或与防火墙专家联系.他们为PROD服务器打开了防火墙,因此无需使用代理.


您必须在两个位置设置凭据才能克服407错误:

Dear Friend,

Either the credentials you are providing are incorrect or Check with your firewall expert. They open the firewall for PROD servers so there is no need to use the Proxy.
OR

You have to set the Credentials in two locations to get past the 407 error:

HttpWebRequest webRequest = WebRequest.Create(uirTradeStream) as HttpWebRequest;
webRequest.Proxy = WebRequest.DefaultWebProxy;
webRequest.Credentials = new NetworkCredential("user", "password", "domain");
webRequest.Proxy.Credentials = new NetworkCredential("user", "password", "domain")



如果以上方法均无法解决,请点击链接



If the above things don''t work out then follow the link

http://blogs.msdn.com/b/jpsanders/archive/2009/03/24/httpwebrequest-webexcepton-the-remote-server-returned-an-error-407-proxy-authentication-required.aspx[^]

Don''t forget to mark this as your answer if it helps you out.

Thanks


检查StackOverFlow上的该线程是否有帮助.
需要407个代理身份验证 [
Check if this thread on StackOverFlow is of any help.
407 proxy authentication required[^]


当我从网络凭证中删除域名时,它起作用了
when i remove domain name from networkwork credentaial it works


这篇关于C#中的Web服务应用程序-的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆