URL behavior attributes using the ASP.NET Web service agent

xiaoxiao2021-03-05  23

in

vs.net

Mutually call

ASP.NET Web Service

At the time, the default generated proxy class

URL

The behavior uses a static value, if

Web

The service is transferred, and it is possible to appear unacceptable situations.

Web

The service retries generates a new proxy class, which brings many inconveniences to the program deployment, the solution is to set up

URL

Behavior uses dynamic values, and may not know how to have this feature for many people, including my previous colleagues, I wrote this article, provide some help, of course, the best instructions or through instances .

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.

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.

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 to the in the configuration file. "Value =" "/>, personal feeling is better to use specialized element nodes to include this information, not appsetting Other information is mixed, as a dedicated setting like the database connection string in .NET Framework 2.0. This article refers to the "Microsoft .NET programming technology insider".

转载请注明原文地址:https://www.9cbs.com/read-32259.html

New Post(0)