我有一个Java Restful WebService的URL: http://localhost:8080/WebServiceEx/rest/hello/dgdg
当我执行这个URL时,WebService方法会返回一个字符串。
我的需求是在Servlet中调用上述的WebService URL,有谁能帮忙吗?
Servlet代码:
public Class StoreServlet extends HttpServlet{
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws IOException, ServletException {
//Invoke WebService and Get Response String Here
}
WebService 代码:
public class HelloWorldService {
@Context
private ServletContext context;
@GET
@Path("/{param}")
public Response getMsg(@PathParam("param") String msg) {
return Response.status(200).entity(msg).build();
}
}