如何解决调用REST Web服务的资源
| 我正在编写REST Web服务。这是Web服务的片段:@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 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]);
}
}
如果通过此URI调用它
http://localhost:8080/Project/resources/first/cat/EBAY-IE/1/0.123
您会收到404 HTTP错误。
下面还有一个资源。
@GET
@Produces(\"text/html\")
public String getMess( ) {
return \"hello\";
}
如果您使用此URI调用服务
http://localhost:8080/Project/resources/first
您在屏幕上获得\“ hello \”字符串。
为什么我不能使用指定的路径调用第一个资源?
解决方法
谢谢您的建议,尽管问题出在其他地方。通过客户端(浏览器)访问Web服务时出现HTTP 404错误。使用URI,我无法连接到服务器。我只需要更新端口。然后,我更新了客户端代码(Javascript)访问服务的路径。服务系统运行良好。谢谢
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。