Moved airline JMS functionality from to sandbox, not ready yet.
This commit is contained in:
@@ -1,55 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<project name="spring-ws-airline-sample-saaj-client" default="build"
|
||||
xmlns:artifact="urn:maven-artifact-ant">
|
||||
<property name="bin.dir" value="bin"/>
|
||||
<property name="src.dir" value="src"/>
|
||||
|
||||
<target name="init">
|
||||
<typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="urn:maven-artifact-ant">
|
||||
<classpath>
|
||||
<pathelement location="${basedir}/../maven-artifact-ant-2.0.4-dep.jar"/>
|
||||
</classpath>
|
||||
</typedef>
|
||||
|
||||
<artifact:remoteRepository id="java.net" url="https://maven-repository.dev.java.net/nonav/repository"
|
||||
layout="legacy"/>
|
||||
|
||||
<artifact:dependencies pathId="compile.classpath">
|
||||
<remoteRepository refid="java.net"/>
|
||||
<dependency groupId="javax.xml.soap" artifactId="saaj-api" version="1.3"/>
|
||||
<dependency groupId="javax.jms" artifactId="jms" version="1.1"/>
|
||||
<dependency groupId="activemq" artifactId="activemq" version="2.1"/>
|
||||
<dependency groupId="geronimo-spec" artifactId="geronimo-spec-j2ee-management" version="1.0-rc4"/>
|
||||
<dependency groupId="concurrent" artifactId="concurrent" version="1.3.4"/>
|
||||
<dependency groupId="commons-logging" artifactId="commons-logging" version="1.1"/>
|
||||
</artifact:dependencies>
|
||||
|
||||
<artifact:dependencies pathId="runtime.classpath">
|
||||
<remoteRepository refid="java.net"/>
|
||||
<dependency groupId="com.sun.xml.messaging.saaj" artifactId="saaj-impl" version="1.3"/>
|
||||
</artifact:dependencies>
|
||||
|
||||
</target>
|
||||
|
||||
|
||||
<target name="build" depends="init">
|
||||
<mkdir dir="${bin.dir}"/>
|
||||
<javac srcdir="${src.dir}" destdir="${bin.dir}" debug="true">
|
||||
<classpath refid="compile.classpath"/>
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<target name="clean">
|
||||
<delete dir="${bin.dir}"/>
|
||||
</target>
|
||||
|
||||
<target name="run" depends="build">
|
||||
<java classname="org.springframework.ws.samples.airline.client.jms.GetFlights" fork="true" failonerror="true">
|
||||
<classpath refid="compile.classpath"/>
|
||||
<classpath refid="runtime.classpath"/>
|
||||
<classpath location="${bin.dir}"/>
|
||||
</java>
|
||||
</target>
|
||||
|
||||
</project>
|
||||
@@ -1,13 +0,0 @@
|
||||
SPRING WEB SERVICES
|
||||
|
||||
This directory contains a client for the Airline Web Service that uses JMS: Java Message Service. The client can be run
|
||||
from the provided ant file, by calling "ant run".
|
||||
|
||||
NOTE that the client uses ActiveMQ 2.1, and needs to be changed for other versions of ActiveMQ, or other JMS providers.
|
||||
Also note that ActiveMQ needs to be running before this sample is started.
|
||||
|
||||
SAJA Client Sample table of contents
|
||||
---------------------------------------------------
|
||||
* src - The source files for the client
|
||||
* build.xml - Ant build file with a 'build' and a 'run' target
|
||||
|
||||
@@ -1,195 +0,0 @@
|
||||
/*
|
||||
* Copyright 2006 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ws.samples.airline.client.jms;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
import javax.jms.BytesMessage;
|
||||
import javax.jms.JMSException;
|
||||
import javax.jms.Message;
|
||||
import javax.jms.MessageListener;
|
||||
import javax.jms.Session;
|
||||
import javax.jms.Topic;
|
||||
import javax.jms.TopicConnection;
|
||||
import javax.jms.TopicConnectionFactory;
|
||||
import javax.jms.TopicPublisher;
|
||||
import javax.jms.TopicSession;
|
||||
import javax.jms.TopicSubscriber;
|
||||
import javax.xml.soap.MessageFactory;
|
||||
import javax.xml.soap.MimeHeaders;
|
||||
import javax.xml.soap.Name;
|
||||
import javax.xml.soap.SOAPBodyElement;
|
||||
import javax.xml.soap.SOAPElement;
|
||||
import javax.xml.soap.SOAPEnvelope;
|
||||
import javax.xml.soap.SOAPException;
|
||||
import javax.xml.soap.SOAPMessage;
|
||||
import javax.xml.transform.OutputKeys;
|
||||
import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.TransformerException;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
|
||||
import org.codehaus.activemq.ActiveMQConnection;
|
||||
import org.codehaus.activemq.ActiveMQConnectionFactory;
|
||||
|
||||
/**
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
public class GetFlights implements MessageListener {
|
||||
|
||||
public static final String NAMESPACE_URI = "http://www.springframework.org/spring-ws/samples/airline/schemas";
|
||||
|
||||
public static final String PREFIX = "airline";
|
||||
|
||||
private static final String CORRELATION_ID = "correlationId";
|
||||
|
||||
private static final String REQUEST_TOPIC = "org.springframework.ws.samples.airline.RequestTopic";
|
||||
|
||||
private static final String RESPONSE_TOPIC = "org.springframework.ws.samples.airline.ResponseTopic";
|
||||
|
||||
private TopicConnection connection;
|
||||
|
||||
private MessageFactory messageFactory;
|
||||
|
||||
private Topic responseTopic;
|
||||
|
||||
private TopicSession session;
|
||||
|
||||
private TransformerFactory transfomerFactory;
|
||||
|
||||
public GetFlights(TopicConnectionFactory connectionFactory) throws SOAPException, JMSException {
|
||||
messageFactory = MessageFactory.newInstance();
|
||||
transfomerFactory = TransformerFactory.newInstance();
|
||||
connection = connectionFactory.createTopicConnection();
|
||||
session = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
|
||||
responseTopic = session.createTopic(RESPONSE_TOPIC);
|
||||
TopicSubscriber subscriber = session.createSubscriber(responseTopic);
|
||||
subscriber.setMessageListener(this);
|
||||
connection.start();
|
||||
}
|
||||
|
||||
public void onMessage(Message message) {
|
||||
try {
|
||||
System.out.println("Received message");
|
||||
BytesMessage bytesMessage = (BytesMessage) message;
|
||||
byte[] buf = new byte[(int) bytesMessage.getBodyLength()];
|
||||
bytesMessage.readBytes(buf);
|
||||
ByteArrayInputStream is = new ByteArrayInputStream(buf);
|
||||
SOAPMessage saajMessage = messageFactory.createMessage(new MimeHeaders(), is);
|
||||
writeGetFlightsResponse(saajMessage);
|
||||
System.exit(0);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace(System.err);
|
||||
}
|
||||
}
|
||||
|
||||
public void close() {
|
||||
if (session != null) {
|
||||
try {
|
||||
session.close();
|
||||
}
|
||||
catch (JMSException ex) {
|
||||
ex.printStackTrace(System.err);
|
||||
}
|
||||
}
|
||||
if (connection != null) {
|
||||
try {
|
||||
connection.close();
|
||||
}
|
||||
catch (JMSException ex) {
|
||||
ex.printStackTrace(System.err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private SOAPMessage createGetFlightsRequest() throws SOAPException {
|
||||
SOAPMessage message = messageFactory.createMessage();
|
||||
SOAPEnvelope envelope = message.getSOAPPart().getEnvelope();
|
||||
Name getFlightsRequestName = envelope.createName("GetFlightsRequest", PREFIX, NAMESPACE_URI);
|
||||
SOAPBodyElement getFlightsRequestElement = message.getSOAPBody().addBodyElement(getFlightsRequestName);
|
||||
Name fromName = envelope.createName("from", PREFIX, NAMESPACE_URI);
|
||||
SOAPElement fromElement = getFlightsRequestElement.addChildElement(fromName);
|
||||
fromElement.setValue("AMS");
|
||||
Name toName = envelope.createName("to", PREFIX, NAMESPACE_URI);
|
||||
SOAPElement toElement = getFlightsRequestElement.addChildElement(toName);
|
||||
toElement.setValue("VCE");
|
||||
Name departureDateName = envelope.createName("departureDate", PREFIX, NAMESPACE_URI);
|
||||
SOAPElement departureDateElement = getFlightsRequestElement.addChildElement(departureDateName);
|
||||
departureDateElement.setValue("2006-01-31");
|
||||
return message;
|
||||
}
|
||||
|
||||
public void getFlights() throws SOAPException, IOException, TransformerException, JMSException {
|
||||
SOAPMessage request = createGetFlightsRequest();
|
||||
Topic requestTopic = session.createTopic(REQUEST_TOPIC);
|
||||
TopicPublisher publisher = session.createPublisher(requestTopic);
|
||||
BytesMessage message = session.createBytesMessage();
|
||||
message.setJMSCorrelationID(CORRELATION_ID);
|
||||
message.setJMSReplyTo(responseTopic);
|
||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||
request.writeTo(os);
|
||||
os.flush();
|
||||
message.writeBytes(os.toByteArray());
|
||||
publisher.publish(message);
|
||||
System.out.println("Written GetFlights request to " + requestTopic);
|
||||
}
|
||||
|
||||
private void writeGetFlightsResponse(SOAPMessage message) throws SOAPException, TransformerException {
|
||||
SOAPEnvelope envelope = message.getSOAPPart().getEnvelope();
|
||||
Name getFlightsResponseName = envelope.createName("GetFlightsResponse", PREFIX, NAMESPACE_URI);
|
||||
SOAPBodyElement getFlightsResponseElement =
|
||||
(SOAPBodyElement) message.getSOAPBody().getChildElements(getFlightsResponseName).next();
|
||||
Name flightName = envelope.createName("flight", PREFIX, NAMESPACE_URI);
|
||||
Iterator iterator = getFlightsResponseElement.getChildElements(flightName);
|
||||
Transformer transformer = transfomerFactory.newTransformer();
|
||||
transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
|
||||
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
|
||||
int count = 1;
|
||||
while (iterator.hasNext()) {
|
||||
System.out.println("Flight " + count);
|
||||
System.out.println("--------");
|
||||
SOAPElement flightElement = (SOAPElement) iterator.next();
|
||||
DOMSource source = new DOMSource(flightElement);
|
||||
transformer.transform(source, new StreamResult(System.out));
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
String url = ActiveMQConnection.DEFAULT_URL;
|
||||
if (args.length > 0) {
|
||||
url = args[0];
|
||||
}
|
||||
TopicConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url);
|
||||
GetFlights getFlights = null;
|
||||
try {
|
||||
getFlights = new GetFlights(connectionFactory);
|
||||
getFlights.getFlights();
|
||||
while (true) {
|
||||
// keep running until we receive a response message in onMessage
|
||||
}
|
||||
}
|
||||
finally {
|
||||
if (getFlights != null) {
|
||||
getFlights.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -47,11 +47,6 @@
|
||||
<groupId>org.springframework.ws</groupId>
|
||||
<artifactId>spring-ws-security</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.ws</groupId>
|
||||
<artifactId>spring-ws-sandbox</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<!-- Spring dependencies -->
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
@@ -164,32 +159,11 @@
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>5.0.4</version>
|
||||
</dependency>
|
||||
<!-- JMS depdendencies -->
|
||||
<dependency>
|
||||
<groupId>javax.jms</groupId>
|
||||
<artifactId>jms</artifactId>
|
||||
<version>1.1</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>geronimo-spec</groupId>
|
||||
<artifactId>geronimo-spec-j2ee-management</artifactId>
|
||||
<version>1.0-rc4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>activemq</groupId>
|
||||
<artifactId>activemq</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>concurrent</groupId>
|
||||
<artifactId>concurrent</artifactId>
|
||||
<version>1.3.4</version>
|
||||
</dependency>
|
||||
<!-- Various dependencies -->
|
||||
<dependency>
|
||||
<groupId>joda-time</groupId>
|
||||
<artifactId>joda-time</artifactId>
|
||||
<version>1.2.1</version>
|
||||
<version>1.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>joda-time</groupId>
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
<?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-2.0.xsd">
|
||||
<description>
|
||||
This application context contains a Spring-WS JMS transport.
|
||||
</description>
|
||||
|
||||
<bean id="connectionFactory" class="org.springframework.jms.connection.SingleConnectionFactory">
|
||||
<description>
|
||||
The JMS connection factory to use for receiving request JMS message, and sending response messages. Replace
|
||||
this bean with a JNDI Pooled connection factory, or change the wrapped "targetConnectionFactory" bean.
|
||||
</description>
|
||||
<property name="targetConnectionFactory">
|
||||
<bean class="org.codehaus.activemq.ActiveMQConnectionFactory">
|
||||
<property name="brokerURL" value="tcp://localhost:61616"/>
|
||||
</bean>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="listenerContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
|
||||
<description>
|
||||
A Spring 2.0 MessageListenerContainer which listens for incoming messages on the Request Topic. When a
|
||||
message is received, the messageListener defined below is invoked.
|
||||
</description>
|
||||
<property name="connectionFactory" ref="connectionFactory"/>
|
||||
<property name="pubSubDomain" value="true"/>
|
||||
<property name="destinationName" value="org.springframework.ws.samples.airline.RequestTopic"/>
|
||||
<property name="messageListener" ref="messageListener"/>
|
||||
</bean>
|
||||
|
||||
<bean id="messageListener" class="org.springframework.ws.transport.jms.MessageEndpointMessageListener">
|
||||
<description>
|
||||
Spring 2.0 SessionAwareMessageListener that creates a SOAP message from the invoming JMS message using
|
||||
a messageFactory, and forwards it to the message to the messageDispatcher. Both of these beans are defined
|
||||
in applicationContext-ws.xml.
|
||||
</description>
|
||||
<property name="messageFactory" ref="messageFactory"/>
|
||||
<property name="messageReceiver" ref="messageDispatcher"/>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
@@ -1,7 +1,6 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
|
||||
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
|
||||
version="2.4">
|
||||
<display-name>Spring-WS Airline Sample</display-name>
|
||||
@@ -20,8 +19,6 @@
|
||||
classpath:org/springframework/ws/samples/airline/service/applicationContext.xml
|
||||
<!-- Remove the following line if you want to disable WS-Security and Acegi -->
|
||||
classpath:org/springframework/ws/samples/airline/security/applicationContext-security.xml
|
||||
<!-- Remove the following line if you want to disable JMS support -->
|
||||
classpath:org/springframework/ws/samples/airline/ws/applicationContext-ws-jms.xml
|
||||
classpath:org/springframework/ws/samples/airline/ws/applicationContext-ws.xml
|
||||
</param-value>
|
||||
</context-param>
|
||||
|
||||
Reference in New Issue
Block a user