0 comments

Generating the Proxy class with VS IDE in .net

Generating the Proxy class with VS IDE
1. Deign the default.aspx with two textboxes, three labels and a single button server control as in the following.
2. Right-click over the client project in the Solution Explorer, and select "Add Service reference", then click on the "Advanced" button in the dialog box and finally click "Add Web Reference" as in the following.
3. Copy the Web Service URL from the image 1.2, paste into the URL text box and hit Enter. This operation will browse your web service.


4. The web service test page will appear in the windows with an entire methods list and the "Add Reference" button will be enabled as:

Generating the Proxy class with VS IDE in .net.jpg

5.In the Web Reference name text box you can change the namespace in which the proxy class will generated.
6.Now click over the "Add Reference" button.
7.Now the web reference will appear in the Web References group for the project in the Solution Explorer window as in the following:


1.       Open the Default.aspx.cs file and add a button click handler and put the following code in it:

publicpartial class_Default : System.Web.UI.Page
{   
    
protected void btnAdd_Click(object sender,EventArgs e)
    {
        
int x, y, Result;
        x = 
Convert.ToInt32(TextBox1.Text);
        y = 
Convert.ToInt32(TextBox2.Text);
        //web service class instantiation
        localhost.UtilityWebService obj = new localhost.UtilityWebService();
        //Method call
        Result=obj.addition(x, y);
        //Output
        Label3.Text = Result.ToString();  
    }
}
Finally run the project and enter 2 integer type values in the given text boxes and hit the button for calling the additional web service method as in the following:

                                              .NET InterView Questions
 
Toggle Footer
Top