2016-11-25 89 views
0

我已经在骡社区版3.8应用程序定义的流程如下:骡子APIkit:“流未找到”,而不是HTTP 415不支持的媒体类型

<flow name="post:/api/v1:application/json:api-v1-config"> 
    <set-property propertyName="Content-Type" value="application/json" doc:name="Property"/> 
    <expression-component> 
    payload = app.registry['RestServiceBean_2.10'].postApiCall(
     payload, 
     message); 
    </expression-component> 
</flow> 

而且在同一个文件映射为一个HTTP 415

<apikit:mapping statusCode="415"> 
    <apikit:exception value="org.mule.module.apikit.exception.UnsupportedMediaTypeException" /> 
    <set-property propertyName="Content-Type" value="application/json" doc:name="Property"/> 
    <set-payload value="{ &quot;message&quot;: &quot;Unsupported media type&quot; }" doc:name="Unsupported media type"/> 
</apikit:mapping> 

现在,当我将请求发送到该端点与Content-Type: application/xml,我在日志中看到一个异常称为Flow not found for resource ...和接收HTTP 500响应。

我错过了什么,在这种情况下,我必须告诉配置它应该返回HTTP 415的位置?

回答

0

我想通了,我必须从流动名中删除application/json:

<flow name="post:/api/v1:api-v1-config"> 
    <set-property propertyName="Content-Type" value="application/json" doc:name="Property"/> 

通过此配置,正确的异常(HTTP 415)被抛出。

0

如果你的项目没有错构瘤为基础的,你需要创建一个单独的流程来处理所有其他媒体类型,然后手动throw new org.mule.module.apikit.exception.UnsupportedMediaTypeException()

相关问题