asp.net web-services

Other topics

Remarks:

Now run the application that look like as follows.

enter image description here

Now in the above we see our method that we are created in the webservice.cs file, so click on that method and provide input values and click on the "invoke" link as in.

enter image description here

The output will be as follows enter image description here

Note

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

  1. "Start" - "All Programs" - "Microsoft Visual Studio 2010"
  2. "File" - "New Project" - "C#" - "Empty Web Application" (to avoid adding a master page)
  3. Provide the web site a name such as "agetodays" or another as you wish and specify the location
  4. Then right-click on Solution Explorer - "Add New Item" - you see the web service templates

enter image description here

Select Web Service Template and click on add button. then after that the Solution Explorer look like as follows.

enter image description here

Then open the Webservice.cs class and write the following method followed by [webMethod] attribute as in.

[WebMethod]
    public string HelloWorld() {
        return "Hello World";
    }

Syntax:

  1. SOAP/WSDL

    [Syntax: http://1111:22/HelloWorld]

    [Response: WDSL]

Parameters:

ParametersDescriptions
PathParamBinds the parameter passed to method to a value in path.
QueryParamBinds the parameter passed to method to a query parameter in path.
MatrixParamBinds the parameter passed to method to a HTTP matrix parameter in path.
HeaderParamBinds the parameter passed to method to a HTTP header.
CookieParamBinds the parameter passed to method to a Cookie.
FormParamBinds the parameter passed to method to a form value.
DefaultValueAssigns a default value to a parameter passed to method.
ContextContext of the resource for example HTTPRequest as a context.

Contributors

Topic Id: 8341

Example Ids: 26757

This site is not affiliated with any of the contributors.