Consume a Windows Azure Service using ASP.NET

by Jagadish Pulakhandam on 12/28/2011 7:07:50 AM
Rated 0 from 0 votes
Brief: Video demonstration on how to consume a Windows Azure Service using ASP.NET Web Application
Posted to: Microsoft Azure Technologies
Add to DiggAdd to del.icio.usAdd to FURLAdd to RedditAdd to YahooAdd to BlinklistAdd to GoogleAdd to ma.gnoliaAdd to ShadowsAdd to Technorati

Attached video demonstrates the following:
  • Creating a new ASP.NET Web application using Visual Studio 2010
  • Adding a service reference to a hosted Windows Azure service (developed and deployed in previous posts)
  • Creating instance to proxy and accessing the service operations
NOTE:  Developing and testing the service used in this demonstration is covered in previous post.

Source Code:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebConsumer.WebForm1" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<head runat="server">
    <title></title>
    <style type="text/css">
        .style1
        {
            width: 100%;
        }
        .style2
        {
            width: 131px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
     
        <table class="style1">
            <tr>
                <td class="style2">
                    <asp:Label ID="Label1" runat="server" Text="Enter First No:"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="txtFirstNo" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="style2">
                    <asp:Label ID="Label2" runat="server" Text="Enter Second No:"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="txtSecondNo" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="style2">
                     </td>
                <td>
                    <asp:Button ID="btnCalc" runat="server" onclick="btnCalc_Click"
                        Text="Calculate" />
                </td>
            </tr>
            <tr>
                <td class="style2">
                     </td>
                <td>
                    <asp:Label ID="lblMsg" runat="server"></asp:Label>
                </td>
            </tr>
        </table>
     
    </div>
    </form>
</body>
</html>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
 
namespace WebConsumer
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
 
        }
 
        protected void btnCalc_Click(object sender, EventArgs e)
        {
            var oSvcClient = new CalcSvcRef.Service1Client();
            int a = Convert.ToInt16(this.txtFirstNo.Text);
            int b = Convert.ToInt16(this.txtSecondNo.Text);
            this.lblMsg.Text = "Sum = " + Convert.ToString(oSvcClient.GetSum(a, b));
        }
    }
}

<?xml version="1.0"?>
 
<!--
  For more information on how to configure your ASP.NET application, please visit
  -->
 
<configuration>
    <system.web>
        <compilation debug="true" targetFramework="4.0" />
    </system.web>
 
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_IService1" closeTimeout="00:01:00"
                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                    allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                    useDefaultWebProxy="true">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <security mode="None">
                        <transport clientCredentialType="None" proxyCredentialType="None"
                            realm="" />
                        <message clientCredentialType="UserName" algorithmSuite="Default" />
                    </security>
                </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://calcsvc.cloudapp.net/Service1.svc"
                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1"
                contract="CalcSvcRef.IService1" name="BasicHttpBinding_IService1" />
        </client>
    </system.serviceModel>
</configuration>

Join the .NET Code Central Community and join the discussion!
Signing-up is FREE and quick. Do it now, we want to hear your opinion
0

Rated 0 from 0 votes ( login  to rate)
DotnetKicks DotnetKicksDe DotNetShoutout

Attachments / Source Code
You need to Login or Join for FREE to download the following

Video/Screen Recording (may not have audio narration/annotations)
You need to Login or Join for FREE to download the following