/** * This endpoint method uses a combination of XPath expressions and marshalling to handle message * with a <code><GetFlightsRequest></code> payload. * * @param from the from airport * @param to the to airport * @param departureDateString the string representation of the departure date * @param serviceClassString the string representation of the service class * @return the JAXB2 representation of a <code><GetFlightsResponse></code> */ @PayloadRoot(localPart = GET_FLIGHTS_REQUEST, namespace = MESSAGES_NAMESPACE) @Namespace(prefix = "m", uri = MESSAGES_NAMESPACE) @ResponsePayload public GetFlightsResponse getFlights( @XPathParam("//m:from") String from, @XPathParam("//m:to") String to, @XPathParam("//m:departureDate") String departureDateString, @XPathParam("//m:serviceClass") String serviceClassString) throws DatatypeConfigurationException { if (logger.isDebugEnabled()) { logger.debug( "Received GetFlightsRequest '" + from + "' to '" + to + "' on " + departureDateString); } LocalDate departureDate = new LocalDate(departureDateString); ServiceClass serviceClass = null; if (StringUtils.hasLength(serviceClassString)) { serviceClass = ServiceClass.valueOf(serviceClassString.toUpperCase()); } List<org.springframework.ws.samples.airline.domain.Flight> flights = airlineService.getFlights(from, to, departureDate, serviceClass); GetFlightsResponse response = objectFactory.createGetFlightsResponse(); for (org.springframework.ws.samples.airline.domain.Flight domainFlight : flights) { response.getFlight().add(SchemaConversionUtils.toSchemaType(domainFlight)); } return response; }
/** * This endpoint method uses marshalling to handle message with a <code><BookFlightRequest> * </code> payload. * * @param request the JAXB2 representation of a <code><BookFlightRequest></code> * @return the JAXB2 representation of a <code><BookFlightResponse></code> */ @PayloadRoot(localPart = BOOK_FLIGHT_REQUEST, namespace = MESSAGES_NAMESPACE) @ResponsePayload public JAXBElement<Ticket> bookFlight(@RequestPayload 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); }