Create and publish a Web Service
A DataSet object can be returned in a Web service method
Web services can be said to be the foundation of next-generation Web applications, regardless of whether the client is a Windows application, an ASP. NET Web Form program, or even a client in another language, can communicate with the same WEB service, its platform and language independence gives it a broad space for development.
With VS2005 and IIS, we can easily publish a web SERVICE
Environment: Windows Server 2003,.net FrameWork 2.0,iis6.0
Tool: VS2005
1. First create a new Web service project in VS2005.
Open file, new, Web site, and in the dialog box, select ASP. VS2005 automatically generates a Service.cs file with the following code:
C # code
- Using System;
- Using System.Web;
- Using System.Web.Services;
- Using System.Web.Services.Protocols;
- [WebService (Namespace = "http://tempuri.org/")]
- [WebServiceBinding (ConformsTo = wsiprofiles.basicprofile1_1)]
- Public class Service:System.Web.Services.WebService {
- Public Service () {
- //If you are using a design component, uncomment the following line
- //initializecomponent ();
- }
- [WebMethod]
- public String HelloWorld () {
- return "Hello World";
- }
- }
You can modify your own namespace here, add your own method, but this article just to illustrate how to create and publish, so do not make any changes to Service.cs. It may be necessary to add DLLs to the project, such as Log4net.dll, in addition to being declared in the code: using Log4net; There is also the right-add reference-add the DLL on the project. It will eventually be added to the Bin folder of the project's root directory.
2. Build a Web site
Very simple, "build", "Build Web Site" or direct SHIFT+F6
3. Publishing a website
is also simple, "build", "publishing Site", here will pop up a dialog box, nothing to modify, note the published directory. For example, C: \ My document \visual Studio 2005\projects\website1\precompiledweb\website1, we need the files in the directory.
4. Configure IIS
In Windows Server 2003, for example, if IIS is not installed on the server, you must first install:
Control Panel Add Remove, Add/Remove components, application Server, Internet Information Services
If the installation process requires 2003 of the data on the installation CD, specifically, such as the CD-ROM ISO file after decompression:
Cn_win_srv_2003_r2_enterprise_with_sp2_vl_cd1\i386
Then choose what is prompted on the dialog box, such as Iisback.vb_
Enter IIS:
Internet Information Services Manager, Administrative Tools
Create a new virtual directory under the IIS Manager-Web site-Default Web site (or create a new one yourself), such as WebService, and copy all the files and directories in the 3rd release directory to this directory, open IIS, locate your site, right-click on the WebService directory, Select Properties, in the "Virtual directory" tab of the Pop-up dialog box, after the application name, click the "Create" button, then OK.
By this time, it should have been completed, you can verify by accessing http://Domain/webservice/service.asmx.
At this point, it is still possible to have a bad access and, if there is no ASP. NET tab in the WebService virtual directory created above, it is likely that the problem is as follows.
Attention:
When the program may need to run on the Framework2.0 framework, the default. NET environment in IIS is 1.1. An unrecognized node problem occurs.
Workaround:
Upgrade. NET environment to 2.0, start-to-run, cmd-
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe-i
Sometimes you will still be prompted to install the. NET Framework 3.5 or later
After the installation is complete, there may be some minor problems, such as no permissions to execute the script ah, then in the virtual directory-Execute permissions to select the pure script
If there are 404, then:
JS Code
- IIS access aspx file display 404 can't find the file?
- Workaround:
- Microsoft Windows [version 5.2.3790]
- (C) Copyright 1985-2003 Microsoft Corp.
- C:\Documents and SETTINGS\ADMINISTRATOR>CD c:\windows\microsoft.net
- C:\WINDOWS\MICROSOFT.NET>CD fra*
- C:\WINDOWS\MICROSOFT.NET\FRAMEWORK>CD v2*
- C:\windows\microsoft.net\framework\v2.0.50727>aspnet_regiis-i-enable
- Start installation of ASP. NET (2.0.50727).
- .........................................................
- ASP. NET (2.0.50727) installation is complete.
- C:\windows\microsoft.net\framework\v2.0.50727>
Referenced from: http://www.cnblogs.com/mrray/archive/2010/11/24/1886300.html
See the Run Web page right-click on the asmx file to browse directly.