org.springframework.ws.server.endpoint.annotation.ResponsePayload Java Examples

The following examples show how to use org.springframework.ws.server.endpoint.annotation.ResponsePayload. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HelloWorldEndpoint.java    From spring-ws with MIT License 6 votes vote down vote up
@PayloadRoot(
    namespace = "http://codenotfound.com/types/helloworld",
    localPart = "person")
@ResponsePayload
public Greeting sayHello(@RequestPayload Person request) {
  LOGGER.info("Endpoint received person[firstName={},lastName={}]",
      request.getFirstName(), request.getLastName());

  String greeting = "Hello " + request.getFirstName() + " "
      + request.getLastName() + "!";

  ObjectFactory factory = new ObjectFactory();
  Greeting response = factory.createGreeting();
  response.setGreeting(greeting);

  LOGGER.info("Endpoint sending greeting='{}'",
      response.getGreeting());
  return response;
}
 
Example #2
Source File: OrderHistoryEndpoint.java    From spring-ws with MIT License 6 votes vote down vote up
@PayloadRoot(namespace = "http://codenotfound.com/types/orderhistory",
    localPart = "getOrderHistoryRequest")
@Namespace(prefix = "oh", uri = "http://codenotfound.com/types/orderhistory")
@ResponsePayload
public GetOrderHistoryResponse getOrderHistory(@XPathParam(userIdXPath) String userId) {
  LOGGER.info("received request for order history of userId='{}'", userId);

  // fetch the order history for the received user
  ObjectFactory factory = new ObjectFactory();
  OrderListType orderListType = factory.createOrderListType();

  for (int i = 0; i < 3; i++) {
    OrderType orderType = factory.createOrderType();
    orderType.setOrderId("order" + i);
    orderListType.getOrder().add(orderType);
  }

  OrderHistoryType orderHistoryType = factory.createOrderHistoryType();
  orderHistoryType.setOrderList(orderListType);

  GetOrderHistoryResponse result = factory.createGetOrderHistoryResponse();
  result.setOrderHistory(orderHistoryType);

  return result;
}
 
Example #3
Source File: TicketAgentEndpoint.java    From spring-ws with MIT License 6 votes vote down vote up
@PayloadRoot(namespace = "http://example.org/TicketAgent.xsd",
    localPart = "listFlightsRequest")
@ResponsePayload
public JAXBElement<TFlightsResponse> listFlights(
    @RequestPayload JAXBElement<TListFlights> request)
    throws InterruptedException {

  // sleep for 10 seconds so a timeout occurs
  Thread.sleep(10 * (long) 1000);

  ObjectFactory factory = new ObjectFactory();
  TFlightsResponse tFlightsResponse =
      factory.createTFlightsResponse();
  tFlightsResponse.getFlightNumber().add(BigInteger.valueOf(101));

  return factory.createListFlightsResponse(tFlightsResponse);
}
 
Example #4
Source File: CreateOrderEndpoint.java    From spring-ws with MIT License 6 votes vote down vote up
@PayloadRoot(namespace = NAMESPACE_URI, localPart = "order")
@ResponsePayload
public OrderConfirmation createOrder(@RequestPayload Order request) {
    LOGGER.info(
            "Endpoint received order for Customer[firstName={},lastName={}]",
            request.getCustomer().getFirstName(),
            request.getCustomer().getLastName());

    // process order

    ObjectFactory factory = new ObjectFactory();
    OrderConfirmation response = factory.createOrderConfirmation();
    response.setConfirmationId(UUID.randomUUID().toString());

    LOGGER.info("Endpoint sending orderConfirmationId='{}'",
            response.getConfirmationId());
    return response;
}
 
