问题
I created a hello world REST service and now I d like to generate the WADL file.
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
I also tried calling :
http://localhost:8090/<myapplicattion_name>.wadl but still no result.
Is this feature supported by Jersey 1.7? If yes what do i do wrong?
The web.xml file looks like this:
Thank you
回答1:
What is the name of your app in Apache, i.e., "context"? Assume the name is "restApp". Try this:
http://localhost:8090/restApp/application.wadl
Or, if you servlet mapping is:
<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
回答2:
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 :
<?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
In my case :
JAXRS_HelloWorld is project name
rest is url pattern
来源:https://stackoverflow.com/questions/19424000/how-to-generate-wadl-file-using-jersey-1-7