Mule 3.7中的HTTP请求连接器有效负载(POST)

时间:2016-12-21 20:19:50

标签: http-post mule

我有一个带有JSON有效负载的异步流(Payload Type为java.lang.String)并尝试对HTTP请求连接器执行POST但我收到400错误。当我在调试器中运行应用程序时,有效负载类型从JSON字符串更改为org.glassfish.grizzly.utils.BufferInputStream,我认为这是问题。

enter image description here

如何解决此问题?

由于

2 个答案:

答案 0 :(得分:0)



   <flow name="createFlow">
        <vm:inbound-endpoint exchange-pattern="one-way" path="createApi" connector-ref="VMConfiguration" doc:name="VM"/>
        <enricher doc:name="Message Enricher" source="payload" target="#[flowVars.createApiPayload]">
            <flow-ref name="createBomCollection" doc:name="createBomCollection"/>
        </enricher>
        <logger message="Payload after Create Api Call: #[message.payloadAs(java.lang.String)]" level="INFO" doc:name="Logger"/>
        <set-payload value="#[message.payload]" mimeType="application/json" doc:name="Set Payload"/>
        <dw:transform-message doc:name="Transform Message">
            <dw:set-payload><![CDATA[%dw 1.0
%output application/json
---
{
    (createApi: payload.createApi) when (payload.createApi != null)
	
}]]></dw:set-payload>
        </dw:transform-message>
    </flow>
    <sub-flow name="createApiCollection">
        <set-session-variable variableName="retryCount" value="#[new java.util.concurrent.atomic.AtomicInteger(0)]" doc:name="initialize retryCount"/>
        <logger message="Payload before system Post: #[message.payload]" level="INFO" doc:name="Logger"/>
        <http:request config-ref="System_HTTP_Request_Configuration" path="/bom1" method="POST" doc:name="HTTP">
            <http:request-builder>
                <http:header headerName="Content-Type" value="application/json"/>
                <http:header headerName="requestID" value="#[sessionVars.requestID]"/>
                <http:header headerName="transactionID" value="#[sessionVars.transactionID]"/>
                <http:header headerName="quoteID" value="#[sessionVars.quoteID]"/>
                <http:header headerName="operationName" value="#[sessionVars.operationName]"/>
            </http:request-builder>
        </http:request>
</sub-flow>
&#13;
&#13;
&#13;

答案 1 :(得分:0)

如果使用Dataweave转换器,则使用JAVA输出返回类型为“ org.glassfish.grizzly.utils.BufferInputStream ”的Object,例如:

%dw 1.0
%output application/java
---
payload

尝试在Dataweave转换后将Object添加到JSON!

<object-to-string-transformer doc:name="Object to String"/>