Example #5
Source File: CustomerEndpoint.java    From ddd-strategic-design-spring-boot with Apache License 2.0 6 votes vote down vote up
@PayloadRoot(namespace = NAMESPACE_URI, localPart = "saveCustomerRequest")
@ResponsePayload
public SaveCustomerResponse saveCustoemr(@RequestPayload SaveCustomerRequest request) {
    SaveCustomerResponse response = new SaveCustomerResponse();
    Customer customer = request.getCustomer();
    Kunde kunde = new Kunde();
    kunde.setNachname(customer.getLastName());
    kunde.setVorname(customer.getFirstName());
    kunde.setStrasse(customer.getStreet());
    kunde.setPlz(customer.getPostCode());
    kunde.setStadt(customer.getCity());
    Kunde savedKunde = kundeRepository.saveAndFlush(kunde);
    redisTemplate.convertAndSend("customer-created-events", new CustomerCreatedEvent(savedKunde));
    customer.setId(savedKunde.getId());
    response.setCustomer(customer);

    return response;
}
 
Example #6
Source File: CreateOrderEndpoint.java    From spring-ws with MIT License 6 votes vote down vote up
@PayloadRoot(namespace = NAMESPACE_URI, localPart = "order")
@ResponsePayload
public OrderConfirmation createOrder(@RequestPayload Order request) {
    LOGGER.info(
            "Endpoint received order for Customer[firstName={},lastName={}]",
            request.getCustomer().getFirstName(),
            request.getCustomer().getLastName());

    // process order

    ObjectFactory factory = new ObjectFactory();
    OrderConfirmation response = factory.createOrderConfirmation();
    response.setConfirmationId(UUID.randomUUID().toString());

    LOGGER.info("Endpoint sending orderConfirmationId='{}'",
            response.getConfirmationId());
    return response;
}
 
Example #7
Source File: CreateOrderEndpoint.java    From spring-ws with MIT License 6 votes vote down vote up
@PayloadRoot(namespace = NAMESPACE_URI, localPart = "order")
@ResponsePayload
public OrderConfirmation createOrder(@RequestPayload Order request) {
    LOGGER.info(
            "Endpoint received order for Customer[firstName={},lastName={}]",
            request.getCustomer().getFirstName(),
            request.getCustomer().getLastName());

    // process order

    ObjectFactory factory = new ObjectFactory();
    OrderConfirmation response = factory.createOrderConfirmation();
    response.setConfirmationId(UUID.randomUUID().toString());

    LOGGER.info("Endpoint sending orderConfirmationId='{}'",
            response.getConfirmationId());
    return response;
}
 
Example #8
Source File: CreateOrderEndpoint.java    From spring-ws with MIT License 6 votes vote down vote up
@PayloadRoot(namespace = NAMESPACE_URI, localPart = "order")
@ResponsePayload
public OrderConfirmation createOrder(@RequestPayload Order request) {
    LOGGER.info(
            "Endpoint received order for Customer[firstName={},lastName={}]",
            request.getCustomer().getFirstName(),
            request.getCustomer().getLastName());

    // process order

    ObjectFactory factory = new ObjectFactory();
    OrderConfirmation response = factory.createOrderConfirmation();
    response.setConfirmationId(UUID.randomUUID().toString());

    LOGGER.info("Endpoint sending orderConfirmationId='{}'",
            response.getConfirmationId());
    return response;
}
 
