URL behavior attributes using the ASP.NET Web service agent
Zhengzuo
2005-4-6
When calling the ASP.NET Web Service in vs.net, the default generated proxy class's URL behavior uses a static value. If the web service is transferred, it may have an unacceptable situation, and the web service needs to be re-referenced. Generate new proxy classes, which brings many inconveniences on program deployment, and the solution is to set up the URL behavior. For many people who don't pay attention, I may not know that this feature, including my previous colleagues, so write This article provides some help for some friends, of course, the best instructions or through examples.
For example, the original Web Service is in 192.192.132.97, and the IP is 192.192.132.95 after modifying the Web Service to another computer.
Select the node under the Web References (here the ServerFileManager is folder name), list the following properties:
URL: http:// localhost / redmanager / web references / serverfilemanager /
URL behavior: static
Web reference URL: http: // 192.192.132.97/redupload/UPLOADFILESERVICE.ASMX
Folder name: ServerFileManager
Here, you need to re-compile the original service correctly by modifying the new IP address to 192.192.132.95.
The constructor of the generation of the agent class is as follows:
Public UploadFileService ()
{
THIS.URL = "http: // 192.192.132.95/redupload/uploadfiaservice.asmx";
}
The above is the problem, it is written inside.
Below is a solution
Modify the URL behavior value is dynamic, and the following configuration information will be added to the web.config.
appsettings>
Let's take a change in the constructor of the service agent class.
Public UploadFileService ()
{
String urlsetting = system.configuration.configurationSettings.appsettings ["redmanager.serverfilemanager.uploadFileService"];
IF ((UrlSetting! = NULL))
{
THIS.URL = String.concat (Urlsetting, "");
}
Else
{
THIS.URL = "http: // 192.192.132.95/redupload/uploadfiaservice.asmx";
}
}
Since then, we can adjust the program by modifying configuration information in the web.config configuration file without having to recompile the code.
If you use the command line, you can implement the language tool (WSDL.exe) through the web service.
Wsdl.exe / urlkey: redmanager.serverfilemanager.uploadFileService "http: // 192.192.132.95/Redupload/uploadFileService.asmx or
WSDL.EXE / AppSettingURLKey: Redmanager.serverFileManager.uploadFileService "http: // 192.192.132.95/redupload/uploadFiaservice.asmx
From the above, it will add