Using Proxy · Server Code


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace MyWebApp.projects.asmx
{
    public partial class UsingProxy : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void TranslateButton_Click(object sender, EventArgs e)
        {
            if (EnglishTextBox.Text != string.Empty)
            {
                try
                {
                    // consuming a web service using a web reference
                    MyWebService.TranslateToFrenchService service = 
                        new MyWebService.TranslateToFrenchService();
                    FrenchLabel.Text = 
                        service.TranslateToFrench(EnglishTextBox.Text);
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }

        protected void Translatev2Button_Click(object sender, EventArgs e)
        {
            if (Englishv2TextBox.Text != string.Empty)
            {
                try
                {
                    // consuming a web service using a service reference
                    MyWebServiceB.TranslateToFrenchServiceSoapClient soapClient = 
                        new MyWebServiceB.TranslateToFrenchServiceSoapClient();
                    Frenchv2Label.Text = 
                        soapClient.TranslateToFrench(Englishv2TextBox.Text);
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
    }
}