Example #9
Source File: TicketAgentEndpoint.java    From spring-ws with MIT License 5 votes vote down vote up
@SuppressWarnings("unchecked")
@PayloadRoot(namespace = "http://example.org/TicketAgent.xsd", localPart = "listFlightsRequest")
@ResponsePayload
public JAXBElement<TFlightsResponse> listFlights(
    @RequestPayload JAXBElement<TListFlights> request, @SoapHeader(
        value = "{http://example.org/TicketAgent.xsd}listFlightsSoapHeaders") SoapHeaderElement soapHeaderElement) {
  String clientId = "unknown";

  try {
    // create an unmarshaller
    JAXBContext context = JAXBContext.newInstance(ObjectFactory.class);
    Unmarshaller unmarshaller = context.createUnmarshaller();

    // unmarshal the header from the specified source
    JAXBElement<ListFlightsSoapHeaders> headers =
        (JAXBElement<ListFlightsSoapHeaders>) unmarshaller
            .unmarshal(soapHeaderElement.getSource());

    // get the header values
    ListFlightsSoapHeaders requestSoapHeaders = headers.getValue();
    clientId = requestSoapHeaders.getClientId();
  } catch (Exception e) {
    LOGGER.error("error during unmarshalling of the SOAP headers", e);
  }

  ObjectFactory factory = new ObjectFactory();
  TFlightsResponse tFlightsResponse = factory.createTFlightsResponse();
  tFlightsResponse.getFlightNumber().add(BigInteger.valueOf(101));

  // add an extra flightNumber in the case of a clientId == abc123
  if ("abc123".equals(clientId)) {
    LOGGER.info("clientId == abc123");
    tFlightsResponse.getFlightNumber().add(BigInteger.valueOf(202));
  }

  return factory.createListFlightsResponse(tFlightsResponse);
}
 
Example #10
Source File: TicketAgentEndpoint.java    From spring-ws with MIT License 5 votes vote down vote up
@PayloadRoot(namespace = "http://example.org/TicketAgent.xsd",
    localPart = "listFlightsRequest")
@ResponsePayload
public JAXBElement<TFlightsResponse> listFlights(
    @RequestPayload JAXBElement<TListFlights> request) {

  ObjectFactory factory = new ObjectFactory();
  TFlightsResponse tFlightsResponse =
      factory.createTFlightsResponse();
  tFlightsResponse.getFlightNumber().add(BigInteger.valueOf(101));

  return factory.createListFlightsResponse(tFlightsResponse);
}
 
Example #11
Source File: TicketAgentEndpoint.java    From spring-ws with MIT License 5 votes vote down vote up
@PayloadRoot(namespace = "http://example.org/TicketAgent.xsd", localPart = "listFlightsRequest")
@ResponsePayload
public JAXBElement<TFlightsResponse> listFlights(
    @RequestPayload JAXBElement<TListFlights> request) {
  ObjectFactory factory = new ObjectFactory();
  TFlightsResponse tFlightsResponse = factory.createTFlightsResponse();
  tFlightsResponse.getFlightNumber().add(BigInteger.valueOf(101));

  return factory.createListFlightsResponse(tFlightsResponse);
}
 
Example #12
Source File: TicketAgentEndpoint.java    From spring-ws with MIT License 5 votes vote down vote up
@PayloadRoot(namespace = "http://example.org/TicketAgent.xsd", localPart = "listFlightsRequest")
@ResponsePayload
public JAXBElement<TFlightsResponse> listFlights(
    @RequestPayload JAXBElement<TListFlights> request) {

  ObjectFactory factory = new ObjectFactory();
  TFlightsResponse tFlightsResponse = factory.createTFlightsResponse();
  tFlightsResponse.getFlightNumber().add(BigInteger.valueOf(101));

  return factory.createListFlightsResponse(tFlightsResponse);
}
 
Example #13
Source File: TicketAgentEndpoint.java    From spring-ws with MIT License 5 votes vote down vote up
@PayloadRoot(namespace = "http://example.org/TicketAgent.xsd", localPart = "listFlightsRequest")
@ResponsePayload
public JAXBElement<TFlightsResponse> listFlights(
    @RequestPayload JAXBElement<TListFlights> request) {

  ObjectFactory factory = new ObjectFactory();
  TFlightsResponse tFlightsResponse = factory.createTFlightsResponse();
  tFlightsResponse.getFlightNumber().add(BigInteger.valueOf(101));

  return factory.createListFlightsResponse(tFlightsResponse);
}
 
