Guruji Point - Code You Want To Write

  • Home
  • Asp.Net
  • WCF
  • SQL
  • Type Script
  • AngularJS
  • Tech News
  • Blog
  • Earn Online

Monday, 20 March 2017

Create A Web Service In Asp.Net Using Visual Studio 2015

 Webservice     2 comments   



Introduction
In this post we will learn about how to create a Web Service in asp.net using Visual Studio 2015. How to run service project and also detail about the basic terms used in Service like WebMethod etc.


Description
 VS 2015 doesn't allows you to create a Web Service project like VS 2010, 12 etc.  Microsoft update its VS-15 with new features . Peoples are very rarely use the web service in  today's modern world. Because we have a Web Api concept also WCF service. 
But many times you only have a small service requirement ,for these situation this post will be the best understanding explanation for you about the service creation in c# asp.net.
As we already talked about Web Service basics in previous update about service.


Practice
Here we create a Web Service in 4 simple steps. 

1.  Open VS2015  and Create a New WebSite . Select an Empty Website template ,give a suitable name to it ( in my example its name DemoWebService ) and click OK.


2.  After creating new WebSite goto Solution Explorer , select Website Name and right click, select Add New Item and select WebService type page. give a suitable name to this . Here i named this TestService.


 After adding webService page your code looks like this


3. Remove given Web Method if you don't want to use this and create your own method based upon your requirement. Here i create a AgeCalulator method named GetAge.


[WebMethod]
  public string GetAge(DateTime Dob)
  {
      DateTime PresentYear = DateTime.Now;

      TimeSpan ts = PresentYear - Dob;
      int Age = ts.Days / 365;
      return Age.ToString(); 
  }


GetAge method will return age in year  and accept the datetime  type of input variable as a parameter. 

4. Build Project and right click on your asmx page and choose Setas StartPage and Run the                     Application.



You will find the similar type of screen in front of you after running the application. And its all done, you have successfully created a Web Service just in 4 simple steps. 

Test Web Service 
Click on the method which created earlier in my example it is GetAge 

As we can see i used Dob as parameter name in my WebMethod and in the above image it is clearly shown field name Dob. Enter any Dob in DD/MM/YY format and click on Invoke Button.
Here is the output given by the web service which is 21 conversion of given DOB.

<string xmlns="http://gurujipoint.com/">21</string>

You can add as many methods you want in this service and use these wherever you want in any application by giving your service reference. In my next article i will explain you how to consume this web service.

Points To Remember  :-
  • Web Service is a communication platform between two same or different platform application.
  •  Method in Web service always start with Web-Method attributes which tells about it is a web method which is accessible from anywhere in application.






  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
Email ThisBlogThis!Share to TwitterShare to Facebook
Newer Post Older Post Home

2 comments:

  1. for ict 9931 July 2020 at 22:24

    IEEE Final Year projects Project Centers in Chennai are consistently sought after. Final Year Students Projects take a shot at them to improve their aptitudes, while specialists like the enjoyment in interfering with innovation. For experts, it's an alternate ball game through and through. Smaller than expected IEEE Final Year project centers ground for all fragments of CSE & IT engineers hoping to assemble. Final Year Projects for CSE It gives you tips and rules that is progressively critical to consider while choosing any final year project point.

    Spring Framework has already made serious inroads as an integrated technology stack for building user-facing applications. Spring Framework Corporate TRaining the authors explore the idea of using Java in Big Data platforms.
    Specifically, Spring Framework provides various tasks are geared around preparing data for further analysis and visualization. Spring Training in Chennai


    The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training

    ReplyDelete
    Replies
      Reply
  2. شركة كواليتي للخدمات المنزلية5 December 2021 at 01:47

    شركة تعقيم في الشارقة

    ReplyDelete
    Replies
      Reply
Add comment
Load more...

Facebook Updates

Guruji Point

Categories

comma seperated string in sql Comman table Expression in SQL Dynamic Grid Row IQueryable in c# Learn AngularJS row_number() and dense_rank() salary table structure. Scope_Identity() Use of indexes while loop in sql why do we need cursor why tuple used

About Us

This blog is about the Programming ,Tech News and some intresting facts related Contents. Here you can find fundamental and expert level topic of programming languages very practically related to C# , Asp.Net ,Sql-Server, JavaScript, Jquery, WebServices And also Web-Api, WCF ,WPF, Angular Js.

Contact Us

Email Us - gurujipoints@gmail.com
Contact- 8077657477

Reach Us

Copyright © Guruji Point - Code You Want To Write