Solved

How do I specify 'Automatic Proxy Detection, HTTP, SOCKS'

Posted on 2009-07-06
3
943 Views
Last Modified: 2012-05-07

I am working on adding code to my application that will allow it to properly work with a proxy server.  In doing some research I see that applications like Skype, MS Messenger...  allow the user to specify 3 proxy options.
1) Automatic proxy detection
2) HTTP
3) SOCKS

I think that I understand how to specify the 'Automatic proxy' but can not find anything in the web service classes that allow me to specify HTTP or SOCKS.

I believe that... will work for Automatic detection.
ws.Proxy = System.Net.WebRequest.DefaultWebProxy
Is that correct?

How do I specify SOCKS, HTTP?
I am new to working with Proxy servers so it could be very obvious.

Thanks
Private Sub cmdGetPatientName_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdGetPatientName.Click
    Dim bUserSuppliedProxyCredentails As Boolean = True
    'Call a function to see if the user want to specify credentials
 
    Dim bUserSuppliedProxyInfo As Boolean = True
    'Call a function to see if the user has given us proxy information
 
    Dim ws As New SampleWebService.Service1
    If bUserSuppliedProxyInfo Then
      ws.Proxy = New System.Net.WebProxy("http://myWebProxy", 456)
    Else
      ws.Proxy = System.Net.WebRequest.DefaultWebProxy
    End If
 
    If bUserSuppliedProxyCredentails Then
      ws.Proxy.Credentials = New NetworkCredential("UserName", "Password", "Domain")
    End If
 
 
    Dim patientId As Integer = 123
    Dim patientName As String = ws.GetPatienName(patientId)
 
    MsgBox(patientName, MsgBoxStyle.Information)
 
  End Sub

Open in new window

0
Comment
Question by:jongrossex
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 25

Expert Comment

by:apeter
ID: 24800789
We can't have automatic proxy detection for web service. We have to configure manually if you have any proxy else you don't require to mention it at all.

All those messengers use protocols like Sockets, HTTP for different needs and thus they have different settings.

But web services is only over HTTP.
0
 

Author Comment

by:jongrossex
ID: 24803993
Thanks apeter,

Can you modify the sample code so that it would be correct as it related to the automatic proxy detection.

I understand that I do not need to worry about socks.

Thanks
Jon
0
 
LVL 25

Accepted Solution

by:
apeter earned 500 total points
ID: 24811678
Your code looks fine. Checking if proxy info is available then set it else don't do anything. Since default proxy will be set and we don't need to set it manually. So i have deleted only else part in the proxy setting IF statement.

Private Sub cmdGetPatientName_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdGetPatientName.Click
    Dim bUserSuppliedProxyCredentails As Boolean = True
    'Call a function to see if the user want to specify credentials
 
    Dim bUserSuppliedProxyInfo As Boolean = True
    'Call a function to see if the user has given us proxy information
 
    Dim ws As New SampleWebService.Service1
    If bUserSuppliedProxyInfo Then
      ws.Proxy = New System.Net.WebProxy("http://myWebProxy", 456)
    End If
 
    If bUserSuppliedProxyCredentails Then
      ws.Proxy.Credentials = New NetworkCredential("UserName", "Password", "Domain")
    End If
 
 
    Dim patientId As Integer = 123
    Dim patientName As String = ws.GetPatienName(patientId)
 
    MsgBox(patientName, MsgBoxStyle.Information)
 
  End Sub
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question