ASP.Net Team,
In .Net 1.1, we do not call Web Services directly in ASP.net code.
We create separate DLL project and then call Web Service within that DLL.
Here is what happens with VS.Net 2005: When a DLL adding Web Reference to a Web Services,
a new App.Config and a new Settings.setting file are created, with url
saved in these files ( such as http://localhost:1056/WebService1/Service1.asmx). When we
complie the DLL project, the Url shows up in complied DLL (revealed by ILDASM).
Obviously, when this DLL is deployed with WAP, no one can change WebService
url endpoint since it is compiled into a DLL --- this is a problem for deployment configuration
since we need to recompile the DLL and WAP/WebSite in order to retarget WebService EndPoint.
If you look at WebService Proxy carefully, it uses
"Global.ClassLibrary1.My.MySettings.Default.ClassLibrary1_localhost_Service1"
no long uses AppSetting as in .Net 1.1
One the other hand, if I call WebService directly from ASP.Net (WAP or WebSite), I can change
WebService Endpoint Url from Web.Config since there are no DLL at all.
Question: During our Migration using WAP, Should we stay away from Facade design pattern so that
WebServices ALWAYS get called from ASP.Net codebehind ?
Does this mean the end to Facade pattern or this is something that can be fixed in
VS.Net 2005 SP1, particular for people who use WAP?
Steps to re-produce:
Step1. Create a blank Solution
Step2. Crate a WebService Project
Step3. Create a ClassLibrary Project and Add Web Reference to 2. (This is Facade DLL)
Note that VS.Net 2005 will default Web Reference as dynamic.
And therefore, there will be a App.Config file with
http://localhost:1056/WebService1/Service1.asmx as one property
And there is another file Settings.setting repeat the same information.
Step4. Write a function for the class to return URL of the WebService Proxy
public string Test()
{
return (new localhost.Service1()).Url;
}
Step5. Create a WAP and add Step3 DLL as Reference.
Step6 Add a Label to default.aspx in the WAP and code as in
proected void Page_Load(..)
{
this.Label1.Text=(new ClassLibrary1.Class1()).Test();
}
Step7. Browser Default.aspx (do not run debug) and you should see
http://localhost:1056/WebService1/Service1.asmx
Step8 Change App.Config, Web.Config, Settings.settings in all places using notepad to
http://localhost:7777/WebService1/Service1.asmx
Step9. Refresh the browser showing default.aspx and you will NOT see the changes made.
Note: the same happens when WAP is published, where only Web.Config can be changed.
Partial Copy from ILDasm:
.custom instance void [System]System.Configuration.DefaultSettingValueAttribute::.
ctor(string) = ( 01 00 1E 68 74 74 70 3A 2F 2F 6C 6F 63 61 6C 68 // ...http://localh
6F 73 74 2F 53 65 72 76 69 63 65 31 2E 61 73 6D // ost/Service1.asm
78 00 00 ) // x..