Search:
Namespaces
Discussions
.NET v1.1
Feedback
I want to specify the location of the web service on the client at run time...anyone?
Messages
Related Types
This message was discovered on
ASPFriends.com 'aspngwebservices' list
.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Noorez Khamis
I think i didnt clearly explain my last post. Here is the sample
scenario that I want to accomplish.
I have 3 web services.
1.
http://development/default.asmx
2.
http://staging/default.asmx
3.
http://production/default.asmx
I have one client. I have a message box on the client where i want to
specify the service to use ( ie, the above web services dev, staging, or
prod).
I know how to set the client to use one web service by using
wsdt.....url...etc......, however I want to specify the web service to
use at run time.
Anyone have any sample code or anything that could help me set this up??
Reply to this message...
Yasser Shohoud
You can set the URL property of the proxy class on the client side:
Dim ws As new TheServiceProxy
ws.Urlth;eUrl
A good place to store the URL is in the application's configuration file
much like you would a database connection string.
_______________________________________________
Yasser Shohoud
Read the book "Building Web Services with Visual Basic" at
http://www.vbws.com/book/
Read the .NET Web Services newsletter at
http://www.vbws.com/newsletter
-----Original Message-----
From: Noorez Khamis [mailto:
Click here to reveal e-mail address
]
Sent: Wednesday, September 26, 2001 4:18 PM
To: aspngwebservices
Subject: [aspngwebservices] I want to specify the location of the web
service on the client at run time...anyone?
I think i didnt clearly explain my last post. Here is the sample
scenario that I want to accomplish.
I have 3 web services.
1.
http://development/default.asmx
2.
http://staging/default.asmx
3.
http://production/default.asmx
I have one client. I have a message box on the client where i want to
specify the service to use ( ie, the above web services dev, staging, or
prod).
I know how to set the client to use one web service by using
wsdt.....url...etc......, however I want to specify the web service to
use at run time.
Anyone have any sample code or anything that could help me set this up??
| [aspngwebservices] member
Click here to reveal e-mail address
Y;OUR ID
|
http://www.asplists.com/asplists/aspngwebservices.asp
J;OIN/QUIT
|
http://www.asplists.com/search
S;EARCH Archives
Reply to this message...
Christian Weyer
E.g.:
1. In the web.config:
<appSettings>
<add key="WebserviceURI" value="
http://www.somewhere.com/webservice.asmx"
; />
</appSettings>
2. use it:
string strWebServiceURL =
System.Configuration.
ConfigurationSettings
.AppSettings["WebserviceURI"];
MyProxy objProxy = new MyProxy;
objProxy.url = strWebServiceURL;
HTH,
--
Regards,
Christian Weyer
____________________________
> The .NET Difference <
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
http://www.eyesoft.de/dotnet
____________________________
Yasser Shohoud wrote:
[Original message clipped]
Reply to this message...
doug.seven (VIP)
You can compile the proxy client using the /appsettingurlkey: argument.
This will add an if() eval in the proxy client. The if() tells the proxy to
use the config value if it is available, or the URL that the proxy was
created with if the config value does not exist.
In your config file you can add an appSetting key, and provide different
values for dev, stage, or prod.
Here's an example:
<WSDL>
wsdl.exe
http://localhost/TrivialFunTools.asmx?WSDL
/l:CS
/out:AWebService.cs /n:Proxies /appsettingurlkey:AWebServiceUrl
<this is put into the proxy class>
[System.Diagnostics.
DebuggerStepThroughAttribute
()]
public AWebService() {
string urlSetting =
System.Configuration.
ConfigurationSettings
.AppSettings["AWebServiceUrl"];
if ((urlSetting != null)) {
this.Url = urlSetting;
}else {
this.Url =
"
http://localhost/AWebService.asmx"
;;
}
}
<web.config>
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="AWebServiceUrl"
value="
http://www.dotnetjunkies.com/services/AWebService.asmx"
;
/>
</appSettings>
</configuration>
______________________________________________
doug seven | sr. developer | dotnetjunkies.com
Learn ASP.NET - Read the books...
Programming Data-Driven Web Applications with ASP.NET
http://www.amazon.com/exec/obidos/ASIN/0672321068/dotnetjunkies-20/107-10642
54-2553318
ASP.NET: Tips, Tutorials and Code
http://www.amazon.com/exec/obidos/ASIN/0672321432/dotnetjunkies-20/107-10642
54-2553318
[Original message clipped]
Reply to this message...
Matthew R. Belk
Is there a way to configure VS.NET to do this when you add a
web-reference to a project, or does this have to be done by hand. If it
has to be done by hand, would the resulting proxy class be added via the
normal "Add
Reference
..." method?
Thanks,
Matthew
=20
Matthew Belk
BizSpeed, Inc., www.bizspeed.com
4555 Mansell Rd., Ste 300
Alpharetta, GA 30022
770.521.4262
-----Original Message-----
From: doug.seven [mailto:
Click here to reveal e-mail address
]=20
Sent: Thursday, September 27, 2001 11:41 AM
To: aspngwebservices
Subject: [aspngwebservices] RE: I want to specify the location of the
web service on the client at run time...anyone?
You can compile the proxy client using the /appsettingurlkey: argument.
This will add an if() eval in the proxy client. The if() tells the proxy
to use the config value if it is available, or the URL that the proxy
was created with if the config value does not exist.
In your config file you can add an appSetting key, and provide different
values for dev, stage, or prod.
Here's an example:
<WSDL>
wsdl.exe
http://localhost/TrivialFunTools.asmx?WSDL
/l:CS
/out:AWebService.cs /n:Proxies /appsettingurlkey:AWebServiceUrl
<this is put into the proxy class>
[System.Diagnostics.
DebuggerStepThroughAttribute
()]
public AWebService() {
string urlSetting =3D
System.Configuration.
ConfigurationSettings
.AppSettings["AWebServiceUrl"]
;
if ((urlSetting !=3D null)) {
this.Url =3D urlSetting;
}else {
this.Url =3D
"
http://localhost/AWebService.asmx"
;;
}
}
<web.config>
<?xml version=3D"1.0" encoding=3D"utf-8" ?>
<configuration>
<appSettings>
<add key=3D"AWebServiceUrl"
=09
value=3D"
http://www.dotnetjunkies.com/services/AWebService.asmx"
;
/>
</appSettings>
</configuration>
______________________________________________
doug seven | sr. developer | dotnetjunkies.com
Reply to this message...
System.Configuration.ConfigurationSettings
System.Diagnostics.DebuggerStepThroughAttribute
System.Security.Cryptography.Xml.Reference
Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us
-
Terms of Use
-
Privacy Policy
-
www.dotnet247.com