Set up and deploy WebService, use simple applications in combination with Entity classes, and use webservice entities
Environment: VS2013
IIS: IIS6
1. Build
1. Create a project, add an ASP. NET empty Web application, and select. NET Framework4
2. Add a Web Service (ASMX) to the project)
3. Add the server method to the WebService1.asmx file. Here, add a test method.
Note: Do not omit [WebMethod] before the method so that remote Web clients can call this method.
2. Distributed WebService
1. Right-click the project and select "publish" from the menu"
2. Create a configuration file named "config1"
Select the connection option, select the file system for the publishing method, and select the location where WebService needs to be released
Set: to Release
The webService is published successfully. The output shows that the webService is published successfully. The following file is displayed at the target location.
Note: The desktop cannot be selected for the target location, and the files on the desktop have access permissions, which can easily be published to IIS and cannot be accessed. Whether or not the paths under drive C are inaccessible has not been tested.
3. Deploying IIS
1. Add an application under the Default Web Site and set the alias. This is as happy as you are. It doesn't matter. Select the WebService release location in the physical path.
2. Click Browse. The following information is displayed in the browser. Click "WebService1.asmx" to Display Server errors. the. NET Framework shown in the version information column is 2.0,
However, we selected. NET Framework 4.0 when creating a WebService.
3. Add a. NET Framework 4.0 Application pool to the application pool.
Select advanced settings for the WebService application, change the application pool to the new one, and repeat the above two steps,
In the browser, we can see the method we just added in webService. asmx,
Click service description to jump to the wsdl mode.
So far, WebService has been released and deployed successfully.
4. The client calls the WebService server Method
1. Create a project, create a console application, select a project, right-click the project, and add a service reference.
2. Add the previously released WebService to the address. if the service is not found in the drop-down list, click discover,
After selecting the address, click "go to" to view the service.
3. Click "advanced", click "add Web reference", select WebService as the URL, and add reference.
Added successfully. You can see web references in the project.
4. Call the server method in the client program
5. Applications of WebService and entity classes
1. Add [Serializable] to the front of the object class, and [XmlInclude (typeof (Book)]
2. regenerate the project and publish WebService. Update the web reference on the client to call the Book object and create a method.
The call method and result are as follows:
3. Use of inherited classes