More Information needed

S

Shimon Sim

Hi
I am starting using WS in my applications. So I know how to create, publish
and consume them.
I am bothered by a question with following scenario
I want to create application that has WS as part of it. This application
could be deployed on different servers that I may not be aware of.
How can client that used one server connect to the same WS but on the other
server without recompiling?

What do I have to do to allow client to be tested on one server but then
easily connect to production WS without any involvement of a developer.( End
user could adjust URL)

Thank
Shimon
 
D

Dilip Krishnan

Hello Shimon,

Quoted
"Here's how to do it:
Add your web reference. Go to "Solution Explorer", right click on the web
reference name (eg. "localhost") and choose properties. In the property
window change "Url Behavior" from "Static" to "Dynamic".

If the web service client is a non-web application, this will automatically
create a file name app.config with the URL to the web service.

<appsettings>
<add key="myapplication.mywebservice.service1"
value="http://localhost/mywebservice/service1.asmx";
</appsettings>

After you comiple your client app, the configuration file of it (such as
something.exe.config) will have the same content as the app.config.
Now, you can deploy the configuration along with the client executable. If
you ever need to change the web service location, you can open the
something.exe.config file in notepad and change the value attribute.

If the web service client is a web application such as asp.net web form,
changing "Url Behavior" from "Static" to "Dynamic" will automatically add
the same appsettings to web.config. Now, if you ever need to change the web
service location, you can open web.config file in notepad and change the
value attribute.

For Service URLs that change more often or at runtime, you can write custom
code to change the URL property off of the proxy class.

e.g.

ws.GetCustomers()
ws.Url = CompatibleCustomerServices(2) //bind to a the next compatible
service in the list
ws.GetCustomers()"

HTH
Regards,
Dilip Krishnan
MCAD, MCSD.net
dkrishnan at geniant dot com
http://www.geniant.com
 
S

Shimon Sim

Thank you.
Shimon
Dilip Krishnan said:
Hello Shimon,

Quoted
"Here's how to do it:
Add your web reference. Go to "Solution Explorer", right click on the web
reference name (eg. "localhost") and choose properties. In the property
window change "Url Behavior" from "Static" to "Dynamic".

If the web service client is a non-web application, this will
automatically
create a file name app.config with the URL to the web service.

<appsettings>
<add key="myapplication.mywebservice.service1"
value="http://localhost/mywebservice/service1.asmx";
</appsettings>

After you comiple your client app, the configuration file of it (such as
something.exe.config) will have the same content as the app.config.
Now, you can deploy the configuration along with the client executable. If
you ever need to change the web service location, you can open the
something.exe.config file in notepad and change the value attribute.

If the web service client is a web application such as asp.net web form,
changing "Url Behavior" from "Static" to "Dynamic" will automatically add
the same appsettings to web.config. Now, if you ever need to change the
web
service location, you can open web.config file in notepad and change the
value attribute.

For Service URLs that change more often or at runtime, you can write
custom
code to change the URL property off of the proxy class.

e.g.

ws.GetCustomers()
ws.Url = CompatibleCustomerServices(2) //bind to a the next compatible
service in the list
ws.GetCustomers()"

HTH
Regards,
Dilip Krishnan
MCAD, MCSD.net
dkrishnan at geniant dot com
http://www.geniant.com
 

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,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top