?
Solved

How do I allow my web service to work with a Proxy Server

Posted on 2009-07-01
4
Medium Priority
?
432 Views
Last Modified: 2012-05-07
We are developing an application that has a client application that needs to call a web service that is located on our web server.  The client application will be install by a wide range of users spanning from home users to people behind corporate firewalls.

What functionality do we need in our product to ensure that we can work with different proxy servers.  I see that application like Instant messenger and Norton Antivirus allow for proxy setting to be supplied by the user& I have read about using default proxy and cached credentials.

Dim proxy As System.Net.WebProxy = System.Net.WebProxy.GetDefaultProxy
proxy.Credentials = System.Net.CredentialCache.DefaultCredentials
ws.Proxy = proxy

I am having trouble understanding what should be included in our client application, what are different techniques to do the same thing.

So the question&
I am looking for a sample application that shows/describes the best practices of implementing web services to work with proxy servers.  I would like to understand why applications like Norton Antivirus have the options to specify proxy settings.
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
  • 2
4 Comments
 
LVL 15

Expert Comment

by:jinal
ID: 24756347

Use configuration file.
This is sample
<system.net>
  <defaultProxy>
    <proxy usesystemdefault="true" />
  </defaultProxy>
</system.net>

Also in your sample  you did use System.Net.WebProxy.GetDefaultProxy which is deprecated .

http://dotnetstep.blogspot.com/2009/04/webservice-authenticate-against-proxy.html
0
 

Author Comment

by:jongrossex
ID: 24767892

Hi Jinal,

Thanks for your comments.

I have tried to put together a sample based on what I have read.  Please critique the sample code.  I am interested if I am close or how to make it better.

Do you have any special error handling that you use when calling a web service?

Thanks
Jon
Private Sub cmdGetPatientName_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdGetPatientName.Click
 
    Dim bUserSuppliedNetworkCredentails 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 bUserSuppliedNetworkCredentails Then
      ws.Credentials = New NetworkCredential("UserName", "Password", "Domain")
    End If
 
    Dim patientId As Integer = 123
    Dim patientName As String = ws.GetPatientName(patientId)
 
    MsgBox(patientName, MsgBoxStyle.Information)
 
  End Sub

Open in new window

0
 
LVL 15

Accepted Solution

by:
jinal earned 2000 total points
ID: 24768963
Hello ,
In some of the case you need to supply credentials for proxy server to.
ws.Proxy.Credentials = ....

0
 

Author Closing Comment

by:jongrossex
ID: 31598816
Thanks for your help.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

752 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