Nat*_*dle 4 rest synchronous mule
**问题解决了,这要归功于neildo。这是从POST获得回复所需要的
我的REST Flow的实现调用一个Java API,该Java API返回一个Java对象。然后,我将该对象转换为JSON文档,并将其返回给客户端。我的Logger步骤正在记录正确的数据,但是客户端只得到200 OK且为空。
我有我的所有流量设置同步和我的HTTP端点,以请求-响应。我想念什么?
谢谢!内森
这是我的XML文件
<apikit:config name="IAMPerson-config" raml="IAMPerson.raml" consoleEnabled="true" consolePath="console" doc:name="Router"/>
<apikit:mapping-exception-strategy name="IAMPerson-apiKitGlobalExceptionMapping">
<apikit:mapping statusCode="404">
<apikit:exception value="org.mule.module.apikit.exception.NotFoundException" />
<set-property propertyName="Content-Type" value="application/json" />
<set-payload value="{ "message": "Resource not found" }" />
</apikit:mapping>
...
</apikit:mapping-exception-strategy>
<flow name="IAMPerson-main" doc:name="IAMPerson-main" processingStrategy="synchronous">
<http:inbound-endpoint address="http://localhost:8081/api" doc:name="HTTP" exchange-pattern="request-response" password="admin" user="admin" contentType="application/json"/>
<apikit:router config-ref="IAMPerson-config" doc:name="APIkit Router"/>
<exception-strategy ref="IAMPerson-apiKitGlobalExceptionMapping" doc:name="Reference Exception Strategy"/>
</flow>
<flow name="post:/person:IAMPerson-config" doc:name="post:/person:IAMPerson-config" processingStrategy="synchronous">
<json:json-to-object-transformer doc:name="JSON to Object" returnClass="PersonDTO"/>
<invoke name="invokeCreate" object-ref="personService" method="create" methodArguments="#[payload]"></invoke>
<json:object-to-json-transformer sourceClass="Person" doc:name="Person Object to JSON"/>
<logger level="INFO" doc:name="Logger" message="#[payload]"/>
</flow>
<flow name="put:/person:IAMPerson-config" doc:name="put:/person:IAMPerson-config" processingStrategy="synchronous">
<logger level="INFO" doc:name="Logger" message="#[payload]"/>
<json:json-to-object-transformer doc:name="JSON to Object" returnClass="PersonDTO"/>
<invoke name="invokeUpdate" object-ref="personService" method="update" methodArguments="#[payload]"/>
<json:object-to-json-transformer sourceClass="Person" doc:name="Person Object to JSON"/>
<logger level="INFO" doc:name="Logger" message="#[payload]"/>
</flow>
Run Code Online (Sandbox Code Playgroud)
这是我的RAML文件的一部分,在其中定义了请求和响应主体。当我向Mule发布消息时,出现此错误,但没有任何记录到Mule控制台。
null(java.lang.NullPointerException)。消息有效负载的类型为:ContentLengthInputStream
post:
body:
application/json:
responses:
200:
body:
application/json:
Run Code Online (Sandbox Code Playgroud)
在您的raml文件中,确保您的资源方法正在将响应200正文与application / json映射。例如...
/person:
post:
responses:
200:
body:
application/json:
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6634 次 |
| 最近记录: |