我有一个 java Rest WebService URLhttp://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
}
网络服务代码:
public class HelloWorldService {
@Context
private ServletContext context;
@GET
@Path("/{param}")
public Response getMsg(@PathParam("param") String msg) {
return Response.status(200).entity(msg).build();
}
}