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

  • Home
  • SEARCH
  • 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 8648921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:25:50+00:00 2026-06-12T13:25:50+00:00

I have a problem with a simple C# web service from a sample. This

  • 0

I have a problem with a simple C# web service from a sample.
This is my server side code:

public delegate string LengthyProcedureAsyncStub(int milliseconds);

    public class MyState
    {
        public string text;
        public object previousState;
        public LengthyProcedureAsyncStub asyncStub;
    }

    [WebMethod]
    public IAsyncResult BeginLengthyProcedure(int milliseconds, AsyncCallback cb, object s)
    {
        LengthyProcedureAsyncStub stub = new LengthyProcedureAsyncStub(LengthyProcedure);
        MyState ms = new MyState();
        ms.previousState = s;
        ms.asyncStub = stub;
        return stub.BeginInvoke(milliseconds, cb, ms);
    }

    public string LengthyProcedure(int milliseconds)
    {
        System.Threading.Thread.Sleep(milliseconds);
        return "Success";
    }

    [WebMethod]
    public string EndLengthyProcedure(IAsyncResult call)
    {
        MyState ms = (MyState)call.AsyncState;
        string result = ms.asyncStub.EndInvoke(call);
        return result;//ms.text;
    }

I consume the service from a client like so:

private void button1_Click(object sender, EventArgs e)
    {

        Waiter(5000);

    }

    private void Waiter(int milliseconds)
    {
        asyncProcessor.Service1SoapClient sendReference;
        sendReference = new asyncProcessor.Service1SoapClient();
        sendReference.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
        sendReference.BeginLengthyProcedure(milliseconds, ServiceCallBack, null);

    }

    private void ServiceCallBack(IAsyncResult result)
    {
        string strResult = result.ToString();
    }

The problem is that the client variable strResult should have “Sucess” as it’s value, instead it has this: “System.ServiceModel.Channels.ServiceChannel+SendAsyncResult”.
What am I doing wrong or overlooking?

Thanks in advance fro your time 🙂

  • 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-06-12T13:25:51+00:00Added an answer on June 12, 2026 at 1:25 pm

    You have to pass sendReference instead of null.

    private void Waiter(int milliseconds)
    {
        asyncProcessor.Service1SoapClient sendReference;
        sendReference = new asyncProcessor.Service1SoapClient();
        sendReference.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
        sendReference.BeginLengthyProcedure(milliseconds, ServiceCallBack, sendReference);
    
    }
    
    private void ServiceCallBack(IAsyncResult result)
    {
        asyncProcessor.Service1SoapClient sendReference = result.AsyncState as asyncProcessor.Service1SoapClient;
        string strResult = sendReference.EndLengthyProcedure(result);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple web service. The server is a regular, public-facing HTTPS server
I have a problem with a web page. The introduction of a simple <base
I have what seems like a simple problem. I have a Spring web app,
I have a simple problem with SQL SERVER charindex function. DECLARE @VAR1 varchar SET
I have a simple web service sitting on our internal network. I used SOAPUI
I need to call a web service from my classic ASP website. I have
I am having a problem returning an ArrayList from my web service (Java). I
I have a peculiar problem when calling a web service that expects the message
I have WCF service running from within a Windows Service. This is working fine
I have a WSDL file which is from an Axis2 Web Service. When I

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.