Hello to all,
I used apache cxf to implement a restFul Server, everything is working
correctly except one thing. I have to get inside the methods of a
@Service if the request was made by HTTP or HTTPS, so I inject a
UriInfo to get the scheme, but It always return the value of the first
request to the service. Scheme, server name and port doesn't change
but path do.
I tried also with SecurityContext, but I've got the same problem, it
looks like it doesn't get updated in different requests.
My Tomcat configuration have 2 connectors on 2 different ports, one
for http and other for https.
My Service class looks like:
@Service("timeService")
public class TimeService {
...
@POST @Path("{url}")
@Produces("*/*")
@Consumes("*/*")
public Response getAS2from(byte[] content, @Context HttpHeaders
headers, @Context UriInfo uri)
{
boolean sc=false;
logger.info("Scheme: {}", uri.getAbsolutePath().toString());
logger.info("Scheme3: {}",uri.getAbsolutePath().getScheme());
if(((uri.getAbsolutePath().getScheme())!= null) &&
(uri.getAbsolutePath().getScheme()).equalsIgnoreCase("https")){
logger.info("Recibiendo POST por HTTPS...");
sc=true;
}
else{
logger.info("Recibiendo POST por HTTP...");
}
...
}
@POST
@Produces("*/*")
@Consumes("*/*")
public Response getAS2fromR(byte[] content, @Context HttpHeaders
headers, @Context UriInfo uri)
{
boolean sc=false;
logger.info("Scheme: {}", uri.getAbsolutePath().toString());
logger.info("Scheme3: {}",uri.getAbsolutePath().getScheme());
//Tratar mensaje AS2
if(((uri.getAbsolutePath().getScheme())!= null) &&
(uri.getAbsolutePath().getScheme()).equalsIgnoreCase("https")){
logger.info("Recibiendo POST por HTTPS...");
sc=true;
}
else{
logger.info("Recibiendo POST por HTTP...");
}
...
}
Any suggestions about this???
Thank you very much!