Monday 24 June 2013

WebService Creating and Consuming WebService in asp.net or Create and call webservice in asp.net

WebService Creating and Consuming WebService in asp.net or Create and call webservice in asp.net  :


1.Create Webservices use The Link:


2Webservices Page Create and Then

  Solution Right Click --- > Add Web Reference 


 3. Web Services in this solution 



4 . Use Web Services Solution Select --- >  SampleWebservices.asmx                   



5 .Add Refrences  Web Services Select [WebMethod] --- > Add Refrences                    

6 .Refrences  Web Services Page in Add--- >


 Call webservice in asp.net  :

  <div align="center">
        A :
        <asp:TextBox ID="txtA" runat="server"></asp:TextBox>
        <br />
        B :
        <asp:TextBox ID="txtB" runat="server"></asp:TextBox>
        <br />
        <asp:Button ID="btnAdd" runat="server" Text="Add" OnClick="btnAdd_Click" />
        <br />
        <span style="color:Red;font-weight:bold">ANS:</span>
        <asp:Label ID="lblAns" runat="server"></asp:Label>
    </div>

aspx CS:

protected void btnAdd_Click(object sender, EventArgs e)
    {

       int x, y, Ans;
         x =Convert.ToInt32(txtA.Text);
        y =Convert.ToInt32(txtB.Text);

//Add Webservices (Use This Webservices)
        SampleWebservices objWebServicesAdd = new     
                                                                               SampleWebservices();
        //objWebServicesAdd.Add(x,y);

        Ans = Convert.ToInt32(objWebServicesAdd.Add(x, y));
        lblAns.Text =Convert.ToString(Ans);
            
    }























              









No comments:

Post a Comment