Skip to main content

#'hi'0 人がディスカッション中

Am building an API using RAML (APIKit Router) and i want to send the response with a header field "Content-Disposition"

 

I don't see any place in Mule 4 to set HTTP Response headers rather than directly mentioning on HTTP Listener. I don't want to do that on HTTP Listener as it impacts other resources/paths.

 

and i see that mulesoft documentation mentions about accessing attributes and http headers. but stupid thing doesnt give details about how to set header attributes.

 

am really pissed off with this. anybody can help me on this ?

3 件の回答
  1. 2019年12月11日 7:56

    <flow name="testhttpFlow" doc:id="beb4b2ce-9a41-44ad-bf8a-37bf4a5613d0" >

          <http:listener doc:name="Listener" doc:id="4f8d7d19-9c3c-433d-afcd-ddd12241d92e" config-ref="HTTP_Listener_config" path="/">

             <http:response statusCode="#vars.httpStatus default 200">

           <http:headers>#vars.outboundHeaders default {}</http:headers>

       </http:response>

     

          </http:listener>

          <logger level="INFO" doc:name="Logger" doc:id="6e1fac7b-d610-4406-81ec-5193a63a5145" message="test req :::: #payload"/>

          <ee:transform doc:name="Transform Message" doc:id="ef8e8e24-21c4-4aa3-bcad-8ce57e05d207" >

             <ee:message >

             </ee:message>

             <ee:variables >

                <ee:set-variable variableName="outboundHeaders" ><![CDATA[%dw 2.0

    output application/json

    ---

    {

       "correlation": correlationId

     

    }]]></ee:set-variable>

             </ee:variables>

          </ee:transform>

          <!-- <scripting:execute doc:name="Execute" doc:id="a35ff2e4-1f6c-49d0-9fc0-f445f897f898" engine="groovy">

             <scripting:code >vars.outboundHeaders.put('Content-Disposition', 'form-data');

    vars.outboundHeaders.put('ddd', 'dd');</scripting:code>

          </scripting:execute> -->

          <set-payload value="#'hi'" doc:name="Set Payload" doc:id="d74cb14a-b32d-4ccf-bdba-4ef001c7b378" />

       </flow>

     

    please try to run this flow.. commented groovy if you want without dw , we can use this also

0/9000