Results 1 to 3 of 3

Thread: ws:outbound-gateway not getting called

  1. #1
    Join Date
    May 2011
    Location
    Mumbai, India
    Posts
    93

    Question 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 at 01:36 AM.

  2. #2
    Join Date
    May 2011
    Location
    Mumbai, India
    Posts
    93

    Default

    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 1st, 2012 at 11:44 PM.

  3. #3
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    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

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •