Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2009-07-06
3
Medium Priority
?
944 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 2000 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

Independent Software Vendors: 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

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

715 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