Dynamic web service call

  • Thread starter Bruno Alexandre
  • Start date
B

Bruno Alexandre

Hi Guys,

I already build my "wonderful" webService and it returs DataSets exactly
like I want, and it does wonderful things...

but...

Now that I develop a Window Forms application that consume that web
service, I need to change the WS from my local machine to the Client machine
(so, I will change the WS address), I want to compile the Window Form App
and send it to the client, and in a Settings Menu I would be abble to add
the correct path for the web service, that's done, the thing is:

How can I, in code, use that variable instead the one that VS2005 created
automatically when I register a WebReference ?

All the help is gratly appreciate.

Thank you.

--

Bruno Alexandre
København, Danmark

"a portuguese in Denmark"
 
C

Cowboy \(Gregory A. Beamer\)

Web services have an URL property that allows you to change the URL at
runtime:

HelloWorldService.Service service = new HelloWorldService.Service();

service.Url = "new url here";

lblHello.Text = service.HelloWorld();
 
P

Paul Wu

Bruno:

When you register a web service, Visual Studios creates proxy class(es) from
the WSDL and adds the URL of the Web Service in your config file.

When you instantiate the proxy class, the URL is read from the config file.
So, when you move your application to a different computer, all you need to
do is modify the Web Service entry in the config file. The URL is in the
<applicaitonSettings> section and should be fairly obvious to find.

If you need to change the URL dynamically while the program is running, then
modifying the URL property of the Web Service (as Gregory Beamer pointed
out) would be the way to go.
 
B

Bruno Alexandre

thank you both,
exactly wnat I needed :)

--

Bruno Alexandre
København, Danmark

"a portuguese in Denmark"
 
R

Robert Lewandowski

Sorry to hijack an old thread but this is very similar to an issue I am having. I have clients that comsume a 1.1 webservice. The URL is read from a local config file so I can dynamically change it if I needed to. However there is another wrinkle. When the webservices get recompiled under .NET 2.0 the clients stop working. It seems to me that the clients shouldnt care about the version the webservices are compiled under. Any insight appreciated! Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,157
Latest member
MercedesE4
Top