I want to know if I can implement a RESTFul web service using HTTPS instead of HTTP I am using Jersey and Spring to implement RESTFUL web service. If yes then what code changes do I need to make? Following is the code snippet I have
@Component
@Path("/payment")
public class PaymentService {
@Autowired
TransactionBo transactionBo;
@GET
@Path("{year}/{format}")
public Response savePayment(@PathParam("year") int year,
@PathParam("format") String format,@PathParam("name") String name) {
String result = transactionBo.save(year,format,name);
return Response.status(200).entity(result).build();
}
}
You don't need to do anything different in Jersey or Spring MVC for HTTPS. You do need to enable HTTPS in your servlet container (or load balancer), but this is independent of your REST service, and probably any of your java code.
If you are not using a load balancer, but you are using Tomcat for a servlet container, check here for details to enable HTTPS: https://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html. If you are using a load balancer, it's better to enable HTTPS in the load balancer so that you don't have to enable SSL in your backend servlet containers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With