Example #1
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            var proxy = new ShoppingCartServiceProxy.ShoppingCartServiceClient();

            try
            {
                var newCart = proxy.CreateCart();
                txtCartId.Text = newCart.ToString(CultureInfo.InvariantCulture);
                lblResult.Text = String.Format("Cart created with ID:") + newCart;
                proxy.Close();
            }
            catch (TimeoutException timeout)
            {
                lblResult.Text = timeout.Message;
                proxy.Abort();
            }
            catch (CommunicationException commException)
            {
                lblResult.Text = commException.Message;
                proxy.Abort();
            }
        }
Example #2
0
        protected void Button6_Click(object sender, EventArgs e)
        {
            var proxy = new ShoppingCartServiceProxy.ShoppingCartServiceClient();

            try
            {
                var shoppingCartId = Int32.Parse(txtCartId.Text);
                var success        = proxy.RemoveCart(shoppingCartId);
                lblResult.Text = String.Format("Operation was ") + (success ? "successful" : "unsuccessful");
                proxy.Close();
            }
            catch (TimeoutException timeout)
            {
                lblResult.Text = timeout.Message;
                proxy.Abort();
            }
            catch (CommunicationException commException)
            {
                lblResult.Text = commException.Message;
                proxy.Abort();
            }
        }