Hi craighb,
Yes, sure, you can make the webservice proxy class(defined in class library
project)'s url configurable in your ASP.NET web application, just follow
this way:
** in your class library project(which contains the webservice proxy), open
the app.config file generated by the IDE, you can find the following style
configuration:
==============
<configuration>
<configSections>
<sectionGroup name="applicationSettings"
type="System.Configuration.ApplicationSettingsGroup, System,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="ClassLibrary1.Properties.Settings"
type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"
/>
</sectionGroup>
</configSections>
.........................
<applicationSettings>
<ClassLibrary1.Properties.Settings>
<setting name="ClassLibrary1_wsvc_Service" serializeAs="String">
<value>
http://servername/WCFSVC/Service.svc</value>
</setting>
</ClassLibrary1.Properties.Settings>
</applicationSettings>
</configuration>
=================================
the above configuration elements are generated by IDE to store the url of
webservice proxy. To allow any other projects (which reference this class
library and use the webservice proxy) to change the url, you can copy all
the above configuration sections into the target application's
app.config(or web.config for ASP.NET app).
For example, suppose my ASP.NET web application use added reference to the
class library and use that webservice proxy, I can override the proxy url
in web.config as below:
================
<configuration>
<configSections>
<sectionGroup name="applicationSettings"
type="System.Configuration.ApplicationSettingsGroup, System,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="ClassLibrary1.Properties.Settings"
type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"
/>
</sectionGroup>
</configSections>
<connectionStrings>
<add name="ClassLibrary1.Properties.Settings.testdbConnectionString"
connectionString="Data Source=localhost;Initial
Catalog=testdb;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
<applicationSettings>
<ClassLibrary1.Properties.Settings>
<setting name="ClassLibrary1_wsvc_Service" serializeAs="String">
<value> [ Your overrided new url address here] </value>
</setting>
</ClassLibrary1.Properties.Settings>
</applicationSettings>
<system.web>
....
</system.web>
</configuration>
==================
BTW, since you can programmtically change proxy.Url property, you can also
consider add a simple name/value pair in web.config's AppSettings section
and use code to always assign url from that name/value pair in your ASP.NET
code (where you will call the webservice proxy).
Hope this helps.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------