diff --git a/samples/airline/client/saaj/pom.xml b/samples/airline/client/saaj/pom.xml
index edcaeac8..df0c4e98 100644
--- a/samples/airline/client/saaj/pom.xml
+++ b/samples/airline/client/saaj/pom.xml
@@ -58,7 +58,7 @@
- org.springframework.ws.samples.airline.client.saaj.GetFlights
+ org.springframework.ws.samples.airline.client.saaj.Driver
diff --git a/samples/airline/client/saaj/src/main/java/org/springframework/ws/samples/airline/client/saaj/Driver.java b/samples/airline/client/saaj/src/main/java/org/springframework/ws/samples/airline/client/saaj/Driver.java
new file mode 100644
index 00000000..046d0023
--- /dev/null
+++ b/samples/airline/client/saaj/src/main/java/org/springframework/ws/samples/airline/client/saaj/Driver.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2005-2011 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.saaj;
+
+/**
+ * @author Arjen Poutsma
+ */
+public class Driver {
+
+ public static void main(String[] args) throws Exception {
+ String url = "http://localhost:8080/airline-server/services";
+ if (args.length > 0) {
+ url = args[0];
+ }
+ GetFlights getFlights = new GetFlights(url);
+ getFlights.getFlights();
+
+ if (!System.getProperty("java.version").startsWith("1.5")) {
+ return;
+ }
+ String username = "john";
+ String password = "changeme";
+ GetFrequentFlyerMileage getMileage = new GetFrequentFlyerMileage(url);
+ getMileage.getMileage(username, password);
+ }
+
+}
diff --git a/samples/airline/client/saaj/src/main/java/org/springframework/ws/samples/airline/client/saaj/GetFlights.java b/samples/airline/client/saaj/src/main/java/org/springframework/ws/samples/airline/client/saaj/GetFlights.java
index 96dae1bf..b6bf6f35 100644
--- a/samples/airline/client/saaj/src/main/java/org/springframework/ws/samples/airline/client/saaj/GetFlights.java
+++ b/samples/airline/client/saaj/src/main/java/org/springframework/ws/samples/airline/client/saaj/GetFlights.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2006 the original author or authors.
+ * Copyright 2005-2011 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
+ * 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,
@@ -20,7 +20,6 @@ import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Iterator;
-
import javax.xml.soap.MessageFactory;
import javax.xml.soap.Name;
import javax.xml.soap.SOAPBodyElement;
@@ -115,13 +114,4 @@ public class GetFlights {
transformer.transform(source, new StreamResult(System.out));
}
}
-
- public static void main(String[] args) throws Exception {
- String url = "http://localhost:8080/airline-server/services";
- if (args.length > 0) {
- url = args[0];
- }
- GetFlights getFlights = new GetFlights(url);
- getFlights.getFlights();
- }
}
diff --git a/samples/airline/client/saaj/src/main/java/org/springframework/ws/samples/airline/client/saaj/GetFrequentFlyerMileage.java b/samples/airline/client/saaj/src/main/java/org/springframework/ws/samples/airline/client/saaj/GetFrequentFlyerMileage.java
index 40cfded8..8c27d41b 100644
--- a/samples/airline/client/saaj/src/main/java/org/springframework/ws/samples/airline/client/saaj/GetFrequentFlyerMileage.java
+++ b/samples/airline/client/saaj/src/main/java/org/springframework/ws/samples/airline/client/saaj/GetFrequentFlyerMileage.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2006 the original author or authors.
+ * Copyright 2005-2011 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
+ * 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,
@@ -20,7 +20,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
-
import javax.security.auth.callback.Callback;
import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.callback.UnsupportedCallbackException;
@@ -126,16 +125,4 @@ public class GetFrequentFlyerMileage {
System.err.println("SOAP Fault String: " + fault.getFaultString());
}
}
-
- public static void main(String[] args) throws Exception {
- if (!System.getProperty("java.version").startsWith("1.5")) {
- System.out.println("This sample will only run under JDK 1.5");
- return;
- }
- String url = "http://localhost:8080/airline-server/services";
- String username = "john";
- String password = "changeme";
- GetFrequentFlyerMileage getMileage = new GetFrequentFlyerMileage(url);
- getMileage.getMileage(username, password);
- }
}
diff --git a/samples/airline/client/spring-ws/pom.xml b/samples/airline/client/spring-ws/pom.xml
index 5b647a41..9a7928ae 100644
--- a/samples/airline/client/spring-ws/pom.xml
+++ b/samples/airline/client/spring-ws/pom.xml
@@ -52,7 +52,7 @@
- org.springframework.ws.samples.airline.client.sws.GetFlights
+ org.springframework.ws.samples.airline.client.sws.Driver
diff --git a/samples/airline/client/spring-ws/src/main/java/org/springframework/ws/samples/airline/client/sws/Driver.java b/samples/airline/client/spring-ws/src/main/java/org/springframework/ws/samples/airline/client/sws/Driver.java
new file mode 100644
index 00000000..dc2d3504
--- /dev/null
+++ b/samples/airline/client/spring-ws/src/main/java/org/springframework/ws/samples/airline/client/sws/Driver.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2005-2011 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.sws;
+
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ * @author Arjen Poutsma
+ */
+public class Driver {
+
+ public static void main(String[] args) {
+ ApplicationContext applicationContext = new ClassPathXmlApplicationContext(
+ "org/springframework/ws/samples/airline/client/sws/applicationContext.xml");
+ GetFlights getFlights = applicationContext.getBean("getFlights", GetFlights.class);
+ getFlights.getFlights();
+
+ GetFrequentFlyerMileage getFrequentFlyerMileage = applicationContext
+ .getBean("getFrequentFlyerMileage", GetFrequentFlyerMileage.class);
+ getFrequentFlyerMileage.getFrequentFlyerMileage();
+
+ }
+
+}
diff --git a/samples/airline/client/spring-ws/src/main/java/org/springframework/ws/samples/airline/client/sws/GetFlights.java b/samples/airline/client/spring-ws/src/main/java/org/springframework/ws/samples/airline/client/sws/GetFlights.java
index 72afccae..a2d3ef50 100644
--- a/samples/airline/client/spring-ws/src/main/java/org/springframework/ws/samples/airline/client/sws/GetFlights.java
+++ b/samples/airline/client/spring-ws/src/main/java/org/springframework/ws/samples/airline/client/sws/GetFlights.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2005-2010 the original author or authors.
+ * Copyright 2005-2011 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
+ * 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,
@@ -19,8 +19,6 @@ package org.springframework.ws.samples.airline.client.sws;
import java.text.SimpleDateFormat;
import java.util.Calendar;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.springWs.samples.airline.schemas.messages.BookFlightRequestDocument;
import org.springframework.springWs.samples.airline.schemas.messages.BookFlightResponseDocument;
import org.springframework.springWs.samples.airline.schemas.messages.GetFlightsRequestDocument;
@@ -101,11 +99,4 @@ public class GetFlights extends WebServiceGatewaySupport {
System.out.println("\t" + flight.getTo().getCity());
}
- public static void main(String[] args) {
- ApplicationContext applicationContext = new ClassPathXmlApplicationContext(
- "org/springframework/ws/samples/airline/client/sws/applicationContext.xml");
- GetFlights getFlights = applicationContext.getBean("getFlights", GetFlights.class);
- getFlights.getFlights();
- }
-
}
diff --git a/samples/airline/client/spring-ws/src/main/java/org/springframework/ws/samples/airline/client/sws/GetFrequentFlyerMileage.java b/samples/airline/client/spring-ws/src/main/java/org/springframework/ws/samples/airline/client/sws/GetFrequentFlyerMileage.java
index 8caf7893..99021bc9 100644
--- a/samples/airline/client/spring-ws/src/main/java/org/springframework/ws/samples/airline/client/sws/GetFrequentFlyerMileage.java
+++ b/samples/airline/client/spring-ws/src/main/java/org/springframework/ws/samples/airline/client/sws/GetFrequentFlyerMileage.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2008 the original author or authors.
+ * Copyright 2005-2011 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
+ * 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,
@@ -16,15 +16,11 @@
package org.springframework.ws.samples.airline.client.sws;
-import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamResult;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.ws.WebServiceMessageFactory;
import org.springframework.ws.client.core.support.WebServiceGatewaySupport;
-import org.springframework.xml.transform.StringResult;
import org.springframework.xml.transform.StringSource;
public class GetFrequentFlyerMileage extends WebServiceGatewaySupport {
@@ -41,14 +37,4 @@ public class GetFrequentFlyerMileage extends WebServiceGatewaySupport {
}
- public static void main(String[] args) {
- ApplicationContext applicationContext = new ClassPathXmlApplicationContext(
- "org/springframework/ws/samples/airline/client/sws/applicationContext.xml");
-
- GetFrequentFlyerMileage getFrequentFlyerMileage = applicationContext
- .getBean("getFrequentFlyerMileage", GetFrequentFlyerMileage.class);
- getFrequentFlyerMileage.getFrequentFlyerMileage();
- }
-
-
}
diff --git a/samples/airline/server/src/main/java/org/springframework/ws/samples/airline/ws/AirlineEndpoint.java b/samples/airline/server/src/main/java/org/springframework/ws/samples/airline/ws/AirlineEndpoint.java
index 22e7d5cf..e0c9f8d3 100644
--- a/samples/airline/server/src/main/java/org/springframework/ws/samples/airline/ws/AirlineEndpoint.java
+++ b/samples/airline/server/src/main/java/org/springframework/ws/samples/airline/ws/AirlineEndpoint.java
@@ -22,6 +22,8 @@ import java.util.List;
import javax.xml.bind.JAXBElement;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.XMLGregorianCalendar;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
@@ -49,6 +51,8 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.joda.time.DateTime;
import org.joda.time.LocalDate;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
import static org.springframework.ws.samples.airline.ws.AirlineWebServiceConstants.*;
@@ -65,6 +69,8 @@ public class AirlineEndpoint {
private final ObjectFactory objectFactory = new ObjectFactory();
+ private final DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
+
private final AirlineService airlineService;
@Autowired
@@ -156,5 +162,18 @@ public class AirlineEndpoint {
return SchemaConversionUtils.toSchemaType(domainTicket);
}
+ @PayloadRoot(localPart = GET_FREQUENT_FLYER_MILEAGE_REQUEST, namespace = MESSAGES_NAMESPACE)
+ @ResponsePayload
+ public Element getFrequentFlyerMileage() throws Exception {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Received GetFrequentFlyerMileageRequest");
+ }
+ int mileage = airlineService.getFrequentFlyerMileage();
+ DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
+ Document document = documentBuilder.newDocument();
+ Element response = document.createElementNS(MESSAGES_NAMESPACE, GET_FREQUENT_FLYER_MILEAGE_RESPONSE);
+ response.setTextContent(Integer.toString(mileage));
+ return response;
+ }
}
diff --git a/samples/airline/server/src/main/java/org/springframework/ws/samples/airline/ws/GetFrequentFlyerMileageEndpoint.java b/samples/airline/server/src/main/java/org/springframework/ws/samples/airline/ws/GetFrequentFlyerMileageEndpoint.java
deleted file mode 100644
index c8c96abc..00000000
--- a/samples/airline/server/src/main/java/org/springframework/ws/samples/airline/ws/GetFrequentFlyerMileageEndpoint.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2005-2011 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.ws;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.ws.samples.airline.service.AirlineService;
-import org.springframework.ws.server.endpoint.AbstractDomPayloadEndpoint;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-/**
- * Endpoint that returns the amount of frequent flyer miles for the currently logged in user. Secured via a WS-Security
- * UsernameToken
- *
- * @author Arjen Poutsma
- */
-public class GetFrequentFlyerMileageEndpoint extends AbstractDomPayloadEndpoint implements AirlineWebServiceConstants {
-
- private final AirlineService airlineService;
-
- @Autowired
- public GetFrequentFlyerMileageEndpoint(AirlineService airlineService) {
- this.airlineService = airlineService;
- }
-
- protected Element invokeInternal(Element ignored, Document responseDocument) throws Exception {
- int mileage = airlineService.getFrequentFlyerMileage();
- Element response = responseDocument.createElementNS(MESSAGES_NAMESPACE, GET_FREQUENT_FLYER_MILEAGE_RESPONSE);
- response.setTextContent(Integer.toString(mileage));
- return response;
- }
-}
\ No newline at end of file
diff --git a/samples/airline/server/src/main/java/org/springframework/ws/samples/airline/ws/MarshallingAirlineEndpoint.java b/samples/airline/server/src/main/java/org/springframework/ws/samples/airline/ws/MarshallingAirlineEndpoint.java
deleted file mode 100644
index 74aa95df..00000000
--- a/samples/airline/server/src/main/java/org/springframework/ws/samples/airline/ws/MarshallingAirlineEndpoint.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Copyright 2005-2011 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.ws;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import javax.xml.bind.JAXBElement;
-import javax.xml.datatype.DatatypeConfigurationException;
-import javax.xml.datatype.XMLGregorianCalendar;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.util.Assert;
-import org.springframework.ws.samples.airline.domain.FrequentFlyer;
-import org.springframework.ws.samples.airline.domain.Passenger;
-import org.springframework.ws.samples.airline.schema.BookFlightRequest;
-import org.springframework.ws.samples.airline.schema.Flight;
-import org.springframework.ws.samples.airline.schema.GetFlightsRequest;
-import org.springframework.ws.samples.airline.schema.GetFlightsResponse;
-import org.springframework.ws.samples.airline.schema.Name;
-import org.springframework.ws.samples.airline.schema.ObjectFactory;
-import org.springframework.ws.samples.airline.schema.ServiceClass;
-import org.springframework.ws.samples.airline.schema.Ticket;
-import org.springframework.ws.samples.airline.schema.support.SchemaConversionUtils;
-import org.springframework.ws.samples.airline.service.AirlineService;
-import org.springframework.ws.samples.airline.service.NoSeatAvailableException;
-import org.springframework.ws.samples.airline.service.NoSuchFlightException;
-import org.springframework.ws.samples.airline.service.NoSuchFrequentFlyerException;
-import org.springframework.ws.server.endpoint.annotation.Endpoint;
-import org.springframework.ws.server.endpoint.annotation.PayloadRoot;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.joda.time.DateTime;
-import org.joda.time.LocalDate;
-
-/**
- * Endpoint that handles the Airline Web Service messages using JAXB2 marshalling.
- *
- * This endpoint contains exactly the same logic as the {@link XPathAirlineEndpoint}, and is only provided as an
- * example. Typically, you will not have two endpoints with the same logic.
- *
- * @author Arjen Poutsma
- */
-@Endpoint
-public class MarshallingAirlineEndpoint implements AirlineWebServiceConstants {
-
- private static final Log logger = LogFactory.getLog(MarshallingAirlineEndpoint.class);
-
- private final AirlineService airlineService;
-
- private ObjectFactory objectFactory = new ObjectFactory();
-
- @Autowired
- public MarshallingAirlineEndpoint(AirlineService airlineService) {
- Assert.notNull(airlineService, "airlineService must not be null");
- this.airlineService = airlineService;
- }
-
- /**
- * This endpoint method uses marshalling to handle message with a <GetFlightsRequest> payload.
- *
- * @param request the JAXB2 representation of a <GetFlightsRequest>
- */
- @PayloadRoot(localPart = GET_FLIGHTS_REQUEST, namespace = MESSAGES_NAMESPACE)
- public GetFlightsResponse getFlights(GetFlightsRequest request) throws DatatypeConfigurationException {
- if (logger.isDebugEnabled()) {
- logger.debug("Received GetFlightsRequest '" + request.getFrom() + "' to '" + request.getTo() + "' on " +
- request.getDepartureDate());
- }
- List flights = getSchemaFlights(request.getFrom(), request.getTo(), request.getDepartureDate(),
- request.getServiceClass());
- GetFlightsResponse response = new GetFlightsResponse();
- for (Flight flight : flights) {
- response.getFlight().add(flight);
- }
- return response;
- }
-
- /** Converts between the domain and schema types. */
- private List getSchemaFlights(String from,
- String to,
- XMLGregorianCalendar xmlDepartureDate,
- ServiceClass xmlServiceClass) throws DatatypeConfigurationException {
- LocalDate domainDepartureDate = SchemaConversionUtils.toLocalDate(xmlDepartureDate);
- org.springframework.ws.samples.airline.domain.ServiceClass domainServiceClass =
- SchemaConversionUtils.toDomainType(xmlServiceClass);
- List domainFlights =
- airlineService.getFlights(from, to, domainDepartureDate, domainServiceClass);
- return SchemaConversionUtils.toSchemaType(domainFlights);
- }
-
- /**
- * This endpoint method uses marshalling to handle message with a <BookFlightRequest> payload.
- *
- * @param request the JAXB2 representation of a <BookFlightRequest>
- * @return the JAXB2 representation of a <BookFlightResponse>
- */
- @PayloadRoot(localPart = BOOK_FLIGHT_REQUEST, namespace = MESSAGES_NAMESPACE)
- public JAXBElement bookFlight(BookFlightRequest request) throws NoSeatAvailableException,
- DatatypeConfigurationException, NoSuchFlightException, NoSuchFrequentFlyerException {
- if (logger.isDebugEnabled()) {
- logger.debug("Received BookingFlightRequest '" + request.getFlightNumber() + "' on '" +
- request.getDepartureTime() + "' for " + request.getPassengers().getPassengerOrUsername());
- }
- Ticket ticket = bookSchemaFlight(request.getFlightNumber(), request.getDepartureTime(),
- request.getPassengers().getPassengerOrUsername());
- return objectFactory.createBookFlightResponse(ticket);
- }
-
- /** Converts between the domain and schema types. */
- private Ticket bookSchemaFlight(String flightNumber,
- XMLGregorianCalendar xmlDepartureTime,
- List