开发者

Website Calling Windows Service With Callback

开发者 https://www.devze.com 2023-03-30 09:40 出处:网络
I have a WCF service hosted in a Windows Service. I want a website to be able to call it asynchronously and then when the work is finished the WCF开发者_JAVA百科 service will let the website know the

I have a WCF service hosted in a Windows Service. I want a website to be able to call it asynchronously and then when the work is finished the WCF开发者_JAVA百科 service will let the website know the result. I've looked at various ways of achieving this but I would like to get some more advice on which way would be best. I've looked into using callbacks but also read they can be unreliable. I've read about not doing it this way at all and just having another interface in my service for the website to query the status. I've looked at using MSMQ which at the moment looks like my preferred way forward but would like some more info on how to set this up or whether I shouldn't do it this way.

Does anyone have any advice please?


The nature of any communication on a network is unreliable. The statement:

I've looked into using callbacks but also read they can be unreliable

Assuming you mean WCF callbacks, they are as unreliable as the clients/servers themselves, they all use the same mechanism.

That said, you can store the client of your WCF service in the HttpApplicationState (if the call is application-wide) or HttpSessionState (if the call is local to a session).

When generating the proxy, make sure that you check the option (or specify on the contract) that you are using asynchronous calls.

Then, you would make the call, using a callback (delegate) to indicate when the async call completed.

When the call completes, you would then store the result in the session state.

If this is something that a client on the front end needs to be aware of, then the browser will have to poll your site, checking for the return result, redirecting to a page that can display the results when the result is populated.


Selecting a binding for your application depends on

  1. Architecture of your application
  2. Requirements
  3. interoperability required or not.
  4. response time of the application
  5. availability of time to implement
  6. Infrastructure you are using or want to use.

As your application is a web application and is built on a request/response model, you will not be able to use asyncronous or msmq style for this architecture(or is not adviceable), because there will not be any thread listining for a delayed async response or msmq call. you can make use of one way Methods and direct calls to methods. in this case to reduce response time you have to device ways to optimize your service methods and the processing it is doing.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号