Java 如何使用 Jersey 1.7 生成 WADL 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19424000/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to generate WADL file using Jersey 1.7
提问by panipsilos
I created a hello world REST service and now I d like to generate the WADL file.
我创建了一个 hello world REST 服务,现在我想生成 WADL 文件。
I looked around and saw that I can do so by calling :
我环顾四周,发现我可以通过调用:
http://localhost:8090/application.wadl
However I dont get anything in my case. I am using Jersey 1.7 with Eclipse Indigo and running on Apache 7
但是,我没有得到任何东西。我正在使用 Jersey 1.7 和 Eclipse Indigo 并在 Apache 7 上运行
I also tried calling :
我也试过打电话:
http://localhost:8090/<myapplicattion_name>.wadl
but still no result.
http://localhost:8090/<myapplicattion_name>.wadl
但仍然没有结果。
Is this feature supported by Jersey 1.7? If yes what do i do wrong?
Jersey 1.7 是否支持此功能?如果是,我做错了什么?
The web.xml file looks like this:
web.xml 文件如下所示:
Thank you
谢谢
采纳答案by ChrisO
What is the name of your app in Apache, i.e., "context"? Assume the name is "restApp". Try this:
您的应用程序在 Apache 中的名称是什么,即“上下文”?假设名称是“restApp”。尝试这个:
http://localhost:8090/restApp/application.wadl
Or, if you servlet mapping is:
或者,如果您的 servlet 映射是:
<servlet-mapping>
<servlet-name>RESTService</servlet-name>
<url-pattern>/company/rest/*</url-pattern>
</servlet-mapping>
..it would be:
..这将是:
http://localhost:8090/restApp/company/rest/application.wadl
回答by Balaji Boggaram Ramanarayan
Its usually under this pattern:
它通常在这种模式下:
http://<hostname>:<port>/<PROJECTNAME>/<servlet URL Pattern>/application.wadl
Say suppose if you project deployment desc(web.xml) looks like this :
假设您的项目部署 desc(web.xml) 如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>Restful Web Application</display-name>
<servlet>
<servlet-name>jersey-helloworld-serlvet</servlet-name>
<servlet-class>
com.sun.jersey.spi.container.servlet.ServletContainer
</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>com.example.rest.jersey</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>jersey-helloworld-serlvet</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
</web-app>
Then the url will be something like : http://localhost:8080/JAXRS-HelloWorld/rest/application.wadl
然后网址将是这样的: http://localhost:8080/JAXRS-HelloWorld/rest/application.wadl
In my case :
就我而言:
JAXRS_HelloWorld is project name
rest is url pattern