删除对 Modeshape 休息服务器的请求

问题描述 投票:0回答:1

我正在使用 Modeshape 休息服务器。 Modeshape 的版本是 2.8.2.

当我向某个节点(如

http://localhost:8080/modeshape-server/repo/workspace1/items/file
)发送 GET 请求时,它会返回有关该节点的信息。

但是当我在同一地址上发送 DELETE 请求(例如使用 Fiddler)时,它会返回

405 Method Not Allowed
。 根据 documentation 这样的地址应该支持 DELETE 请求。

更详细。 我发送:

DELETE http://localhost:8080/modeshape-server/repo/workspace1/items/uploads/file HTTP/1.1
User-Agent: Fiddler
Host: localhost:8080

我得到:

HTTP/1.1 405 Method Not Allowed
Server: Apache-Coyote/1.1
Allow: POST, OPTIONS
Content-Type: text/html;charset=utf-8
Content-Length: 984
Date: Tue, 04 Sep 2012 14:16:38 GMT

<html><head><title>JBoss Web/7.0.13.Final - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 405 - </h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>The specified HTTP method is not allowed for the requested resource ().</u></p><HR size="1" noshade="noshade"><h3>JBoss Web/7.0.13.Final</h3></body></html>

pom.xml,我用它来构建rest-server.war

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <properties>
        <modeshape.version>2.8.2.Final</modeshape.version>
    </properties>

    <parent>
        <artifactId>modeshape</artifactId>
        <groupId>org.modeshape</groupId>
        <version>2.8.2.Final</version>
    </parent>

    <groupId>modeshape.demo</groupId>
    <version>0.1</version>

    <artifactId>modeshape-server</artifactId>
    <packaging>war</packaging>
    <name>Modeshape rest server</name>
    <description>ModeShape servlet that provides RESTful access to JCR items</description>
    <url></url>
    <dependencies>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
        </dependency>

        <dependency>
            <groupId>org.modeshape</groupId>
            <artifactId>modeshape-web-jcr</artifactId>
            <version>${modeshape.version}</version>
        </dependency>

        <dependency>
            <groupId>org.modeshape</groupId>
            <artifactId>modeshape-jcr-api</artifactId>
            <version>${modeshape.version}</version>
        </dependency>

        <dependency>
            <groupId>org.modeshape</groupId>
            <artifactId>modeshape-jcr</artifactId>
            <version>${modeshape.version}</version>
        </dependency>

        <dependency>
            <groupId>org.modeshape</groupId>
            <artifactId>modeshape-search-lucene</artifactId>
            <version>${modeshape.version}</version>
        </dependency>

        <dependency>
            <groupId>org.modeshape</groupId>
            <artifactId>modeshape-cnd</artifactId>
            <version>${modeshape.version}</version>
        </dependency>

        <dependency>
            <groupId>org.modeshape</groupId>
            <artifactId>modeshape-repository</artifactId>
            <version>${modeshape.version}</version>
        </dependency>

        <dependency>
            <groupId>org.modeshape</groupId>
            <artifactId>modeshape-graph</artifactId>
            <version>${modeshape.version}</version>
        </dependency>

        <dependency>
            <groupId>org.modeshape</groupId>
            <artifactId>modeshape-common</artifactId>
            <version>${modeshape.version}</version>
        </dependency>

        <dependency>
            <groupId>org.modeshape</groupId>
            <artifactId>modeshape-web-jcr-rest</artifactId>
            <version>${modeshape.version}</version>
        </dependency>

        <dependency>
            <groupId>org.modeshape</groupId>
            <artifactId>modeshape-connector-jdbc-metadata</artifactId>
            <version>${modeshape.version}</version>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.6</version>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>org.modeshape</groupId>
            <artifactId>modeshape-connector-filesystem</artifactId>
            <version>${modeshape.version}</version>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
        </dependency>

        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-jaxrs</artifactId>
            <version>1.2.1.GA</version>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.10</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <repositories>
        <repository>
            <id>jboss</id>
            <url>http://repository.jboss.org/nexus/content/groups/public</url>
        </repository>
    </repositories>

    <build>
        <finalName>rest-server</finalName>
    </build>

</project>

我做错了什么吗?

我也在使用 JBoss-as-7.1.1。但响应中写的是 7.0.13.

而且我使用 Modeshape 休息不是作为服务。我将其用作正常部署的应用程序。 (抱歉,我对应用类型不太熟悉,听说JBoss-as里有一些服务,反正我没用过)

java rest http-delete modeshape
1个回答
3
投票

看起来 2.8.x 期望在

DELETE
请求中包含“Content-Type: application/json”标头。我怀疑由于请求没有这样的标头,因此 Web 应用程序没有该请求的处理程序。

ModeShape 确实提供了一个套件,可以将 ModeShape 2.x 作为服务安装在 JBoss AS 5 和 6 中,另一个套件可以将 ModeShape 3.0(仍处于 Beta 版)安装为 JBoss AS7 中的服务。好处是您的 1+ 应用程序只需查找

Repository
实例(通常通过 JNDI,尽管在 3.0 中您还可以使用 JavaEE
@Inject
注释将存储库自动注入到您的 EJB 或应用程序中)。

但是,JBoss AS7 中没有用于将 ModeShape 2.8.2 安装为服务的套件。

© www.soinside.com 2019 - 2024. All rights reserved.