Announcement Announcement Module
Collapse
No announcement yet.
WebServiceTemplate with JMS transport and WebServiceMessageListener Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • WebServiceTemplate with JMS transport and WebServiceMessageListener

    Hello,

    I'm working on WebServiceTemplate with JMS transport and WebServiceMessageListener. Config is

    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"
    	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
    
    	<bean id="jaxb2Marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
    		<property name="contextPath" value="xx.yyy.zzzz.esb.ws:xx.qqq.schema.integration._1_0.core" />
    		<property name="mtomEnabled" value="true" />
    		<property name="marshallerProperties">
    			<map>
    				<entry key="jaxb.formatted.output">
    					<value type="boolean">true</value>
    				</entry>
    				<entry key="jaxb.fragment">
    					<value type="boolean">true</value>
    				</entry>
    			</map>
    		</property>
    	</bean>
    
    	<bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory"/>
    
    	<bean id="listenerContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
    		<property name="connectionFactory" ref="mqConnectionFactory" />
    		<property name="destinationName" value="response" />
    		<property name="messageListener">
    			<bean class="org.springframework.ws.transport.jms.WebServiceMessageListener">
    				<property name="messageFactory" ref="messageFactory"/>
    				<property name="messageReceiver" ref="messageDispatcher" />
    			</bean>
    		</property>
    		<property name="concurrentConsumers" value="1" />
    		<property name="acceptMessagesWhileStopping" value="false" />
    		<property name="recoveryInterval" value="10000" />
    		<property name="cacheLevelName" value="CACHE_CONSUMER" />
    	</bean>
    
    	<bean id="messageDispatcher" class="org.springframework.ws.soap.server.SoapMessageDispatcher">
    		<property name="endpointAdapters">
    			<list>
    				<ref bean="defaultMethodEndpointAdapter" />
    			</list>
    		</property>
    	</bean>
    
    	<bean id="defaultMethodEndpointAdapter"
    		class="org.springframework.ws.server.endpoint.adapter.DefaultMethodEndpointAdapter">
    		<property name="methodArgumentResolvers">
    			<list>
    				<ref bean="marshallingPayloadMethodProcessor" />
    			</list>
    		</property>		
    		<property name="methodReturnValueHandlers">
    			<list>
    				<ref bean="marshallingPayloadMethodProcessor" />
    			</list>
    		</property>
    	</bean>  
    
    	<bean id="marshallingPayloadMethodProcessor"
    		class="org.springframework.ws.server.endpoint.adapter.method.MarshallingPayloadMethodProcessor">
    		<constructor-arg ref="jaxb2Marshaller" />
    		<constructor-arg ref="jaxb2Marshaller" />
    	</bean>
    
    	<bean id="webServiceTemplate" class="org.springframework.ws.client.core.WebServiceTemplate">
    		<constructor-arg ref="messageFactory"/> 
    		<property name="messageSender">
    			<bean class="org.springframework.ws.transport.jms.JmsMessageSender">
    				<property name="connectionFactory" ref="mqConnectionFactory"/>
    			</bean>
    		</property>
    		<property name="defaultUri" value="jms:request?replyToName=response" />
    		<property name="marshaller" ref="jaxb2Marshaller" />
    		<property name="unmarshaller" ref="jaxb2Marshaller" />
    	</bean>
    
    	<bean id="mqConnectionFactory" class="org.apache.activemq.spring.ActiveMQConnectionFactory">
    		<property name="brokerURL" value="${esb.client.jms.uri}" />
    	</bean>
    </beans>
    Client is

    Code:
    @Service
    public class WebServiceClient implements EsbClient, WebServiceMessageCallback {
    
    	@Inject
    	private WebServiceTemplate webServiceTemplate;
    
    	@Value("${esb.client.requestor}")
    	private String requestor;
    
    	public <T> T sendSync(JAXBElement<?> jaxbElement, Class<T> returnClass) {
    		Object wsResult = webServiceTemplate.marshalSendAndReceive(jaxbElement, this);
    		JAXBElement<T> jaxbResponse = (JAXBElement<T>) wsResult;
    		return jaxbResponse.getValue();
    	}
    
    	public void doWithMessage(WebServiceMessage message) throws IOException, TransformerException {
    		SoapMessage soapMessage = (SoapMessage) message;
    		SoapHeader header = soapMessage.getSoapHeader();
    
    		header.addHeaderElement(new QName("http://www.yyyy.xx/schema/integration/1.0/core", "Version")).setText("1.0");
    		header.addHeaderElement(new QName("http://www.yyyy.xx/schema/integration/1.0/core", "Requestor")).setText(requestor);
    	}
    
    }
    Consumer is Mule ESB.

    I'm able to send message, its correctly processed and sent back to response queue.

    WebServiceMessageListener reads message from response queue but doesnt send back from WebServiceTemplate marshalSendAndReceive method.

    Only warning message appears

    Code:
    2012-10-30 14:18:07,348[listenerContainer-1] WARN  org.springframework.ws.server.MessageDispatcher.dispatch(MessageDispatcher.java:240) - No endpoint mapping found for [SaajSoapMessage {http://ws.esb.zzzz.yyy.xx/}addTaxNumberResponse]
    Any help would be appreciated
    Last edited by dusan37; Oct 30th, 2012, 09:30 AM.
Working...
X