0

I'm new at Restful webservices and im trying to create a WS server to work with an android app. I'm using Netbeans and i followed this tuturial to get started (http://netbeans.org/kb/docs/websvc/rest.html) . I was able to successfully teste the basic features as explained in the tuturial. But now I am not able to add a new feature to the WS. Say I have a table in my DB called User. With the tuturial I can access the table Users by ID trhough the function

@GET
@Path("{id}")
@Produces(
  {
    "application/xml", "application/json"
  })
public User find(@PathParam("id") Integer id)
  {
    return super.find(id);
  }

The problem is if I want to get a User by its name for example. If I create a similar function like

@GET
@Path("{name}")
@Produces(
  {
    "application/xml", "application/json"
  })
public User find(@PathParam("name") String name)
  {
    return super.find(name);
  }

The server crashes. So my question is , what's the procedure to be able to get a User by other parameters different of id.

Thank you

4

1 回答 1

1

这里有一个一小时长的视频,您可以在其中看到一个 Web 服务前端的实现,该前端允许用户插入和访问数据库行。

原理应该是一样的,因为 Web 服务旨在为可互操作的客户端提供服务,不介意它是 android 应用程序还是其他应用程序。在本视频中,您将看到如何使用 2 个参数来形成查询并针对 oracle 数据库触发它。

我认为可以帮助您的东西是实现 CRUD 外观的 EJB。

我希望它有所帮助:http ://www.youtube.com/watch?v=0_0gGL2C1ys&feature=player_embedded

于 2012-05-10T15:44:14.130 回答