REST POST在wildflyv10中返回状态405

时间:2016-03-31 23:02:25

标签: java rest jboss wildfly wildfly-10

我的服务定义为:

@Path("/fileservice")
public class FileService {

@POST
@Path("/path")
@Consumes("application/xml")
public Response getFilePath(FileRequest fileRequest) {

    System.out.println("....." + fileRequest.client);

    (...)
}

我的激活者:

@ApplicationPath("/services")
public class JaxRsActivator extends Application{

}

XML文件映射定义为:

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name="fileDetails")
public class FileRequest {
    @XmlElement public String path;
    @XmlElement public String client;

我的客户是:

public static void main(String args[]) throws Exception {

    URI uri = new URI(SERVICE_URL);

    Client client = ClientBuilder.newClient();

    String xml = "<fileDetails> "
            + "<path>usr/test/a.pdf</path>"
            + "<client>abc</client>"
            +"</fileDetails>" ;

    Response response= client.target(uri).request().post(Entity.xml(xml));
    System.out.println("Request posted :"+ response.getAllowedMethods());
    System.out.println("Request posted, response status :"+ response.getStatus());

当我向网址http://localhost:8080/xx/services/fileservice/path发送请求时,我的格式为response.getStatus()为405。

我在这里做错了什么?

0 个答案:

没有答案