コード例 #1
0
  /**
   * This endpoint method uses a combination of XPath expressions and marshalling to handle message
   * with a <code>&lt;GetFlightsRequest&gt;</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>&lt;GetFlightsResponse&gt;</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;
  }
コード例 #2
0
 /**
  * This endpoint method uses marshalling to handle message with a <code>&lt;BookFlightRequest&gt;
  * </code> payload.
  *
  * @param request the JAXB2 representation of a <code>&lt;BookFlightRequest&gt;</code>
  * @return the JAXB2 representation of a <code>&lt;BookFlightResponse&gt;</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);
 }