Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6855649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:47:06+00:00 2026-05-27T01:47:06+00:00

Say you are calling two methods in WCF from the client side, with one

  • 0

Say you are calling two methods in WCF from the client side, with one web method recursively (or rather iteratively) calling the other web method in a sort of nested manner. A simple example below in pseudo-code, that works but I don’t think I have the proper exception handling in place. What is the best design template for the client and for the server to handle situations where the server fails?

I read the references 1-3 below and they seem to imply you must be disposing of things on either the client or server side–is this correct?

I am using WCF in Silverlight 3.5, using Visual Studio 2008 with C# as the code-behind language, but I don’t think that matters that much, as this is a universal question.

// PSEUDOCODE:

// assume FirstWebService returns a collection of objects, say MyObjects, in a List
// assume SecondWebservice takes this collection and does something with it.

ServiceReference1.Service1Client aClient;
private List myObjectList = new List();

public Page1()
{
InitializeComponent();

aClient = new myWebService.ServiceReference1.Service1Client();

aClient.FirstWebService += new EventHandler(aClient_FirstWebServiceCompleted);

aClient.SecondWebServiceCompleted += new EventHandler(aClient_SecondWebServiceCompleted);

}

//now when you click the button, you will call the first web service which will then call the second web service (many times), until the foreach loop is exhausted.

private void Button1_Click(object sender, RoutedEventArgs e)
{
aClient.FirstWebServiceAsync(); //calls first web service (which in turn will call a second web service “recursively” (or actually repeatedly), see below)

}

void aClient_FirstWebServiceCompleted(object sender, myWebService.ServiceReference1.FirstWebServiceCompletedEventArgs e)
{

         if (e.Error == null)  
         {

           myObjectList = e.Result; //assume both server side myObject and client side myObject are the same thing, so no type checking compiler error here with the Lists.

//Here is the ‘recursive’ (loop) part:

foreach (myObject O in myObjectList)
{
aClient.SecondWebServiceAsync(O); //note the recursive, nested asynchronous call from the first web service to the second web service here…done many times until the foreach loop is exhausted.
}
}

        else
        {
            //handle errors here
        }

}

void aClient_SecondWebServiceCompleted(object sender, myWebService.ServiceReference1.SecondWebServiceCompletedEventArgs e)
{

         if (e.Error == null)  
         {

           // do stuff here = e.Result; //etc

}
else
{
//error trap here, since e.Error != null
}
}

/*
// I have tried the above and it works, and has not failed yet. You have each web service “doing their thing” asynchronously. So far it’s worked Ok, but the web methods are not complicated and perhaps that’s why it’s worked. But I don’t think I have the proper scaffolding in place in case the web service fails—say it was taken off line by a power outage? I have a bad feeling I’ll get errors. How to make it more robust?

Also, the First and Second web services are LINQ to SQL methods, wrapped in ‘using’ blocks with TransactionScope to allow rollback of the methods in case they fail on the server side.

*/

References 1-3: (as a Noob I am not allowed to post more than one link by Stack Overflow, so I’ll post just the second link)

http://old.iserviceoriented.com/blog/post/Indisposable+-+WCF+Gotcha+1.aspx

also see http://www.bluebytesoftware.com /blog/2008/02/18/IDisposableFinalizationAndConcurrency.aspx

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T01:47:06+00:00Added an answer on May 27, 2026 at 1:47 am

    As a practical matter I found letting the garbage collector do its magic works fine–and handle any exceptions the best you can, typically client side.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have an ASMX web service, MyService. The service has a method, MyMethod.
Let say I have a method (example taken from another post): public IQueryable<CityBlock> GetCityBlocks(){
Say I create a simple web service that adds two numbers together. I send
Say I have an overloaded extension method with the following two signatures: public static
Say I have two classes One, the Foo class, interfaces with the user, and
Let's say I have 10 threads running simultaneously. Is there any way of calling
Say we have the following method: private MyObject foo = new MyObject(); // and
Say I have two strings, String s1 = AbBaCca; String s2 = bac; I
Maybe somebody could help me. I need a two methods. The first should open
I have created two partial classes for a web page. Now i have given

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.