0

我有以下 URL 用于调用 Web 服务

http://localhost:8080/mdnd_myshelfService_V1.0/myshelf/authenticateUserAndGetHospitalDetails?username=85010352:password=cHdfODUwMTAzNTIk

除此之外,我需要从特定设备发送用户名和密码,以根据头字段形式的硬编码用户名和密码验证设备。

@GET
@Path("/authenticateUserAndGetHospitalDetails")
@Produces(MediaType.APPLICATION_JSON)
public Hospital getAllHospitalData(@QueryParam("username") String userId) {
    log.error("in getAllHospitalData.. " + userId + " | " );
    }

我应该怎么做才能获得标题字段:MYSHELF_IPHONEUser_QAMYSHELF_IPHONEUser

4

2 回答 2

1

我认为您没有正确调用 Web 服务,因为如果您想为 and 传递查询字符串username,请password使用&运算符在 ?.

http://localhost:8080/...?username=85010352&password=cHdfODUwMTAzNTIk
于 2013-09-03T07:04:14.503 回答
1

如果您使用的是 JAX-RS,则可以使用以下方式访问 HTTP 标头@HeaderParam

@GET
@Path("/authenticateUserAndGetHospitalDetails")
@Produces(MediaType.APPLICATION_JSON)
public Hospital getAllHospitalData(
  @QueryParam("username") String userId,
  @HeaderParam("MYSHELF_IPHONEUser_QA") String userQaHeader,
  @HeaderParam("MYSHELF_IPHONEUser") String userHeader) {
  // ...
}
于 2013-09-03T07:10:43.767 回答