Start consuming different services the same time RRS feed

  • Question

  • User1897897189 posted


    I have 10 different web services(some are wsdls and some apis)
    to be displayed on a web page.

    Some services retrieves data very fast some are too slow.

    I want to start consuming all the 10 services same time.

    Is it possible to do it?

    Please provide me some samples.


    Sunday, March 31, 2019 3:27 PM

All replies

  • User-1174608757 posted

    Hi ,nicklibee

    According to your description,If you want to call services in code behind, I suggest you to use send async method, so that you could send request to multiply services at same time. However ,even if you use send async, the program still needs time to get the responses from all the services so that the page could show. If some of the services is too slow , you still have to wait it finished.

    Else , in front end I suggest that you could use ajax for async request.Ajax will call async request by default. Here is a demo,I hope it could help you.

    Using ajax:

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="APICall.aspx.cs" Inherits="WebApplication1.APICall" %>  
    <!DOCTYPE html>  
    <html xmlns="http://www.w3.org/1999/xhtml">  
    <head runat="server">  
        <script src="jquery-1.7.1.js" type="text/javascript"></script>  
             $(document).ready(function () {  
                 $("#Save").click(function () {  
                     var person = new Object();  
                     person.name = $('#name').val();  
                     person.surname = $('#surname').val();  
                         url: 'http://localhost:3413/api/person',  
                         type: 'POST',  
                         dataType: 'json',  
                         data: person,  
                         success: function (data, textStatus, xhr) {  
                         error: function (xhr, textStatus, errorThrown) {  
                             console.log('Error in Operation');  
        <form id="form1">  
            Name :- <input type="text" name="name" id="name" />  
            Surname:- <input type="text" name="surname" id="surname" />  
            <input type="button" id="Save" value="Save Data" />  

    create the class for Web API 

    using System;  
    using System.Collections.Generic;  
    using System.Linq;  
    using System.Net;  
    using System.Net.Http;  
    using System.Web.Http;  
    namespace WebApplication1.WebAPI  
        public class person  
            public string name { get; set; }  
            public string surname { get; set; }  
        public class personController : ApiController  
            public string Post( person obj)  
                return obj.name + obj.surname;  

    Then we could see 

    If you want to use async in code behind. you could follow the steps in the link as below


    Best Regards


    Monday, April 1, 2019 2:57 AM