If you closely observe that ,there is no separate web service template in .Framework 2010 as you see in 2008 while adding a project or web site it might be because of WCF.
So let us start using a different way to add a web service using a template
- "Start" - "All Programs" - "Microsoft Visual Studio 2010"
- "File" - "New Project" - "C#" - "Empty Web Application" (to avoid adding a master page)
- Provide the web site a name such as "agetodays" or another as you wish and specify the location
- Then right-click on Solution Explorer - "Add New Item" - you see the web service templates
Select Web Service Template and click on add button. then after that the Solution Explorer look like as follows.
Then open the Webservice.cs class and write the following method followed by [webMethod] attribute as in.
[WebMethod]
public string HelloWorld() {
return "Hello World";
}
SOAP/WSDL
[Syntax: http://1111:22/HelloWorld]
[Response: WDSL]
Parameters | Descriptions |
---|---|
PathParam | Binds the parameter passed to method to a value in path. |
QueryParam | Binds the parameter passed to method to a query parameter in path. |
MatrixParam | Binds the parameter passed to method to a HTTP matrix parameter in path. |
HeaderParam | Binds the parameter passed to method to a HTTP header. |
CookieParam | Binds the parameter passed to method to a Cookie. |
FormParam | Binds the parameter passed to method to a form value. |
DefaultValue | Assigns a default value to a parameter passed to method. |
Context | Context of the resource for example HTTPRequest as a context. |