Dynamic web service binding during runtime

A

Anonymous

When we develop web service client and server program,
normally we need to add the webservice into the client, then compile it.

This way, the client can ONLY connect to this particular web service.

What if I have 5 servers providing the same webservice.
I would like the client to be able to pick either one to connect to
during "runtime".

So far, I read that I have to use SOAP (still not very sure how to do this).
Anyone has suggestions?

Thank you!
 
N

Nicholas Paldino [.NET/C# MVP]

Anonymous,

You shouldn't need to add the web service code to the client. You
should be able to add a reference in VS.NET to the web service (as long as
it is producing a WSDL file to describe itself) and then it will create a
proxy on the client side which will make the call for you.

Then, in your code, you can set the URL to the web service on the client
side. This way, you can have a list of servers to contact, and then choose
which one you want to connect to (through the proxy, that is).

Hope this helps.
 
A

Anonymous

Thanks Nic,

How do I set the URL to the web service on the client side during runtime?
 
N

Nicholas Paldino [.NET/C# MVP]

The proxy class should have a Url property which you can set in your
code which will be the url for the web service.
 
A

Anonymous

So I look for this file called "Reference.cs".
Then inside it's constructor, there is a this.Url = .........
This is where i fiddle with?
 
N

Nicholas Paldino [.NET/C# MVP]

Anonymous,

You shouldn't play with the code that the reference generates. Rather,
when you create an instance of your web proxy, after it is created, just set
the Url property to the appropriate URL.
 

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

Top