-----------------------------------------------------------
New Message on BDOTNET
-----------------------------------------------------------
From: LovedJohnySmith
Message 1 in Discussion
Good Day Folks
I've been working on getting TCPTrace and friends to work on my machine (more
about that later), and I have discovered the distinction between static and
dynamic Web references in Visual Studio .NET 2003.
One of the properties of a Web reference in Visual Studio .NET 2003 is called
�URL Behavior� and can be set to a value of �Static� or �Dyanmic�. The
difference between the two is in the differing constructor generated in the
reference.cs (reference.vb) file for your proxy class.
A �Static� reference simply sets the class' �URL� property (inherited from the
class' base) to the URL specified in the reference's �Web Reference URL�
property:
[System.Diagnostics.DebuggerStepThroughAttribute()]<o:p></o:p>
[System.ComponentModel.DesignerCategoryAttribute("code")]<o:p></o:p>
[System.Web.Services.WebServiceBindingAttribute(Name="WSSoap",
Namespace=http://tempuri.org/)]<o:p></o:p>
public class WS : System.Web.Services.Protocols.SoapHttpClientProtocol
{<o:p></o:p>
<o:p></o:p>
/// <remarks/><o:p></o:p>
public WS() {<o:p></o:p>
this.Url = http://localhost:81/WSSecurity/WS.asmx;<o:p></o:p>
}<o:p></o:p>
By contrast, a �Dynamic� reference looks for the URL reference in the
application's config file before using the hardcoded URL:
[System.Diagnostics.DebuggerStepThroughAttribute()]<o:p></o:p>
[System.ComponentModel.DesignerCategoryAttribute("code")]<o:p></o:p>
[System.Web.Services.WebServiceBindingAttribute(Name="WSSoap",
Namespace=http://tempuri.org/)]<o:p></o:p>
public class WS : System.Web.Services.Protocols.SoapHttpClientProtocol
{<o:p></o:p>
<o:p></o:p>
/// <remarks/><o:p></o:p>
public WS() {<o:p></o:p>
string urlSetting =
System.Configuration.ConfigurationSettings.AppSettings["Client.localhost.WS"];<o:p></o:p>
if ((urlSetting != null)) {<o:p></o:p>
this.Url = string.Concat(urlSetting, "");<o:p></o:p>
}<o:p></o:p>
else {<o:p></o:p>
this.Url = http://localhost:81/WSSecurity/WS.asmx;<o:p></o:p>
}<o:p></o:p>
}<o:p></o:p>
The �Dynamic� constructor look's in the app's config file for a config setting
for the URL and uses the hardcoded value only if the app setting does not
exist. Using the constructor above, we could write a config file as follows:
<?xml version=�1.0� encoding=�utf-8� ?>
<configuration>
<appSettings>
<add key=�Client.localhost.WS�
value=�http://localhost:81/WSSecurity/WS.asmx� />
The name of the key will be dependent on the name of your client app and the
name of the vWeb service reference, so check your constructor for the name of
the app settings key to use for your particular project.
Using a �Dynamic� reference allows you to override the default settings and
change Web reference more easily from the application's config file.
Please lemmi noe.. your comments.
Thanx,
Smith
-----------------------------------------------------------
To stop getting this e-mail, or change how often it arrives, go to your E-mail
Settings.
http://groups.msn.com/bdotnet/_emailsettings.msnw
Need help? If you've forgotten your password, please go to Passport Member
Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help
For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact
If you do not want to receive future e-mail from this MSN group, or if you
received this message by mistake, please click the "Remove" link below. On the
pre-addressed e-mail message that opens, simply click "Send". Your e-mail
address will be deleted from this group's mailing list.
mailto:[EMAIL PROTECTED]