You must Sign In to post a response.
  • Category: ASP.NET

    How to implement webservice in asp.net ?


    Are you looking for a way to implement webservice in asp.net ? then read this thread to know more about it



    I have not used any web service in my project.Can any body tell me at what situation u ppl made it?It will good if u provide code also.Thanks in advance.
  • #743112
    A Web service is a unit of managed code that can be remotely invoked using HTTP, that is, it can be activated using HTTP requests. So, Web Services allows you to expose the functionality of your existing code over the network.Web Services allows different applications to talk to each other and share data and services among themselves. Other applications can also use the services of the web services. For example VB or .NET application can talk to java web services and vice versa. So, Web services is used to make the application platform and technology independent.Web Services uses standardized industry standard protocol for the communication. All the four layers (Service Transport, XML Messaging, Service Description and Service Discovery layers) uses the well defined protocol in the Web Services protocol stack.
    Web Services uses SOAP over HTTP protocol for the communication, so you can use your existing low cost internet for implementing Web Services.

    Sample code:

    ASP.NET Web Service file name has extension asmx and create a Web service project and add a file that is named MyWebService.asmx,

    Following is the code in asmx file
    <%@ WebService Language="C#" class="MyClass" %>

    and the back end file is as shown below

    using System.Web.Services ;

    public class MyClass
    {
    [WebMethod()]
    public int Add ( int a, int b)
    {
    return a + b ;
    }
    }
    The page directive WebService is required and class is the name of the .NET Class to expose the Web Service, each method exposes as Web Service Class Method need to have a declarative attribute statement [WebMethod()] in front of it.

    Now your service is ready and There are many ways to consume Web Services

    For more information you can use the link
    http://www.codeproject.com/Articles/1231/ASP-NET-Web-Service

  • #743114
    Yes I am familiar with web service.But I want real time senario where u made web service with code.

  • #743129
    Hai Pinky,
    Whenever you need a functionality which is independent to your project and can be made as a unit and also used at various places in the applications(not only in one application), in those cases, you can make the web service.
    It will reduce the effort to do it in all the applications.
    Lets take an example where I want a functionality which should convert my ClientIndex policy to New Business policy.This is the common functionality and can be used in various applications running in the system.
    Few applications needs to provide the Client Index policy and want to get the New Business policy as the output.
    It needs some logic to get the NB policy back. It needs to check few database tables, and then decide whether the policy exists for the comparable Client index policy.
    So in these kind of scenarios, we can use to build the web service.
    This unit of work can also be used in other applications like in Biztalk server where they need to get the NB policy when providing the Client Index in their orchestration for the further work. So they can consume this service in their Orchestration and get their work done.
    Hope it will be helpful to you.

    Regards,
    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)
    pawansoftit@gmail.com

  • #743138
    hii,
    Webservices are used for the service oriented application.
    i.e for resuablity let us take a example that we are making a service which contains the function for sum of two numbers.
    Now when ever we required this function we can use it from their either in desktop application or in web application.Single service can be used by multiple user.for using the service you have to add reference of it to your project and after that you can access the methods of it.

    Hope this helps you.
    Regards
    Shalini

  • #743150
    The most important advantages of using web services/WCF are re-usability, and interoperability.

    Here re-usabality means you will be developing a webservice/WCF for common task and you will be able to same across the application without much issues. Suppose you have multiple client and both clients are using weather forecast in that case you can make a single webservice/WCF which provides weather information and can be utilized in both application so it reduces your work load.

    Interoperability helps you to develop the webservice/WCF in your preferred language and deploy it in your preferred location. It doesn't matter whihc platform it is developed and which plat form it is consuming. Webservices/WCF are platform independent.

    Another advantage is it's ease of deployment over the net because it uses standard internet protocol.
    If you are new to this concept then go through below tutorials :wcftutorial.net/


    Regards,
    Asheej T K

  • #743218
    web services means re-usability

    Consider we need to develop an application that should support various user interfaces like Windows based interface, Web based interface, Pocket PC, & etc without changing any code.

    Web Services provides you the better solution for this. Presentation Layer will differ for each user interface. So it should be independent of Business Layer and Data Access Layer. Business layer supplies all the functionalities through web services. So there won't be any separate functionality for each user interface. It will be same for all the user interfaces.


  • Sign In to post your comments