【问题标题】:Configuring Glassfish 3.1.2 Server to allow PUT, DELETE配置 Glassfish 3.1.2 服务器以允许 PUT、DELETE
【发布时间】:2013-02-06 22:49:31
【问题描述】:

我在配置 Glassfish 3.1.2 服务器以允许对使用 Netbeans“从数据库创建新的 RESTful webservice”向导创建的 RESTful webservice 的 PUT、DELETE 请求时遇到问题。奇怪的是,我设法让一个 web 服务正常工作,而其他网络服务却没有。谁能解释一下我在哪里/如何配置它?

HTTP/1.1 405 Method Not Allowed
X-Powered-By: Servlet/3.0 JSP/2.2 (GlassFish Server Open Source Edition 3.1.2.2 Java/Oracle Corporation/1.7)
Server: GlassFish Server Open Source Edition 3.1.2.2
Allow: GET,DELETE,OPTIONS,HEAD
Content-Type: text/html
Content-Length: 1153
Date: Tue, 05 Feb 2013 18:35:05 GMT

有效的请求头如下:

Accept:application/json, text/javascript, */*; q=0.01
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-GB,en-US;q=0.8,en;q=0.6
Connection:keep-alive
Content-Length:133
Content-Type:application/json
Cookie:JSESSIONID=b8ec1fb7ae9de4b5536363f4041d; JSESSIONID=b80bb2fbf45363cfe1b61b625890; treeForm_tree-hi=treeForm:tree:configurations:server-config:networkConfig:networkListeners:http-listener-2
Host:localhost:8080
Origin:http://localhost:8080
Referer:http://localhost:8080/mtpStories/faces/index.jsp
User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.17 (KHTML, like Gecko)    Chrome/24.0.1312.57 Safari/537.17
X-Requested-With:XMLHttpRequest

这是失败的请求(不同的网络服务):

Accept:application/json, text/javascript, */*; q=0.01
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-GB,en-US;q=0.8,en;q=0.6
Connection:keep-alive
Content-Length:88
Content-Type:application/json
Cookie:JSESSIONID=ba3ad55776f2c7ea35f6dcbe56d2; JSESSIONID=b9fe5da81c67a083beb2001a6dbf; treeForm_tree-hi=treeForm:tree:configurations:default-config:httpService:httpListeners:http-listener-2
Host:localhost:8080
Origin:http://localhost:8080
Referer:http://localhost:8080/mtpUsers/faces/index_users.jsp
User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.17 (KHTML, like Gecko)    Chrome/24.0.1312.57 Safari/537.17
X-Requested-With:XMLHttpRequest

【问题讨论】:

    标签: web-services configuration glassfish-3 restful-authentication


    【解决方案1】:

    查看您的 web.xml。有任何 定义吗?例如

       <security-constraint>
            ...
            <web-resource-collection>
                <web-resource-name>test</web-resource-name>
                <description/>
                <url-pattern>/mtpStories/*</url-pattern>
                <http-method>GET</http-method>
                <http-method>DELETE</http-method>
                <http-method>OPTIONS</http-method>
                <http-method>HEAD</http-method>
            </web-resource-collection>
            ....
       </security-constraint>
    

    【讨论】:

    • 我删除了所有安全约束,即使我将其添加为 http 方法,PUT 也不起作用
    • 您是否定义了任何可能修改 HTTP 标头的过滤器?
    猜你喜欢
    • 2012-08-17
    • 1970-01-01
    • 1970-01-01
    • 2017-06-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多