Solved

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

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

832 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