Announcement Announcement Module
Collapse
No announcement yet.
ws:outbound-gateway not getting called Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • ws:outbound-gateway not getting called

    Hi,

    I am trying to call my webservices using a ws:outboundgateway.
    But the gateway is not getting called.
    I am using a header-value-router to route to a proper channel.
    It works fine.
    I am using a message template to send the messages to the outbound-gateway.
    This is my code..
    Code:
    <int:header-value-router input-channel="headerChannel"  header-name="testHeader">
    		<int:mapping value="bill" channel="getChannel" />
    		<int:mapping value="post" channel="postChannel" />
    	</int:header-value-router>
    This is my Gateway class:
    Code:
    public class MessageGateway
    {
    
    	private ObjectMapper objectMapper = new ObjectMapper();
    
    	private MessageChannel messageChannel;
    
    	public MessageChannel getMessageChannel()
    	{
    		return messageChannel;
    	}
    
    	public void setMessageChannel(MessageChannel messageChannel)
    	{
    		this.messageChannel = messageChannel;
    	}
    
    	@Autowired
    	private MessagingTemplate messagingTemplate;
    
    	public Message<?> convertMessage(Message<String> message)
    	{
    
    		try
    		{
    
    			System.out.println("in MessageGateway " + message.getPayload());
    			System.out.println("in MessageGateway " + message.getHeaders().get("testHeader"));
    
    			SOAPReq sOAPReq = new SOAPReq();
    
    			HashMap reqMap = objectMapper.readValue(message.getPayload(), HashMap.class);
    
    			System.out.println("reqMap  is " + reqMap);
    			
    			sOAPReq.setDealer((String)reqMap.get("dealer"));
    			sOAPReq.setDivision((String)reqMap.get("Division"));
    			
    			System.out.println("SOAPReq  is " + sOAPReq);
    				
    			Message<RecPROXY> output = (Message<RecPROXY>) messagingTemplate.sendAndReceive(messageChannel,
    					MessageBuilder.withPayload(sOAPReq).build());
    
    			RecPROXY recPROXY = output.getPayload();
    			
    			System.out.println("OUTPUT IS " + output);
    			return null;
    
    		}
    		catch (Exception e)
    		{
    			// TODO: handle exception
    		}
    		return message;
    
    	}
    }
    and this is my configuration class:

    Code:
    	<int:channel id="getChannel" />
    
    	
    	<int:service-activator ref="messageGateway"
    		input-channel="getChannel"  />
    
    	<bean id="messageGateway" class="com.sales.messaging.MessageGateway">
    	<property name="messageChannel" ref="postDataChannel"/>
    	</bean>
    		
    
    	<int:channel id="postDataChannel"/>
    
    
    	<bean name="httpMessageSender"
    		class="org.springframework.ws.transport.http.CommonsHttpMessageSender">
    		<property name="credentials" ref="credentials" />
    	</bean>
    
    	<bean id="credentials"
    		class="org.apache.commons.httpclient.UsernamePasswordCredentials">
    		<constructor-arg value="shane" />
    		<constructor-arg value="shane" />
    	</bean>
    
    
    	<ws:outbound-gateway id="jaypeeGateway" request-channel="postDataChannel"
    		 marshaller="jaxb2Marshaller" 
    		unmarshaller="jaxb2Marshaller"
    		uri="http://localhost/myserver"
    		message-sender="httpMessageSender" />
    
    
    
    
    
    	<bean id="jaxb2Marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
    		<property name="classesToBeBound">
    			<list>
    				<value>com.sales.integration.webservice.billreceivable.SOAPReq</value>
    				<value>com.sales.integration.webservice.billreceivable.RecPROXY</value>
    			</list>
    		</property>
    
    	</bean>
    
    	<bean id="messagingTemplate" class="org.springframework.integration.core.MessagingTemplate"/>
    </beans>
    It prints this line :System.out.println("SOAPReq is " + sOAPReq);
    But does not call the ws:otbound-gateway,
    What am i doing wrong.Please help.

    Thanks in Advance.
    Regards,

    Annuk
    Last edited by annuk; Oct 18th, 2011, 01:36 AM.

  • #2
    Hi,


    The above code is calling the ws-outbound gateway but was getting an exception.
    I had not written print in catch so was not able to figure out the error.

    Thanks...
    Last edited by annuk; Jan 2nd, 2012, 12:44 AM.

    Comment


    • #3
      Well, why do you even need to use MessagingTemplate?
      All you need is route your message to the input channel of ws:outbound-gateway. You may want to also put a ws:header-enricher to add a SOAP header. Just look at these samples: https://github.com/SpringSource/spri...tbound-gateway

      Comment

      Working...
      X