Solved

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

Posted on 2009-07-06
3
939 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
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

749 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