Administrateur
Administrateur

Reputation: 901

How to call a web service in "fire and forget" way from ASP.Net

I have a web service that I want to call from one of my asp.net classes. I can call my web service successfully.But now I need to call this service asynchronously. I need to call it and NOT wait for the service to complete execution. I don't need to process a response from the service and don't need to verify if the service executed successfully. All I want is to be able to call the service and be free to do other things.

Upvotes: 4

Views: 4569

Answers (3)

Tim
Tim

Reputation: 28530

One way to implement a fire-and-forget approach is to use the IsOneWay property on the OperationContract attribute, like this:

[OperationContract(IsOneWay=true)]
public void SomeMethod(string someValue);

When set to true, the operation won't return a message. Note that methods marked as one-way cannot have return types or ref or out parameters (which makes sense). It also should not be confused with asynchronous calls, because it's not the same thing (in fact, a one-way call can block on the client if it takes a while to get a connection, for example).

See OperationContractAttribute.IsOneWay Property for more information.

Upvotes: 3

slash shogdhe
slash shogdhe

Reputation: 4197

You need to consume web service asynchronously. Goto and check

AddServiceReference -> Advance -> generate asynchronous operations.

after this async callback events will be available to you for every method Suppose you have ABC method in you service when you will consume it by as sync these methods will be available to you in your application

1>ABC (fire and wait for output)
2>ABCAsync(fire and forget)
3>ABC callback event(get fired <if ABCAsync is called> when data available in your application)

Upvotes: 4

Jportelas
Jportelas

Reputation: 646

Have you tried this:?

http://msdn.microsoft.com/en-us/library/bb885132(v=vs.110).aspx

this is another way to do it, check it out.

Upvotes: -1

Related Questions