0

The goal of my app is to create a leaderboard for a competition. To add to one's score, you just have to write something in hipchat (I already have a listener in hipchat that attempts to make a post to my Tapestry app).

I am running into lots of trouble around accepting and handling a 3rd party POST to my Tapestry app. All the documentation I can find deals with internal requests.

Does anyone have any experience in setting up a way to receive a 3rd party post, handle it and make actions with the information? Any help would be great!

4

1 回答 1

0

Tapestry 的原生 POST 处理旨在处理 HTML 表单提交,并且不适合机器发起的 REST 请求。因此,我会将它作为一个 REST 资源请求来处理,这是JAX-WS的目的。我假设您的意思是 Tapestry 5,如果是这样,那么开始使用Tynamo 的 Tapestry-resteasy 模块是很不错的(为了披露,我是维护者之一)。如果您是 JAX-WS 的新手,您可能想阅读有关它的概述(链接是针对 Jersey 的,参考实现,但无论实现如何,注释的工作方式都相同)。原则上,你会实现一个(POJO+annotations)资源类和一个类似这样的操作:

@POST
@Produces({"application/json"})
public Response scorePoints(User user, long score)
{
    leaderboardService.add(user, score);
    return Response.ok().build();
}

在客户端,您只需传入用户 ID,Tapestry 的类型强制将处理其余部分(假设 User 是 Tapestry 的已知实体)。当然,您也可以在两边都使用原始数据类型。

于 2015-07-22T03:58:37.853 回答