Announcement Announcement Module
Collapse
No announcement yet.
How to set Content Type in HttpServletResponse to "application/soap+xml" Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to set Content Type in HttpServletResponse to "application/soap+xml"

    I have a spring integration based web application which interacts with a back end web application that is a JEE application.

    I have a very simple http-inbound-gateway within Spring integration based web application which receives a SOAP 1.2 message ( from .Net application) and I pass that message received to a chain containing a http-outbound-gateway, which in turn calls a web service in JEE application (which also uses spring-ws for the web service) .

    I have to make sure that response that is returned has content type of application/soap+xml. How can I make it to happen? Currently the SOAP message reaches the web services in JEE application, but it always returns text/xml in content type in the HTTP response header.

    I am posting below my configuration details. I tried using header enricher both before sending ( so that I explicitly set the accept header to accept application/soap+xml) to outbound gateway as well as after receiving from outbound gate way ( to set the header in response to Content-Type="application/soap+xml) . It did not work.

    I tried on the Java web application web services to use produces attribute as below ( available in 3.2.3) , it also did not work, though I would prefer to set content type within spring integration web application instead of in JEE application:

    My Web Services:
    =============
    @RequestMapping( produces="application/soap+xml" )
    @PayloadRoot(namespace = NAMESPACE_URI, localPart = "MyRequest")
    @ResponsePayload
    public MyResponse getMyService(@RequestPayload MyRequest request) {

    ....
    }



    I use spring integration 2.2.3, Spring-WS 2.1.2 & Spring core 3.2.3

    My integration configuration file is as below:
    ===================================
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:int="http://www.springframework.org/schema/integration"
    xmlns:int-http="http://www.springframework.org/schema/integration/http"
    xsi:schemaLocation="http://www.springframework.org/schema/integration/ws
      		http://www.springframework.org/schem...gration-ws.xsd
      		http://www.springframework.org/schema/integration
      		http://www.springframework.org/schem...ntegration.xsd
      		http://www.springframework.org/schem...gration/stream
    		http://www.springframework.org/schem...ion-stream.xsd
      		http://www.springframework.org/schema/context 
      		http://www.springframework.org/schem...ontext-3.0.xsd
      		http://www.springframework.org/schema/beans
      		http://www.springframework.org/schem...ring-beans.xsd
      		http://www.springframework.org/schema/integration/http 
      		http://www.springframework.org/schema/integration/http/spring-integration-http-2.2.xsd"
      		>
    
    
    
    <int-http:inbound-gateway id="http-requestGateway"
    request-channel="http-requestChannel"
    reply-channel="http-response-channel"
    />
    
    <int:channel id="http-requestChannel"/> 
    <int:channel id="http-response-channel"/> 
    
    <int:chain input-channel="http-requestChannel" output-channel="http-response-channel">
    
    		<int:header-enricher>  			    
    			    <int:header
    			        name="Content-Type"
    			        value="application/soap+xml"
    			        overwrite="true"/>
    			       
    			      <int:header
    			        name="Accept"
    			        value="application/soap+xml"
    			        overwrite="true"/>  
    			        
    			        <int:header
    			        name="AcceptHEADR"
    			        value="application/soap+xml"
    			        overwrite="true"/>   
    			         
    		</int:header-enricher>
    		
    		
    		<int-http:outbound-gateway 		
    		url="http://${webservices.my.host}:${webservices.my.port}/my/ws/MyService/"
    		http-method="POST"
    		expected-response-type-expression="java.lang.String"
    		charset="UTF-8"
    		/>
    		
    		<int:header-enricher>  			    
    			    <int:header
    			        name="Content-Type"
    			        value="application/soap+xml"
    			        overwrite="true"/>
    			       
    			        
    		</int:header-enricher>
    
    		
    </int:chain>
    </beans>
    Last edited by Gary Russell; Jul 23rd, 2013, 11:21 AM.

  • #2
    When posting code/config, please use [ code ] ... [ /code ] tags (no spaces in brackets); I edited your post.

    Nothing jumps out at me; I suggest you turn on DEBUG logging and trace a message through the flow - the header mappers put out a good deal of diagnostics.

    Comment


    • #3
      Hi!
      @RequestMapping( produces="application/soap+xml" )
      Don't confuse yourself: that means, that your request will be processed with controler's mwthod only if request header 'Accept' has value 'application/soap+xml'. Forget it for current use-case.

      And, as you say, external service return 'Content-Type' as ' text/xml'. So, it ignores your 'Accept' header anyway.
      It looks like your last <header-enricher> should work. But...
      So, as Gary suggests, can you DEBUG it and show us what's going on?
      I'll test it tomorrow.

      Take care,
      Artem

      Comment

      Working...
      X