Example #14
Source File: TicketAgentEndpoint.java    From spring-ws with MIT License 5 votes vote down vote up
@PayloadRoot(namespace = "http://example.org/TicketAgent.xsd", localPart = "listFlightsRequest")
@ResponsePayload
public JAXBElement<TFlightsResponse> listFlights(
    @RequestPayload JAXBElement<TListFlights> request) {

  ObjectFactory factory = new ObjectFactory();
  TFlightsResponse tFlightsResponse = factory.createTFlightsResponse();
  tFlightsResponse.getFlightNumber().add(BigInteger.valueOf(101));

  return factory.createListFlightsResponse(tFlightsResponse);
}
 
Example #15
Source File: TicketAgentEndpoint.java    From spring-ws with MIT License 5 votes vote down vote up
@PayloadRoot(namespace = "http://example.org/TicketAgent.xsd",
    localPart = "listFlightsRequest")
@ResponsePayload
public JAXBElement<TFlightsResponse> listFlights(
    @RequestPayload JAXBElement<TListFlights> request) {

  ObjectFactory factory = new ObjectFactory();
  TFlightsResponse tFlightsResponse =
      factory.createTFlightsResponse();
  tFlightsResponse.getFlightNumber().add(BigInteger.valueOf(101));

  return factory.createListFlightsResponse(tFlightsResponse);
}
 
Example #16
Source File: TicketAgentEndpoint.java    From spring-ws with MIT License 5 votes vote down vote up
@PayloadRoot(namespace = "http://example.org/TicketAgent.xsd", localPart = "listFlightsRequest")
@ResponsePayload
public JAXBElement<TFlightsResponse> listFlights(
    @RequestPayload JAXBElement<TListFlights> request) {
  ObjectFactory factory = new ObjectFactory();
  TFlightsResponse tFlightsResponse = factory.createTFlightsResponse();
  tFlightsResponse.getFlightNumber().add(BigInteger.valueOf(101));

  return factory.createListFlightsResponse(tFlightsResponse);
}
 
Example #17
Source File: TicketAgentEndpoint.java    From spring-ws with MIT License 5 votes vote down vote up
@PayloadRoot(namespace = "http://example.org/TicketAgent.xsd", localPart = "listFlightsRequest")
@ResponsePayload
public JAXBElement<TFlightsResponse> listFlights(
    @RequestPayload JAXBElement<TListFlights> request) {
  ObjectFactory factory = new ObjectFactory();
  TFlightsResponse tFlightsResponse = factory.createTFlightsResponse();
  tFlightsResponse.getFlightNumber().add(BigInteger.valueOf(101));

  return factory.createListFlightsResponse(tFlightsResponse);
}
 
Example #18
Source File: TicketAgentEndpoint.java    From spring-ws with MIT License 5 votes vote down vote up
@PayloadRoot(namespace = "http://example.org/TicketAgent.xsd", localPart = "listFlightsRequest")
@ResponsePayload
public JAXBElement<TFlightsResponse> listFlights(
    @RequestPayload JAXBElement<TListFlights> request) {
  ObjectFactory factory = new ObjectFactory();
  TFlightsResponse tFlightsResponse = factory.createTFlightsResponse();
  tFlightsResponse.getFlightNumber().add(BigInteger.valueOf(101));

  return factory.createListFlightsResponse(tFlightsResponse);
}
 
Example #19
Source File: TicketAgentEndpoint.java    From spring-ws with MIT License 5 votes vote down vote up
@PayloadRoot(namespace = "http://example.org/TicketAgent.xsd", localPart = "listFlightsRequest")
@ResponsePayload
public JAXBElement<TFlightsResponse> listFlights(
    @RequestPayload JAXBElement<TListFlights> request) {
  ObjectFactory factory = new ObjectFactory();
  TFlightsResponse tFlightsResponse = factory.createTFlightsResponse();
  tFlightsResponse.getFlightNumber().add(BigInteger.valueOf(101));

  return factory.createListFlightsResponse(tFlightsResponse);
}
 
