Solved

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

Posted on 2009-07-06
3
931 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

While working on Silverlight and WCF application, I faced one issue where fault exception occurred at WCF operation contract is not getting propagated to Silverlight client. So after searching net I came to know that it was behavior by default for s…
Here I am going to explain creating proxies at runtime for WCF Service. So basically we use to generate proxies using Add Service Reference and then giving the Url of the WCF service then generate proxy files at client side. Ok, what if something ge…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

728 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now