Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm using vs2010. In a simple console app I try to add a service reference to http://***/service1.asmx , old asmx service. My computer is behind a proxy server, so i get an error :

"The remote server returned an unexpected response: (407) Proxy Authentication Required."

When im using wsdl tool i can not define proxy server port number and i get message that server, for examle 10.0.0.3:80, did not respond, but i need to specify 8080 port and don't know how. How could i create a reference?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
190 views
Welcome To Ask or Share your Answers For Others

1 Answer

I spent almost 50 hours finding the problem, could not find anywhere on the web this simple solution.

Under "configuration" section in Web.config add this:

  <system.net>
    <defaultProxy enabled="true" useDefaultCredentials="true"></defaultProxy>
</system.net>

Then works like a charm!

You can also do it from the code behind:

serviceConnection = new WebService1();
serviceConnection.Proxy = System.Net.HttpWebRequest.GetSystemWebProxy();
serviceConnection.Proxy.Credentials = CredentialCache.DefaultCredentials; 

Works beautiful!!.

If you need to consume from HTTPS location add this configuration:

<message clientCredentialType="Certificate" algorithmSuite="Default" />

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...