Example #20
Source File: TicketAgentEndpoint.java    From spring-ws with MIT License 5 votes vote down vote up
@SoapAction(value = "http://example.com/TicketAgent/listFlights")
@ResponsePayload
public JAXBElement<TFlightsResponse> listFlights(
    @RequestPayload JAXBElement<TListFlights> request, MessageContext messageContext) {
  // access the SOAPAction value
  WebServiceMessage webServiceMessage = messageContext.getRequest();
  SoapMessage soapMessage = (SoapMessage) webServiceMessage;
  LOGGER.info("SOAPAction header: {}", soapMessage.getSoapAction());

  ObjectFactory factory = new ObjectFactory();
  TFlightsResponse tFlightsResponse = factory.createTFlightsResponse();
  tFlightsResponse.getFlightNumber().add(BigInteger.valueOf(101));

  return factory.createListFlightsResponse(tFlightsResponse);
}
 
Example #21
Source File: TicketAgentEndpoint.java    From spring-ws with MIT License 5 votes vote down vote up
@PayloadRoot(namespace = "http://example.org/TicketAgent.xsd", localPart = "listFlightsRequest")
@ResponsePayload
public JAXBElement<TFlightsResponse> listFlights(
    @RequestPayload JAXBElement<TListFlights> request) {

  ObjectFactory factory = new ObjectFactory();
  TFlightsResponse tFlightsResponse = factory.createTFlightsResponse();
  tFlightsResponse.getFlightNumber().add(BigInteger.valueOf(101));

  return factory.createListFlightsResponse(tFlightsResponse);
}
 
Example #22
Source File: TicketAgentEndpoint.java    From spring-ws with MIT License 5 votes vote down vote up
@PayloadRoot(namespace = "http://example.org/TicketAgent.xsd", localPart = "listFlightsRequest")
@ResponsePayload
public JAXBElement<TFlightsResponse> listFlights(
    @RequestPayload JAXBElement<TListFlights> request) {

  ObjectFactory factory = new ObjectFactory();
  TFlightsResponse tFlightsResponse = factory.createTFlightsResponse();
  tFlightsResponse.getFlightNumber().add(BigInteger.valueOf(101));

  return factory.createListFlightsResponse(tFlightsResponse);
}
 
Example #23
Source File: CountryEndpoint.java    From spring-boot-samples with Apache License 2.0 5 votes vote down vote up
@PayloadRoot(namespace = NAMESPACE_URI, localPart = "getCountryRequest")
@ResponsePayload
public GetCountryResponse getCountry(@RequestPayload GetCountryRequest request) {
	GetCountryResponse response = new GetCountryResponse();
	response.setCountry(countryRepository.findCountry(request.getName()));

	return response;
}
 
Example #24
Source File: ExampleEntityEndpoint.java    From spring-ws-security-soap-example with MIT License 5 votes vote down vote up
/**
 * Receives a query for an entity and returns the data for said entity.
 * <p>
 * The data to be returned will be acquired from the persistence layer, and
 * then set into the response.
 * <p>
 * But the domain model classes won't be returned. Instead JAXB beans,
 * generated from the XSD file, will be used both for mapping the SOAP
 * request payload, and to generate the SOAP response payload.
 *
 * @param request
 *            payload of the SOAP request for the entity
 * @return payload for the SOAP response with the entity
 */
@PayloadRoot(localPart = ExampleEntityEndpointConstants.REQUEST,
        namespace = ExampleEntityEndpointConstants.ENTITY_NS)
