[英]How to fetch HTTP headers using JAX-RS?
I have the following URL for calling a web service 我有以下URL来调用Web服务
http://localhost:8080/mdnd_myshelfService_V1.0/myshelf/authenticateUserAndGetHospitalDetails?username=85010352:password=cHdfODUwMTAzNTIk
Along with this i need to send username and password from particular device as to verify the device based on hardcoded username and password in the form of header field. 除此之外,我还需要从特定设备发送用户名和密码,以便以头字段的形式根据硬编码的用户名和密码验证设备。
@GET
@Path("/authenticateUserAndGetHospitalDetails")
@Produces(MediaType.APPLICATION_JSON)
public Hospital getAllHospitalData(@QueryParam("username") String userId) {
log.error("in getAllHospitalData.. " + userId + " | " );
}
What should i do to get the header fields: MYSHELF_IPHONEUser_QA
and MYSHELF_IPHONEUser
我该怎么做才能获得标题字段:
MYSHELF_IPHONEUser_QA
和MYSHELF_IPHONEUser
I think you are not calling the web service properly because if you want to pass a query string for username
and password
, use the &
operator to list them after the ?
我认为您没有正确调用Web服务,因为如果您想传递
username
和password
的查询字符串,请使用&
运算符列出它们之后?
. 。
http://localhost:8080/...?username=85010352&password=cHdfODUwMTAzNTIk
If you are using JAX-RS, you can access HTTP headers using @HeaderParam
: 如果您使用的是JAX-RS,则可以使用
@HeaderParam
访问HTTP标头:
@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) {
// ...
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.