I am writing a REST Web service. This is a snippet of Web service:
@Path("/first")
public class InitialResource
{
@GET
@Path(value="/{input}/{location}/{category}/{session}")
@Produces({"application/xml", "text/html"})
public List<Message> getMessage(@PathParam("input") String input, @PathParam("location") String location, @PathParam("category") String category, @PathParam("session") String session) throws NotFoundException
{
if(date.recentUpdate(location) == false)// if false, the checking of category update was开发者_Python百科 run later than 1 hour ago
{
user.dropTable(); // invokes method which checks if you need to drop any user's intermediate results table
if(version.getVersion(location)== true) // if version of category did not change
{
}
else
{// version of category old; updates list of category for a specific country
updateCategory.getCategoryList(id.getSiteId(location));
}
}
return search.runSearch(input, location, category, session.split("\\.")[1]);
}
}
If you invoke it through this URI
http://localhost:8080/Project/resources/first/cat/EBAY-IE/1/0.123
you get 404 HTTP error.
There is one more resource below.
@GET
@Produces("text/html")
public String getMess( ) {
return "hello";
}
If you invoke the service with this URI
http://localhost:8080/Project/resources/first
you get "hello" string on the screen. Why I can't invoke the first resource with specified path?
Thank you for your suggestions, though the problem was elsewhere. I was getting HTTP 404 error accessing the Web service via client (browser). Using URI I just could not connect to the server. I only needed to update the port. And then I updated the path the client code (Javascript) accesses the service. The service system runs well. Thanks
精彩评论