title: How do I check the inbound header "content-type" response in mule?
body: <p>I've got a flow that processes the response from a REST service:</p>
  
  <pre><code>    &lt;http:outbound-endpoint method="GET"
                              address="http://www.SomeAddress.com"
                              exchange-pattern="request-response"&gt;
          ...
          &lt;response&gt;
              &lt;json:json-to-object-transformer/&gt;
              &lt;custom-transformer ... /&gt;
          &lt;/response&gt;
      &lt;/http:outbound-endpoint&gt;
  </code></pre>
  
  <p>Recently the service has been updated to return html content.  I'd like to be able to identify the content-type in the response: </p>
  
  <pre><code>    &lt;http:outbound-endpoint method="GET"
                              address="http://www.SomeAddress.com"
                              exchange-pattern="request-response"&gt;
          ...
          &lt;response&gt;
              &lt;choice&gt;
                  &lt;when content-type is html&gt;
                      &lt;custom-transformer-for-html ... /&gt;
                  &lt;/when&gt;
                  &lt;otherwise&gt;
                      &lt;json:json-to-object-transformer/&gt;
                      &lt;custom-transformer ... /&gt;
                  &lt;/otherwise&gt;
              &lt;/choice&gt;
          &lt;/response&gt;
      &lt;/http:outbound-endpoint&gt;
  </code></pre>
  
  <p>Even better, it would be nice to simply throw an exception if the content-type is unrecognized, similar to a traditional switch statement:</p>
  
  <pre><code>switch (content-type) {
      case (html) : ...
      case (json): ...
      default: throw exception
  }
  </code></pre>
  
  <p>Can a choice statement check the inbound header content-type?  Is the switch with default check possible?  Are there any examples I can look at?</p>
  
  <p>--- Update ---</p>
  
  <p>I tried Davids suggestion below:</p>
  
  <pre><code>        &lt;response&gt;                
              &lt;choice&gt;
                  &lt;when expression="#[message.inboundProperties['Content-Type'].contains('text/html')]"&gt;
                      &lt;logger message="when number one invoked" level="WARN"/&gt;
                  &lt;/when&gt;
                  &lt;when expression="#[message.inboundProperties['Content-Type'].contains('application/json')]"&gt;
                     &lt;logger message="when number two invoked" level="WARN"/&gt;
                  &lt;/when&gt;
                  &lt;otherwise&gt;
                      &lt;logger message="otherwise invoked" level="WARN"/&gt;
                  &lt;/otherwise&gt;
              &lt;/choice&gt;
          &lt;/response&gt;
  </code></pre>
  
  <p>But now I'm getting the following error when I compile:</p>
  
  <pre><code>    cvc-complex-type.2.4.a: Invalid content was found starting with element 'choice'. 
      One of '{"http://www.mulesoft.org/schema/mule/core":abstract-transformer,
      "http://www.mulesoft.org/schema/mule/core":abstract-filter,
      "http://www.mulesoft.org/schema/mule/core":abstract-security-filter, 
      "http://www.mulesoft.org/schema/mule/core":abstract-intercepting-message-processor, 
      "http://www.mulesoft.org/schema/mule/core":abstract-observer-message-processor,
      "http://www.mulesoft.org/schema/mule/core":processor, 
      "http://www.mulesoft.org/schema/mule/core":custom-processor}' is expected. 
      (org.xml.sax.SAXParseException)
        org.apache.xerces.util.ErrorHandlerWrapper:-1 (null)
  </code></pre>