Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="CallWSPage.aspx.cs" Inherits="CallWSPage" %>
 
<!DOCTYPE html>
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style>
        .blurprogressimage{width: 100%;background-color: black;moz-opacity: 0.5;khtml-opacity: .5;opacity: .5;filter: alpha(opacity=50);z-index: 120;height: 100%;position:fixed;top: 0;left: 0;}
        .progressimage{z-index: 700;position:fixed;top: 200pt;left: 500pt;padding: 5px 5px 5px 5px;}
 
    </style>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="scm" runat="server"></asp:ScriptManager>
        <asp:UpdatePanel ID="upWS" runat="server">
            <ContentTemplate>
                <div>
                    <h2>Call WS</h2>
                    <br />
                    <asp:Button runat="server" ID="btnPost" Text="Post WS" OnClick="btnPost_Click" />
                    <br />
                    <asp:Literal ID="ltrMessage" runat="server"></asp:Literal>
                </div>
            </ContentTemplate>
        </asp:UpdatePanel>
        <div>
 
        </div>
 
        <asp:UpdateProgress ID="UpdateProgress1" runat="server" DynamicLayout="true" AssociatedUpdatePanelID="upWS">
            <ProgressTemplate>
                <div class="blurprogressimage">
                    <div class="progressimage">
                        <img src="images/process-img.gif" />
                    </div>
                </div>
            </ProgressTemplate>
        </asp:UpdateProgress>
    </form>
</body>
</html>
 

ASPX.CS PAGE
 
protected void btnPost_Click(object sender, EventArgs e)
  {
      try
      {
          string result = "";
          List<string> objWSList = new List<string>();
          DateTime dtStartTime = System.DateTime.Now;
          objWSList.Add("WS1");
          objWSList.Add("WS2");
          objWSList.Add("WS3");
 
          for (int index = 0; index < objWSList.Count; index++)
          {
              var request = (HttpWebRequest)WebRequest.Create(string.Format("http://webserviceapp.com/webservices/WS.asmx/{0}", objWSList[index]));
              using (var response = request.GetResponse() as HttpWebResponse)
              {
                  if (request.HaveResponse && response != null)
                  {
                      using (var reader = new StreamReader(response.GetResponseStream()))
                      {
                          result = reader.ReadToEnd();
                      }
                      ltrMessage.Text += string.Format("<br/>{0}. {1} ->
Posted 20-Feb-13 22:02pm

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

protected void btnPost_Click(object sender, EventArgs e)
    {
        try
        {
            string result = "";
            List<string> objWSList = new List<string>();
            DateTime dtStartTime = System.DateTime.Now;
            objWSList.Add("WS1");
            objWSList.Add("WS2");
            objWSList.Add("WS3");
 
            for (int index = 0; index < objWSList.Count; index++)
            {
                var request = (HttpWebRequest)WebRequest.Create(string.Format("http://webserviceapp.com/webservices/WS.asmx/{0}", objWSList[index]));
                using (var response = request.GetResponse() as HttpWebResponse)
                {
                    if (request.HaveResponse && response != null)
                    {
                        using (var reader = new StreamReader(response.GetResponseStream()))
                        {
                            result = reader.ReadToEnd();
                        }
                        ltrMessage.Text += string.Format("<br/>{0}. {1} ->> Success", index + 1, objWSList[index]);
                    }
                    else
                        ltrMessage.Text += string.Format("<br/>{0}. {1} ->> Problem", index + 1, objWSList[index]);
                }
            }
            DateTime dtEndTime = System.DateTime.Now;
            TimeSpan ts = dtEndTime.Subtract(dtStartTime);
            ltrMessage.Text += string.Format("<br/><br/><b>Time Taken to Execute those WS (Time format is mm:ss:ms) ->> {0}:{1}:{2}</b>", ts.Minutes.ToString(), ts.Seconds.ToString(), ts.Milliseconds.ToString());
 
        }
        catch (Exception ex)
        {
            ltrMessage.Text += string.Format("<br/>Exception IS :::: {0}", ex.Message);
            //throw;
        }
    }
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web01 | 2.8.140926.1 | Last Updated 21 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100