APIM错误:API上的cURL DELETE命令返回运行时错误

时间:2014-09-09 07:56:13

标签: curl wso2 wso2esb wso2dss wso2-am

我的API将DSS服务作为后端,并具有用于GET,POST,PUT和DELETE操作的关联资源。但是,当我对服务发出DELETE操作时,即使在后端发生成功,APIM也会返回运行时错误:

curl -v -H "Authorization: Bearer 356bcb27f82c849e383d3765e0ccce" -X DELETE http://localhost:8280/fte/1.0/users/105/vacations/13
* Hostname was NOT found in DNS cache
*   Trying localhost...
* Connected localhost (localhost) port 8280 (#0)
> DELETE /fte/1.0/users/105/vacations/13 HTTP/1.1
> User-Agent: curl/7.36.0
> Host: localhost:8280
> Accept: */*
> Authorization: Bearer 356bcb27f82c849e383d3765e0ccce
>
< HTTP/1.1 202 Accepted
< Access-Control-Allow-Headers: authorization,Access-Control-Allow-Origin,Content-Type
< Content-Type: application/xml; charset=UTF-8
< Date: Tue, 09 Sep 2014 07:38:00 GMT
* Server WSO2-PassThrough-HTTP is not blacklisted
< Server: WSO2-PassThrough-HTTP
< Transfer-Encoding: chunked
<
* Connection #0 to host localhost left intact
<am:fault xmlns:am="http://wso2.org/apimanager"><am:code>0</am:code><am:type>Status report</am:type><am:message>Runtime Error</am:message><am:description>Error while building message</am:description></am:fault>[

如何防止出现此类错误?我是否需要来自后端服务的输出消息,以便它不显示此运行时错误?

由于

1 个答案:

答案 0 :(得分:1)

这是因为您的后端服务不响应邮件正文。而是仅发送HTTP状态代码。 APIManager尝试从该空载荷构建消息。为了防止你打开api配置(repository / deploymnet / server / synapse-config / default / api) 对于DELETE操作,在发送到后端之前通过设置OUT_ONLY属性使其成为单向消息。

<property name="OUT_ONLY" value="true"/>

确保仅为DELETE操作设置该属性。如果其他操作返回任何响应主体,则此属性将影响它们。