@SoapAction(ExampleEntityEndpointConstants.ACTION)
@ResponsePayload
public final GetEntityResponse
        getEntity(@RequestPayload final GetEntityRequest request) {
    final GetEntityResponse response; // SOAP response with the result
    final ExampleEntity entity;       // Found entity
    final Entity entityResponse;      // Entity to return

    checkNotNull(request, "Received a null pointer as request");

    LOGGER.debug("Received request for id {}", request.getId());

    // Acquires the entity
    entity = getExampleEntityService().findById(request.getId());

    // The entity is transformed from the domain model to the JAXB model
    entityResponse = new Entity();
    BeanUtils.copyProperties(entity, entityResponse);

    LOGGER.debug("Found entity with id {} and name {}", entity.getId(),
            entity.getName());

    response = new GetEntityResponse();
    response.setEntity(entityResponse);

    return response;
}
 
Example #25
Source File: CalculatorEndpoint.java    From cukes with Apache License 2.0 5 votes vote down vote up
@PayloadRoot(namespace = "http://github.com/ctco/cukes/cukes-soap-sample", localPart = "calculatorRequest")
@ResponsePayload
public CalculatorResponse calculate(@RequestPayload CalculatorRequest request) {
    CalculatorResponse response = new CalculatorResponse();
    response.setResult(request.getA() + request.getB());
    return response;
}
 
Example #26
Source File: SpringWsTestserviceEndpoint.java    From tracee with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@PayloadRoot(localPart = JaxwsTestservice.CURRENT_TRACEE_CONTEXT_LOCALPART,
	namespace = JaxwsTestservice.TNS)
@ResponsePayload
public TraceeEntryResponse currentTraceeContext(@RequestPayload TraceeEntryMethod method) {
	Tracee.getBackend().put("testId", "TestValueFromRemoteEndpoint");
	return new TraceeEntryResponse(Tracee.getBackend().get(TraceeConstants.INVOCATION_ID_KEY));
}
 
Example #27
Source File: CountryEndpoint.java    From tutorials with MIT License 5 votes vote down vote up
@PayloadRoot(namespace = NAMESPACE_URI, localPart = "getCountryRequest")
@ResponsePayload
public GetCountryResponse getCountry(@RequestPayload GetCountryRequest request) {
    GetCountryResponse response = new GetCountryResponse();
    response.setCountry(countryRepository.findCountry(request.getName()));

    return response;
}
 
Example #28
Source File: TicketAgentEndpoint.java    From spring-ws with MIT License 5 votes vote down vote up
@PayloadRoot(namespace = "http://example.org/TicketAgent.xsd", localPart = "listFlightsRequest")
@ResponsePayload
public JAXBElement<TFlightsResponse> listFlights(
    @RequestPayload JAXBElement<TListFlights> request) throws InterruptedException {

  // sleep for 10 seconds so a timeout occurs
  Thread.sleep(10 * 1000);

  ObjectFactory factory = new ObjectFactory();
  TFlightsResponse tFlightsResponse = factory.createTFlightsResponse();
  tFlightsResponse.getFlightNumber().add(BigInteger.valueOf(101));

  return factory.createListFlightsResponse(tFlightsResponse);
}
 
Example #29
Source File: CourseDetailsEndpoint.java    From Spring with Apache License 2.0 5 votes vote down vote up
@PayloadRoot(namespace = "http://localhost:8080/courses", localPart = "GetCourseDetailsRequest")
@ResponsePayload
public GetCourseDetailsResponse processCourseDetailsRequest(@RequestPayload GetCourseDetailsRequest request) {

	Course course = service.findById(request.getId());

	if (course == null)
		throw new CourseNotFoundException("Invalid Course Id " + request.getId());

	return mapCourseDetails(course);
}
 
Example #30
Source File: CourseDetailsEndpoint.java    From Spring with Apache License 2.0 5 votes vote down vote up
@PayloadRoot(namespace = "http://localhost:8080/courses", localPart = "GetAllCourseDetailsRequest")
@ResponsePayload
public GetAllCourseDetailsResponse processAllCourseDetailsRequest(
		@RequestPayload GetAllCourseDetailsRequest request) {

	List<Course> courses = service.findAll();

	return mapAllCourseDetails(courses);
}