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 683249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:41:11+00:00 2026-05-14T01:41:11+00:00

I need a console app which will calling webmethod. It must be asynchronous and

  • 0

I need a console app which will calling webmethod.

It must be asynchronous and without timeout (we don’t know how much time takes this method to deal with task.

Is it good way:

[WebMethod]
[SoapDocumentMethod(OneWay = true)]

??

  • 1 1 Answer
  • 1 View
  • 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-14T01:41:12+00:00Added an answer on May 14, 2026 at 1:41 am

    Don’t use one-way if you need results

    First, if you need a response from your method, you don’t want [SoapDocumentMethod(OneWay = true)]. This attribute creates a “fire and forget” call which never returns a response back to the caler and must return void. Instead, use a regular method call and call it async.

    One method or two?

    If you’re using ASMX, there are two basic solutions: one method with a very long timeout, or two methods (as @Aaronaught suggested above): one to kick off the operation and return an ID of the operation, and another to pass in the ID and retrieve results (if available).

    Personally, I would not recommend this two-method approach in most cases because of the additional complexity involved, including:

    • client and server code needs to be changed to suppport 2-step invocation
    • ASP.NET intrinsic objects like Request and Response are not available when called from a background task launched with ThreadPool.QueueUserWorkItem.
    • throttling on a busy server gets much harder if there are multiple threads involved with each request.
    • the server must hang onto the results until the client picks them up (or you decide to throw them out), which may eat up RAM if results are large.
    • you can’t stream large, intermediate results back to the client

    True, in some scenarios the 2-method approach may scale better and will be more resilient to broken network connections between client and server. If you need to pick up results hours later, this is something to consider. But your operations only take a few minutes and you can guarantee the client will stay connected, given the addiitonal dev complexity of the 2-method approach I’d consider it a last resort to be used only if the one-method solution doesn’t match your needs.

    Anyway, the solution requires two pieces. First, you need to call the method asynchronously from the client. Second, you need to lengthen timeouts on both client and server. I cover both below.

    Calling ASMX Web Services Asynchronously

    For calling an ASMX web service asynchronously from a command-line app, take a look at this article starting with page 2. It shows how to call a web service asynchronously from a .NET cilent app using the newer Event-Based Async Pattern. Note that the older .NET 1.0 approach described here, which relies on BeginXXX/EndXXX methods on the proxy, is not recommended anymore anymore since Visual Studio’s proxy generator doesn’t create those methods. Better to use the event-based pattern as linked above.

    Here’s an excerpt/adaptation from the article above, so you can get an idea of the code involved:

    void KickOffAsyncWebServiceCall(object sender, EventArgs e)
    {
        HelloService service = new HelloService();
        //Hookup async event handler
        service.HelloWorldCompleted += new 
            HelloWorldCompletedEventHandler(this.HelloWorldCompleted);
        service.HelloWorldAsync();
    }
    
    void HelloWorldCompleted(object sender,
                             HelloWorldCompletedEventArgs args)
    {
        //Display the return value
        Console.WriteLine (args.Result);
    }
    

    Lengthen server and client timeouts

    To prevent timeouts, http://www.dotnetmonster.com/Uwe/Forum.aspx/asp-net-web-services/5202/Web-Method-TimeOut has a good summary of how to adjust both client and server timeouts. You didn’t specify in your question if you own the server-side method or just the client-side call, so the excerpt below covers both cases:

    there has two setttings that will
    affect the webservice call timeout
    behavior:

    ** The ASP.NET webservice’s server-side httpruntime timeout
    setting, this is configured through
    the following element:

    httpRuntime Element (ASP.NET Settings Schema)
    http://msdn2.microsoft.com/en-us/library/e1f13641.aspx

    <configuration> <system.web>
    <httpRuntime ………….
    executionTimeout=”45″
    ……………/> </system.web>
    </configuration>

    Also, make sure that you’ve set the
    <compilation debug=”false” /> so as to
    make the timeout work correctly.

    ** If you’re using the wsdl.exe or VS IDE “add webreference” generated
    proxy to call webservice methods,
    there is also a timeout setting on the
    client proxy class(derived from
    SoapHttpClientProtocol class). This is
    the “Timeout” property derived from
    “WebClientProtocol” class:

    WebClientProtocol.Timeout Property http://msdn2.microsoft.com/en-us/library/system.web.services.protocols.webclientprotocol.timeout.aspx

    Therefore, you can consider adjusting
    these two values according to your
    application’s scenario. Here is a
    former thread also mentioned this:

    http://groups.google.com/group/microsoft.public.dotnet.framework.webservices/browse_thread/thread/73548848d0544bc9/bbf6737586ca3901

    Note that I’d strongly recommend making your timeouts long enough to encompass your longest operation (plus enough buffer to be safe should things get slower) but I wouldn’t recommend turning off timeouts altogether. It’s generally bad programming practice to allow unlimited timeouts since an errant client or server can permanently disable the other. Instead, just make timeouts very long— and make sure to be logging instances where your clients or servers time out, so you can detect and diagnose the problem when it happens!

    Finally, to echo the commenters above: for new code it’s best to use WCF. But if you’re stuck using ASMX web services, the above solution should work.

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

Sidebar

Ask A Question

Stats

  • Questions 386k
  • Answers 386k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Turns out the problem was by appending parameters in the… May 14, 2026 at 11:45 pm
  • Editorial Team
    Editorial Team added an answer Windows is now supported by Spork! http://wiki.github.com/timcharper/spork/ Spork is a… May 14, 2026 at 11:45 pm
  • Editorial Team
    Editorial Team added an answer This is fairly easy. var timerID; $("#left").hover(function() { timerID =… May 14, 2026 at 11:45 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.