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

    Hosting mechanisms in windows communication foundation

    Hi,

    Please anyone tell me when to use which hosting mechanism in WCF

    Regards,

    RAJAN CRP
  • #758967
    Hello,

    To create the Web service
    1. In Solution Explorer, right-click the Web site name (http://localhost/TemperatureWebService), and then click Add New Item.
    2. Under Visual Studio installed templates, click Web Service, and then in the Name box, type Convert.
    3. Make sure that the Place code in separate file check box is selected, and then click Add.

    1. Add the following code inside the class, after the HelloWorld method:
    [System.Web.Services.WebMethod()]
    public double FahrenheitToCelsius(double Fahrenheit)
    {
    return ((Fahrenheit - 32) * 5) / 9;
    }

    [System.Web.Services.WebMethod()]
    public double CelsiusToFahrenheit(double Celsius)
    {
    return ((Celsius * 9) / 5) + 32;
    }

    2. After you have entered the functions, save the file.

    To test the Web service:

    1. In Solution Explorer, click Convert.asmx, and then press CTRL+F5.
    The Web service is invoked and a page appears in the browser that shows the methods that are exposed by the Web service.
    2. Click CelsiusToFahrenheit, which invokes that method.
    A page appears that prompts you for parameter values for the CelsiusToFahrenheit method.
    3. In the Celsius box, type 100, and then click Invoke.
    A new window appears that displays the XML that the Web service returns when the CelsiusToFahrenheit method is invoked. The value 212 appears in the XML.
    4. Close the browser that contains the method results.
    5. In the original browser, click Back to return to the list of methods.
    6. Click FahrenheitToCelsius and test to make sure that the method is returning the results that you expect.
    If you type 212, the FahrenheitToCelsius method will return 100.
    7. Close the browser.

    You have finished creating the Web service; the next step is to use it.

    For more reference follow the below link:
    https://msdn.microsoft.com/en-us/library/8wbhsy70(v=vs.80).aspx
    http://www.codemag.com/Article/0701041

    Hope this will help you.
    Mark the answer if it helps you.

    Regards,
    Nirav Lalan
    DNS Gold Member
    "If you can dream it, you can do it."

  • #758968
    Hi Crprajan.

    There are many advantages and disadvantages over one another.
    Choosing the hosting environment is depending upon the requirements.

    IIS Hosting:
    IIS will load your service when you demand.
    when first request is received then it will create a
    servicehost and then servicehost creates service
    class to handle the request.
    This is advantage in managing the system resources. If we dont need the memory of the system is not consumed.
    Disadvantage is that only HTTP protocol
    could be used.

    Self hosting:
    Self-host can easily run many sites on a single
    machine, on a single port. You can even create
    one main site and a backup one at the same
    address that will remove only if the main site
    does not respond.

    Refer below link for more details

    www.c-sharpcorner.com/uploadfile/dhananjaycoder/various-options-in-hosting-of-wcf-services/

    m.wcftutorial.net/WCF/WCF-Hosting

    Regards

    Sridhar.
    DNS Member.
    "Hope for the best.. prepare for the worst.."

    Sridhar Thota.
    Editor: DNS Forum.

  • #758969
    Hi Nirav.

    You have posted webservice example for wcf hostings.
    Please read question while answering, dont post spam answers.
    I think by mistake you might have posted the response.

    Regards

    Sridhar.
    DNS Member.
    "Hope for the best.. prepare for the worst.."

    Sridhar Thota.
    Editor: DNS Forum.

  • #758970
    Hello,

    Sorry by mistake the wrong post got posted here.

    Regards,
    Nirav Lalan
    DNS Gold Member
    "If you can dream it, you can do it."

  • #758971
    Hello,

    Multiple hosting and protocols supported by WCF. Microsoft has introduced the WCF concept in order to make distributed application development and deployment simple.

    Four different ways to host the WCF service such as below. Also refer the links to when and which hosting mechanism will be best for you
    1. IIS hosting
    --> http://wcftutorial.net/WCF-IIS-Hosting.aspx

    2. Self hosting
    --> http://wcftutorial.net/WCF-Self-Hosting.aspx

    3. Windows Activation Service
    --> http://wcftutorial.net/WCF-WAS-Hosting.aspx

    4. Windows Service
    --> http://wcftutorial.net/WCF-Windows-Service-Hosting.aspx

    Hope this will help you to understand deeply and will increase your knowledge.
    Mark the answer if it helped you.

    Regards,
    Nirav Lalan
    DNS Gold Member
    "If you can dream it, you can do it."

  • #758983
    You can deploy WCF services on
    - Local IIS Server
    - Visual Studio Development Server
    - Windows Azure Development Environment
    When a data service is developed as an ASP.NET project, it can be deployed to an IIS Web server by using the standard ASP.NET deployment processes. Visual Studio provides the following deployment technologies for ASP.NET, depending on the kind of ASP.NET project that hosts the data service that you are deploying
    You can deploy it using
    - Web Deployment Package
    - One-Click Publishing
    see below links for more details
    https://msdn.microsoft.com/en-us/library/dd465323(v=vs.110).aspx
    https://msdn.microsoft.com/en-us/library/dd465337(v=vs.110).aspx

    Thanks
    Koolprasd2003
    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]


  • Sign In to post your comments