您的位置:首页 > 其它

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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: