在RESTful Web服务异步请求 [英] Asynchronous request in RESTFul WebService

查看:517
本文介绍了在RESTful Web服务异步请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要创造一个请求将异步处理一个基于REST的Web服务。
通过异步,我的意思是,客户端将作出请求并继续其与出等待来自service.Is能够实现这个响应执行?
我需要部署在WebSphere Application Server的服务。

I need to create a REST based web service where the request will be handled asynchronously. By asynchronous ,I mean that the client will make the request and continue with its execution with out waiting for the response from the service.Is it possible to achieve this? I need to deploy the service in WebSphere Application Server.

推荐答案

所以我不知道,如果你的问题是关于如何做服务器,或如何处理一个RESTful的方式异步操作的异步处理。如果是后者,那么这里就是该方法的总结建议在: http://restcookbook.com /资源/ asynchroneous的操作/

So I am not sure if your question is about how to do asynchronous processing on the server, or how to handle asynchronous operations in a RESTful manner. If it is the latter, then here is a summary of the approach suggested at: http://restcookbook.com/Resources/asynchroneous-operations/

code你的服务的方法。

Code your service method to


  • (一)处理请求的操作异步(使用单独的
    螺纹最有可能的)。

  • (二)立即返回202-接受
  • 的响应code
  • (三)在响应主体,返回一个URI,重新presents请求的操作状态。

  • (a) handle the requested operation asynchronously (using a separate thread most likely).
  • (b) Immediately return a response code of 202-Accepted
  • (c) In the response body, return a URI that represents the status of the requested operation.

然后code你的客户:

Then code your client to:


  • (一)主呼服务方法。当响应完成后,如果响应code是202,需要注意的URI在体内返回。

  • (b)在后台线程,定期轮询的URI,直到它返回的指示操作完成。

这篇关于在RESTful Web服务异步请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