How to Deploy Web Service by Web Setup Project in asp.net Application

By
In this tutorial, i am going to Explain how to deploy web service by web setup project.You can Install this web service on your computer or server and use this functionality from your website (application) .In our previous tutorial i have already explained
You need to transfer the web service from development environment to the production environment to make a web service available to website(Application).You can deploy this web service by Web Setup project template in visual studio 2010 or 2012. 
There are some steps to implements this concepts on asp.net website,which are given below:-
Step- 1 First open your visual studio --> File --> New -->website-->Select ASP.NET Empty website and select visual c# from left window-->OK-->open Solution Explorer -->Right click on website -->Add New Items -->Select Web Service and visual c#-->write web services Name (simpleService.asmx) -->click Add as shown below:-
template

Step- 2 Now write the c# codes in simpleService.cs file as show below:-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;

/// <summary>
/// Summary description for simpleService
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
// [System.Web.Script.Services.ScriptService]
public class simpleService : System.Web.Services.WebService {

    public simpleService () {

        //Uncomment the following line if using designed components 
        //InitializeComponent(); 
    }

    [WebMethod]
    public string msdotnet()
    {
        return "Welcome to our website";
    }
    [WebMethod]
    public double rect_area(double i, double j)
    {
        return i * j;
    }
    [WebMethod]
    public double triangle_area(double i, double j)
    {
        return (i * j) / 2;
    }

    [WebMethod]
    public double simpleinterest(double i, double j, int k)
    {
        return (i * j * k) / 100;
    }
    
}

Step- 3 Now Run the Web Service(simpleService.asmx) -->Copy the Browser  URL as show below:-


URL


Step- 4 Now  open Solution Explorer --> Add a web Form (setupapplication.aspx) -->Drag and drop Label,Text Box and Button controls on the Form as shown below:-


form

Step- 5 Now write the c# codes on setupapplication.cs file as given below:- 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using latestservice;

public partial class setupapplication : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        simpleService obj = new simpleService();
        double area1 = obj.rect_area(Convert.ToInt32(TextBox1.Text), Convert.ToInt32(TextBox2.Text));
        Label1.Text = "Rectangle Area=" + area1;
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        simpleService obj = new simpleService();
        double area2 =obj.triangle_area(Convert.ToInt32(TextBox1.Text), Convert.ToInt32(TextBox2.Text));
        Label1.Text = "Traingle Area=" + area2;
    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        simpleService obj = new simpleService();
        double SI = obj.simpleinterest(Convert.ToInt32(TextBox1.Text), Convert.ToInt32(TextBox2.Text), Convert.ToInt32(TextBox3.Text));
        Label1.Text = " Simple Interest =" +SI;
    }
}       

Step- 6 Now for Configuration,Open Solution Explorer -->Right click on website (Application)-->Add Reference -->Paste the copied web service URL(Step-3) -->Next arrow as shown below:-
configure-service

Step- 7 Now Go File -->New -->Project as show below:-


file-setup

Step- 8 Now Expand other project Type-->Click visual studio Installer -->select setup project --> write Name -->OK as shown below:-


project
Step- 9 Now go Solution Explorer-->Right click on mysetup -->Add -->click project output..-->OK as shown below:-
add-project

Step- 10 Now Right click on mysetup --> Build -->Go visual studio 2010\projects\webservice2\mysetup\Debug folder-->install this setup on your system as shown below:-
paths
Step- 11 Now Run Application (press F5) --> Enter the required fields details --> press button(RectArea, TraingleArea , Simple Interest) as shown below:-


output

For More...
  1. How to send mail from asp.net application free
  2. Transaction in sql server
  3. Reflection in c#
  4. How to add control at Run time in .Net Application
  5. Constructor and Destructor in c#
  6. Data Integrity in sql server
  7. How to insert Data and Write the XML File
  8. Ado and Ado.NET
  9. Partial class in C#
  10. Basic elements are used to compiling the c# code 
Download Below attached file
         Download

0 comments:

Post a Comment

Powered by Blogger.