简体   繁体   English

无法测试宁静的Web服务

[英]unable to test restful web service

I am creating a simple restful service and testing it using soapui. 我正在创建一个简单的Restful服务,并使用soapui对其进行测试。 Everytime I am getting error : 500 : Internal server error. 每次遇到错误时:500:内部服务器错误。 At server logs it shows class not found . 在服务器日志中显示未找到类。 Adding jars it starts conflicting. 添加罐子开始产生冲突。 I think it is jar issue only but do not know exact jars. 我认为这只是罐子问题,但不知道确切的罐子。

web.xml :- web.xml:-

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
  <display-name>Service</display-name>
 <servlet>
        <servlet-name>Jersey REST Service</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.service</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Jersey REST Service</servlet-name>
        <url-pattern>/rest/*</url-pattern>
    </servlet-mapping>  
</web-app>

jars:- 罐子: -

com.springsource.org.objectweb.asm_2.2.3.jar
jersey-client.jar
jersey-core.jar
jersey-gf-server.jar

Java Code:- Java代码:

package com.service;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;

@Path("/cal/")
public class RestService {

    @GET
    @Path("/one/")
    @Produces("application/xml")
    public String sanction(){               
        return new Sanction().servesRequest();
    }
}

wadl path :- http://localhost:8090/Service/rest/application.wadl wadl路径: -http:// localhost:8090 / Service / rest / application.wadl

I have tried changing jars, changing jersey servlet class name, eclipse, netbeans and many more but unable to get it on floor. 我尝试过更改jar,更改jersey servlet类名称,eclipse,netbeans等,但无法在地板上进行。

This was the jar issue. 这是罐子的问题。 I was downloading jars from https://jersey.java.net/download.html which contains 3 folders namely api,ext,lib but I was not using all jars from these folders by mistake. 我正在从https://jersey.java.net/download.html下载jar,其中包含3个文件夹,即api,ext,lib,但我没有错误地使用这些文件夹中的所有jar。 I also had to change web.xml as these jars are for jersey2.19 so the new web.xml is like 我还必须更改web.xml,因为这些罐子用于jersey2.19,所以新的web.xml就像

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
  <display-name>Service</display-name>
 <servlet>
    <servlet-name>REST Web </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.service</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>REST Web </servlet-name>
    <url-pattern>/rest/*</url-pattern>
  </servlet-mapping>

</web-app>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM