How to create simple web service in VS2010, NOT WCF service
2013-09-11 17:49
435 查看
The way I created a WebService "Hello World" project using Visual Studio 2010 with .Net 4.0 is as follows:
1. File -> New -> Project
2. Temporarily Select .NET Framework 3.5 from the dropdown list at the top center of the New Project Dialog Box.
3. Select Template "ASP.NET Web Service Application - OK
4. In the Solution Explorer right click on the WebService1 project within the Solution WebService1 -select Properties on the bottom
5. On the Application Tab change the Target framework back to
.NET Framework 4.0
6. Confirm all the warning that you'll have to manuall change things, etc.
7. press F5 to start the Hello World App
What should you see:
8: A browser launches with http://localhost:4001/Service1.asmx as the URL with a link named HelloWorld which is the WebMethod
9: Click the HelloWorld Link and click Invoke
10: Output:
< div> <?xml version="1.0" encoding="utf-8"
?> </div> <div> <div style="TEXT-INDENT: -2em; MARGIN-LEFT: 1em" mce_style="TEXT-INDENT: -2em; MARGIN-LEFT: 1em">
<string xmlns=http://tempuri.org/>Hello World</string>
</div> <div style="TEXT-INDENT: -2em; MARGIN-LEFT: 1em" mce_style="TEXT-INDENT: -2em; MARGIN-LEFT: 1em"> </div> <div style="TEXT-INDENT: -2em; MARGIN-LEFT: 1em" mce_style="TEXT-INDENT: -2em; MARGIN-LEFT: 1em"> Hello World is the return value of the HelloWorld
method</div> <div style="TEXT-INDENT: -2em; MARGIN-LEFT: 1em" mce_style="TEXT-INDENT: -2em; MARGIN-LEFT: 1em"> </div> <div style="TEXT-INDENT: -2em; MARGIN-LEFT: 1em" mce_style="TEXT-INDENT: -2em; MARGIN-LEFT: 1em"> You're off and running.. Have Fun.</div>
<div style="TEXT-INDENT: -2em; MARGIN-LEFT: 1em" mce_style="TEXT-INDENT: -2em; MARGIN-LEFT: 1em"> </div> <div style="TEXT-INDENT: -2em; MARGIN-LEFT: 1em" mce_style="TEXT-INDENT: -2em; MARGIN-LEFT: 1em"> </div></div>
1. File -> New -> Project
2. Temporarily Select .NET Framework 3.5 from the dropdown list at the top center of the New Project Dialog Box.
3. Select Template "ASP.NET Web Service Application - OK
4. In the Solution Explorer right click on the WebService1 project within the Solution WebService1 -select Properties on the bottom
5. On the Application Tab change the Target framework back to
.NET Framework 4.0
6. Confirm all the warning that you'll have to manuall change things, etc.
7. press F5 to start the Hello World App
What should you see:
8: A browser launches with http://localhost:4001/Service1.asmx as the URL with a link named HelloWorld which is the WebMethod
9: Click the HelloWorld Link and click Invoke
10: Output:
< div> <?xml version="1.0" encoding="utf-8"
?> </div> <div> <div style="TEXT-INDENT: -2em; MARGIN-LEFT: 1em" mce_style="TEXT-INDENT: -2em; MARGIN-LEFT: 1em">
<string xmlns=http://tempuri.org/>Hello World</string>
</div> <div style="TEXT-INDENT: -2em; MARGIN-LEFT: 1em" mce_style="TEXT-INDENT: -2em; MARGIN-LEFT: 1em"> </div> <div style="TEXT-INDENT: -2em; MARGIN-LEFT: 1em" mce_style="TEXT-INDENT: -2em; MARGIN-LEFT: 1em"> Hello World is the return value of the HelloWorld
method</div> <div style="TEXT-INDENT: -2em; MARGIN-LEFT: 1em" mce_style="TEXT-INDENT: -2em; MARGIN-LEFT: 1em"> </div> <div style="TEXT-INDENT: -2em; MARGIN-LEFT: 1em" mce_style="TEXT-INDENT: -2em; MARGIN-LEFT: 1em"> You're off and running.. Have Fun.</div>
<div style="TEXT-INDENT: -2em; MARGIN-LEFT: 1em" mce_style="TEXT-INDENT: -2em; MARGIN-LEFT: 1em"> </div> <div style="TEXT-INDENT: -2em; MARGIN-LEFT: 1em" mce_style="TEXT-INDENT: -2em; MARGIN-LEFT: 1em"> </div></div>
相关文章推荐
- How to create, host, test and consume a WCF Web Service
- javax.xml.ws.WebServiceException: WSDL Metadata not available to create the proxy, either Service in
- How to Create Multilingual Webpart in SharePoint 2010 (C# 方式)
- [Solution]How to create Project Web App in SharePoint
- Web.Config - create WCF REST Service and host in Windows Azure
- [转]VSTO+WinForm+WebService+WCF+WPF示例
- How to Configure an SSIS Package to Access a Web Service using WCF
- How to create RESTful WCF Service
- Learn how to create a simple virtual layout in Flex 4
- How and Why to use the System.servicemodel.MessageParameterAttribute in WCF
- The service cannot be activated because it does not support ASP.NET compatibility. ASP.NET compatibility is enabled for this application. Turn off ASP.NET compatibility mode in the web.config or add the AspNetCompatibilityRequirements attribute to the ser
- How To Write A Simple PHP/MySQL Web Service for an iOS App(1)
- How to create a generic WCF service proxy ?
- How To Write A Simple PHP/MySQL Web Service for an iOS App(2)
- VSTO+WinForm+WebService+WCF+WPF示例
- How to verify ntp service properly or not in linux/unix
- How to get MetaData on client side in WCF?如何在客户端获取WCF service的元数据
- How to create WSDL SourceCode from a webservice.
- How to invoke Java web service in ASP.net using C#
- SharePoint 2010 查询不以某个字符开头的数据[How to Create a SharePoint “Does Not Begin With” Filtered List View]---计算栏的妙用