此 URL WL 12.2.1 上的 Rest-full WS 不支持 HTTP 方法 GET

HTTP method GET is not supported by this URL Rest-full WS on WL 12.2.1

我开发了一个在 tomcat.

上成功运行的 Rest-full WS

应用程序在Weblogic 12.2.1 中部署成功,没有任何异常。然而,在点击 URI 时,我面临 "HTTP method GET is not supported by this URL Rest-full WS" 作为回应。

POST 方法以及生成 wadl 时也会发生这种情况。

下面是 Rest WS 实现 class

@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

我检查了以下链接,但我能找到任何帮助

我得到了解决方案。 12.2.1,不再支持 WebLogic Server Jersey 1.x 服务器端 API。您应该改用相应的标准 JAX-RS 2.0 或 Jersey 2.x APIs。 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