title: How to overcome Invalid token character caused by Content-Type=[text/xml; subtype=gml/2.1.2] in Spring HttpMessageConverterExtractor?
body: <p>I'm stuck at exception</p>
  
  <pre><code>java.lang.IllegalArgumentException: Invalid token character '/' in token "gml/2.1.2"
  at org.springframework.http.MediaType.checkToken(MediaType.java:354)
  </code></pre>
  
  <p>I'm using Spring Integration 3.0 RC1 and http outbound gateway to send request to Geoserver.
  Unfortunately the exception is thrown from inside of org.springframework.web.client.RestTemplate which I cannot override (outbound gateway manages it), so it's to deep for me to change the headers by some HeaderMapper as I've already tried. I'm also unable to change the request header coming from external site, as it's produced by Geoserver.</p>
  
  <p>The error cause header is:
  <strong>Content-Type=[text/xml; subtype=gml/2.1.2]</strong></p>
  
  <p>Please give me some clues if you have one, I'm struggling with it for several days now.</p>
  
  <p>My spring integration setup:</p>
  
  <pre><code>&lt;util:list id="wfsProxyMessageConverterList"&gt;
      &lt;bean class="xxx.StringWfsHttpMessageConverter" /&gt;
      &lt;bean class="xxx.ByteArrayWfsHttpMessageConverter" /&gt;       
  &lt;/util:list&gt;
  
  &lt;int:channel id="wfsRequest"&gt;&lt;/int:channel&gt;
  &lt;int:channel id="wfsResponse"&gt;&lt;/int:channel&gt;
  
  &lt;bean id="wfsHeaderMapper" class="xxx.WfsHeaderMapper" /&gt;
  
  &lt;int-http:inbound-gateway id="wfsInboundGateway" supported-methods="POST"
      request-channel="wfsRequest" reply-channel="wfsResponse"
      path="/gisproxy/wfs" reply-timeout="10000"  
      header-mapper="wfsHeaderMapper"         
          message-converters="wfsProxyMessageConverterList"
  
      /&gt;
  
  &lt;int-http:outbound-gateway id="wfsOutboundGateway"
      request-channel="wfsRequest" reply-channel="wfsResponse"
      url="#{geoserverConfig.url}/wfs"
      http-method="POST" charset="UTF-8" reply-timeout="10000"
      expected-response-type="java.lang.String"
      message-converters="wfsProxyMessageConverterList"
      header-mapper="wfsHeaderMapper"
  
      encode-uri="false" request-factory="apacheCommonsHttpClient"&gt;               
  &lt;/int-http:outbound-gateway&gt;
  </code></pre>
  
  <p>Cheers,
  denu</p>
  
  <p>--- edit: added stack trace ---</p>
  
  <pre><code>SEVERE: Servlet.service() for servlet [core] in context with path [/myapp] threw exception [Request processing failed; nested exception is org.springframework.integration.MessageHandlingException: HTTP request execution failed for URI [https://xx.xxx.xxx.xx:8181/geoserver/wfs]] with root cause
  java.lang.IllegalArgumentException: Invalid token character '/' in token "gml/2.1.2"
  at org.springframework.http.MediaType.checkToken(MediaType.java:354)
  at org.springframework.http.MediaType.checkParameters(MediaType.java:374)
  at org.springframework.http.MediaType.&lt;init&gt;(MediaType.java:335)
  at org.springframework.http.MediaType.parseMediaType(MediaType.java:722)
  at org.springframework.http.HttpHeaders.getContentType(HttpHeaders.java:305)
  at org.springframework.web.client.HttpMessageConverterExtractor.getContentType(HttpMessageConverterExtractor.java:113)
  at org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:84)
  at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:687)
  at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:673)
  at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:491)
  at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:460)
  at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:409)
  at org.springframework.integration.http.outbound.HttpRequestExecutingMessageHandler.handleRequestMessage(HttpRequestExecutingMessageHandler.java:372)
  at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:142)
  at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:73)
  at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:115)
  at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:102)
  at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:77)
  at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:178)
  at org.springframework.integration.core.MessagingTemplate.doSend(MessagingTemplate.java:304)
  at org.springframework.integration.core.MessagingTemplate.doSendAndReceive(MessagingTemplate.java:335)
  at org.springframework.integration.core.MessagingTemplate.sendAndReceive(MessagingTemplate.java:255)
  at org.springframework.integration.gateway.MessagingGatewaySupport.doSendAndReceive(MessagingGatewaySupport.java:234)
  at org.springframework.integration.gateway.MessagingGatewaySupport.sendAndReceiveMessage(MessagingGatewaySupport.java:208)
  at org.springframework.integration.http.inbound.HttpRequestHandlingEndpointSupport.actualDoHandleRequest(HttpRequestHandlingEndpointSupport.java:478)
  at org.springframework.integration.http.inbound.HttpRequestHandlingEndpointSupport.doHandleRequest(HttpRequestHandlingEndpointSupport.java:380)
  at org.springframework.integration.http.inbound.HttpRequestHandlingMessagingGateway.handleRequest(HttpRequestHandlingMessagingGateway.java:101)
  at org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter.handle(HttpRequestHandlerAdapter.java:49)
  at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
  at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
  at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:920)
  at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:827)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
  at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:801)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
  at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
  at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
  at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
  at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
  at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
  at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
  at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
  at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
  at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
  at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
  at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
  at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
  at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
  at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
  at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
  at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
  at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:183)
  at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
  at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
  at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
  at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
  at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
  at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
  at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
  at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
  at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
  at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
  at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
  at org.springframework.orm.hibernate4.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:152)
  at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
  at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
  at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
  at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
  at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
  at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
  at java.lang.Thread.run(Thread.java:724)
  </code></pre>