Mule 使用postman中的content type标头跟踪来自postman的内容类型

Mule 使用postman中的content type标头跟踪来自postman的内容类型,mule,anypoint-studio,Mule,Anypoint Studio,我开发了两个json和xml转换的mule流来打印名字和姓氏。我正在使用choice组合这两个流。现在在postman中,我想通过将头键设置为content type,值设置为application/json或application/xml来获得单独的输出。如何设置 您可以在dataweave中访问这些查询参数,并将其转换为json。然后使用set payload消息处理器,您可以将输出返回给postman。只需确保根据您在set payload message processor中的要求,将m

我开发了两个json和xml转换的mule流来打印名字和姓氏。我正在使用choice组合这两个流。现在在postman中,我想通过将头键设置为content type,值设置为application/json或application/xml来获得单独的输出。如何设置


您可以在dataweave中访问这些查询参数,并将其转换为json。然后使用set payload消息处理器,您可以将输出返回给postman。只需确保根据您在set payload message processor中的要求,将mimeType设置为application/json或application/xml。

您需要添加一个响应转换器,如下所示,但最好的方法是使用RAML,这将使您的工作变得简单,并且不需要选择组件

<response>
  <message-properties-transformer>
    <add-message-property key="Content-Type" value="application/json" />
  </message-properties-transformer>
</response>

<response>
  <message-properties-transformer>
    <add-message-property key="Content-Type" value="application/xml" />
  </message-properties-transformer>
</response>