.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> Web Services >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Creating Web service using C# and adding web service reference in Web application

Posted By:Pravin       Posted Date: May 24, 2012    Points: 40    Category: Web Services    URL: http://www.dotnetspark.com  

SAMPLE WEB SERVICE CREATION AND CALLING THE WEB SERVICE METHODS TO WEB APPLICATION PROJECT.
 

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 MyService : System.Web.Services.WebService
    {
        public MyService()
        {
            //Uncomment the following line if using designed components
            //InitializeComponent();
        }
 
        [WebMethod]
        public string HelloWorld()
        {
            return "Hello World";
        }
 
        [WebMethod]
        public int add(int a, int b)
        {
            return (a + b);
        }
 
        [WebMethod]
        public int Sub(int a, int b)
        {
            return (a - b);
        }
 
        [WebMethod]
        public int Mul(int a, int b)
        {
            return (a * b);
        }
    }




     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend