Web Service Behind A Firewall Problem

  • Thread starter Thread starter Bill Hauver
  • Start date Start date
B

Bill Hauver

I am attempting to use a web service from my work pc
which is behind a firewall. I have used wsdl.exe to
create the web service reference class and added it to my
project. (this seems to work without a hitch).

Before I use this class, I make the necessary calls to
instantiate a WebProxy class and then pass in my
credentials to set the WebProxy.Credentials property so I
can get through the proxy server.

I am now receiving an error message: "Path property must
be set before calling the Send method" within the
WSDL.EXE generated code when invoking a method

Dim results() As Object = Me.Invoke("getQuote", New Object
() {symbol})

I am unsure as to what I may be missing, anyone have any
idea what this error message means?

Thanks - Bill
 
Hello Bill,

Thanks for posting in the group.

Consuming web service when the client is behind a proxy server is a FAQ. We
could refer to MSDN article:
"HOW TO: Configure an XML Web Service Client by Using the .NET Framework to
Work with a Proxy Server"
http://support.microsoft.com/?id=307220

VS.NET uses the Wsdl.exe tool when you add web references. So you can use
Wsdl.exe directly. These are standard solutions to the proxy server issue.

Solution1
--------------
Get the wsdl file locally and add the reference to it.

- In IE on the client machine, type
http://MachineX/Webservice1/Service1.asmx?wsdl
- In IE on the client machine, go to View | Source, copy and save the wsdl
file locally named test.wsdl
- Under the VS.NET command prompt on the client machine, type c:\>wsdl.exe
test.wsdl.
- The Web service proxy source file named service1.cs is generated.
- In VS.NET, right click on the client project, Add, Add Existing Items...
to add service1.cs to the project.
- Code the client to use the web proxy server if it is necessary (see
note2).
- Build the project.

Solution2
--------------
Use the Wsdl.exe tool to specify the proxy and credentials to generate the
proxy code.

- Under the VS.NET command prompt, type: c:\>wsdl.exe
<http://MachineX/Webservice1/Service1.asmx> /proxy:proxyURL
/proxyusername:username /proxypassword:password /proxydomain:domain

- The Web service proxy source file named service1.cs is generated.
- In VS.NET, right click on the client project, Add, Add Existing Items...
to add service1.cs to the project.
- Code the client to use the web proxy server if it is necessary (see
note2).
- Build the project.

Note1:
Run wsdl.exe by itself, you will see a list of usage. Short forms are
'/pu:', '/pp:' and '/pd:'

Note2:
You need code the client to use the web proxy server as follows:

[C#]
MyMath.Math math = new MyMath.Math();
// Set the proxy server to proxyserver, set the port to 80, and specify to
bypass

the proxy server
// for local addresses.
IWebProxy proxyObject = new WebProxy("http://proxyserver:80", true);
math.Proxy = proxyObject;
// Call the Add XML Web service method.
int total = math.Add(8, 5);

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfSystemWebServicesProtocolsHttpWebClientProtocolClassProxyTopic.asp

I tested the above and it works fine on my side. Could you please check it
and post here with the testing results? Also, please posting sample code
slice may also help community to understand the problem well.

Does that answer your question?

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Yes! This is exactly what I was looking for. To further
test this, I tried another web service and ran it against
wsdl.exe and it worked great!

Once I added the wsdl.exe output file to my VB .NET
project, I was able to use it after creating my proxy
server settings in code like this:

Dim x As New TestWebService.ZipCodesService
Dim proxy As New WebProxy("proxyaddress", port)
proxy.Credentials = New NetworkCredential"user", "passw")
x.Proxy = proxy

Thanks for the info, it was a big help! Hopefully the
folks at Microsoft will recognize that there are a lot of
users who live behind firewalls and provide a wizard or
dialog which will prevent the need for using wsdl.exe.

Bill



-----Original Message-----
Hello Bill,

Thanks for posting in the group.

Consuming web service when the client is behind a proxy server is a FAQ. We
could refer to MSDN article:
"HOW TO: Configure an XML Web Service Client by Using the .NET Framework to
Work with a Proxy Server"
http://support.microsoft.com/?id=307220

VS.NET uses the Wsdl.exe tool when you add web references. So you can use
Wsdl.exe directly. These are standard solutions to the proxy server issue.

Solution1
--------------
Get the wsdl file locally and add the reference to it.

- In IE on the client machine, type
http://MachineX/Webservice1/Service1.asmx?wsdl
- In IE on the client machine, go to View | Source, copy and save the wsdl
file locally named test.wsdl
- Under the VS.NET command prompt on the client machine, type c:\>wsdl.exe
test.wsdl.
- The Web service proxy source file named service1.cs is generated.
- In VS.NET, right click on the client project, Add, Add Existing Items...
to add service1.cs to the project.
- Code the client to use the web proxy server if it is necessary (see
note2).
- Build the project.

Solution2
--------------
Use the Wsdl.exe tool to specify the proxy and credentials to generate the
proxy code.

- Under the VS.NET command prompt, type: c:\>wsdl.exe
<http://MachineX/Webservice1/Service1.asmx> /proxy:proxyU RL
/proxyusername:username /proxypassword:password /proxydom ain:domain

- The Web service proxy source file named service1.cs is generated.
- In VS.NET, right click on the client project, Add, Add Existing Items...
to add service1.cs to the project.
- Code the client to use the web proxy server if it is necessary (see
note2).
- Build the project.

Note1:
Run wsdl.exe by itself, you will see a list of usage. Short forms are
'/pu:', '/pp:' and '/pd:'

Note2:
You need code the client to use the web proxy server as follows:

[C#]
MyMath.Math math = new MyMath.Math();
// Set the proxy server to proxyserver, set the port to 80, and specify to
bypass

the proxy server
// for local addresses.
IWebProxy proxyObject = new WebProxy
("http://proxyserver:80", true);
 
Hello Bill,

Thanks for the quick response. I am glad that the probem is resovled now. :)

By the way, I think we could add web reference in IDE directly even when
the client is behind a proxy. That should be what you need.

Note If you are developing a Web application on a machine that is behind
a firewall, and your application will consume Web services found outside of
the firewall, you must include the address and port of your network's proxy
server in the URL. Ask your network administrator to furnish this part of
the URL path. For more information, see The proxy settings on this computer
are not configured correctly for Web discovery..

Thanks again for participating the community.

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Yanhong, I have seen the message you posted below in the
Microsoft help file for .NET, but when I posted the
question about including the address and port of your
network's proxy in the URL to our network/firewall group
they could not provide an answer. Are there some examples
I can find for this??

Thanks again for your help!

Bill
 
Hi Bill,

Thanks for the response.

I think you could refer to this article:
"How to Configure Internet Explorer to Use a Proxy Server"
http://support.microsoft.com/?id=135982

It describes the format of this string. In IE 6.0, it could be set in
Tools->Options.

By the way, I found that you have changed your email alias. I suggest you
go to
http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam.asp
&SD=msdn
to create a no spam email alias.

If there is any question on it, please feel free to post here.

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top