Announcement Announcement Module
Collapse
No announcement yet.
Message Converter Issue in http:inbound-gateway Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Message Converter Issue in http:inbound-gateway

    Hi,

    I am unable to figure out the issue as to why the message converter is not getting invoked in the gateway. My integration version 2.2.3 and Spring 3.1

    Gateway config
    Code:
    <int-http:inbound-gateway id="inboundOpportunitiesSearchRequestGateway"
    	supported-methods="GET, POST" request-channel="opportunitiesSearchRequest"
    	reply-channel="opportunitiesSearchResponse" message-converters="messageConverter"
    	path="/service/opportunities" reply-timeout="50000"/>
    
    <util:list id="messageConverter">
    	<ref bean="marshallingConverter"/>
    </util:list>
       
    <bean id="marshallingConverter"
    	class="org.springframework.http.converter.xml.MarshallingHttpMessageConverter">
    	<constructor-arg index="0" ref="marshaller" />
    	<constructor-arg index="1" ref="marshaller" />
    </bean>
    
    <oxm:jaxb2-marshaller id="marshaller">
    	<oxm:class-to-be-bound name="com.fedbid.ump.model.dto.OpportunityRequest" />
    	<oxm:class-to-be-bound name="com.fedbid.ump.model.dto.MobileBaseResponse" />
    </oxm:jaxb2-marshaller>
    Client code
    Code:
    final String fullUrl = "http://localhost:6179/umpservice/service/opportunities";
    
    @Test
    public void testGetOpportunityAsXml() throws Exception {  
    		String inputString = "<?xml version='1.0' encoding='UTF-8' standalone='yes'?><ns2:OpportunityRequest xmlns:ns2='http://schemas.fedbid.com/buybizservice'><SELLER_EMAIL>[email protected]</SELLER_EMAIL><SERVICE_NAME>GET_OPPORTUNITIES</SERVICE_NAME><ORG_ID>10</ORG_ID></ns2:OpportunityRequest>";
    
    		HttpHeaders headers = new HttpHeaders();
    		headers.add("Accept", "text/xml");
    		headers.setContentType(MediaType.TEXT_XML);
    		HttpEntity<String> requestEntity = new HttpEntity<String>(inputString, headers);
    		
    		ResponseEntity<String> responseEntity = restTemplate.exchange(fullUrl, HttpMethod.POST, requestEntity, String.class);
    }
    Exception:

    org.springframework.integration.MessagingException : Could not convert request: no suitable HttpMessageConverter found for expected type [java.lang.String] and content type [text/xml]
    Last edited by Gary Russell; May 21st, 2013, 02:27 PM.

  • #2
    Hi!

    In addition you have to use request-payload-type attribute on the <int-http:inbound-gateway>.
    Take a look into source code of HttpRequestHandlingEndpointSupport#extractRequestB ody and further to the MarshallingHttpMessageConverter#supports

    It should help you to understand what's going on.

    Take care,
    Artem

    Comment


    • #3
      Originally posted by Cleric View Post
      Hi!

      In addition you have to use request-payload-type attribute on the <int-http:inbound-gateway>.
      Take a look into source code of HttpRequestHandlingEndpointSupport#extractRequestB ody and further to the MarshallingHttpMessageConverter#supports

      It should help you to understand what's going on.

      Take care,
      Artem

      Thanks that solved the issue.

      Comment

      Working...
      X