我开发了一个Rest-full WS,可以在tomcat上成功运行。
应用程序在Weblogic 12.2.1中成功部署,没有任何例外。但是,在点击URI时,我面临“HTTP方法GET不受此URL Rest-full WS支持”作为响应。
这也适用于POST方法以及生成wadl时。
下面是Rest WS实现类
@POST
@Path("/activateService")
@Consumes({MediaType.APPLICATION_XML})
@Produces({MediaType.APPLICATION_XML})
public Response crunchifyREST**(JsonObject model**, @Context
HttpServletRequest request) {
}
@GET
@Path("/verify")
@Produces(MediaType.TEXT_PLAIN)
public Response verifyRESTService(InputStream incomingData) {
String result = "GMPPMediatorTIMService Successfully started..";
// return HTTP response 200 in case of success
return Response.status(200).entity(result).build();
}
web.xml: -
<servlet>
<servlet-name>FacadeHandsetTimpay</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.trivnet.mediator.tim.services</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>FacadeHandsetTimpay</servlet-name>
<url-pattern>/api/*</url-pattern>
</servlet-mapping>
我使用URI作为: - http://localhost:8070/FacadeHandsetTimpay/api/getLastTimPayTransactions
我检查了以下链接,但我可以找到任何帮助 HTTP method GET is not supported by this URL. (Java rest api with jersey)
答案 0 :(得分:0)
我找到了解决方案。 12.2.1,不再支持WebLogic Server Jersey 1.x服务器端API。您应该改用相应的标准JAX-RS 2.0或Jersey 2.x API。不建议使用Jersey 1.x客户端API。建议您尽早使用RESTful客户端应用程序进行更新,以使用JAX-RS 2.0客户端API。
因此,删除这些依赖项:
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-bundle</artifactId>
<version>1.19</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.19</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
<version>1.19</version>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.0-m12</version>
并使用以下依赖项:
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
<version>2.17</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<version>2.17</version>
</dependency>
并且还如下更改web.xml:-
<servlet>
<servlet-name>FacadeHandsetTimpay</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>com.trivnet.mediator.tim.services</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>FacadeHandsetTimpay</servlet-name>
<url-pattern>/api/*</url-pattern>
</servlet-mapping>
来源:- https://docs.oracle.com/middleware/12212/wls/RESTF/intro-restful-service.htm#RESTF109