Search in sources :

Example 1 with ResponsePayload

use of org.springframework.ws.server.endpoint.annotation.ResponsePayload in project webservices-axiom by apache.

the class BrokerEndpoint method order.

@PayloadRoot(namespace = "urn:broker", localPart = "Order")
@ResponsePayload
@Namespaces(@Namespace(prefix = "p", uri = "urn:broker"))
public OrderStatus order(@XPathParam("/p:Order/p:Customer") Integer customer, @RequestPayload Source payloadSource) throws UnknownCustomerException, TransformerException {
    customerService.validateCustomer(customer);
    StringWriter sw = new StringWriter();
    transformerHelper.transform(payloadSource, new StreamResult(sw));
    String payload = sw.toString();
    synchronized (orderQueue) {
        orderQueue.addLast(payload);
        orderQueue.notify();
    }
    OrderStatus status = new OrderStatus();
    status.setReceived(new Date());
    return status;
}
Also used : StringWriter(java.io.StringWriter) StreamResult(javax.xml.transform.stream.StreamResult) Date(java.util.Date) Namespaces(org.springframework.ws.server.endpoint.annotation.Namespaces) ResponsePayload(org.springframework.ws.server.endpoint.annotation.ResponsePayload) PayloadRoot(org.springframework.ws.server.endpoint.annotation.PayloadRoot)

Example 2 with ResponsePayload

use of org.springframework.ws.server.endpoint.annotation.ResponsePayload in project webservices-axiom by apache.

the class CalculatorEndpoint method add.

@PayloadRoot(namespace = NAMESPACE_URI, localPart = "AddRequest")
@ResponsePayload
public Element add(@RequestPayload Element addRequest) throws Exception {
    log.debug("Endpoint invoked");
    double sum = 0d;
    for (Element operand : operandExpression.evaluate(addRequest)) {
        sum += Double.parseDouble(operand.getTextNormalize());
    }
    Element response = new Element("AddResponse", NAMESPACE);
    response.setText(String.valueOf(sum));
    return response;
}
Also used : Element(org.jdom2.Element) ResponsePayload(org.springframework.ws.server.endpoint.annotation.ResponsePayload) PayloadRoot(org.springframework.ws.server.endpoint.annotation.PayloadRoot)

Aggregations

PayloadRoot (org.springframework.ws.server.endpoint.annotation.PayloadRoot)2 ResponsePayload (org.springframework.ws.server.endpoint.annotation.ResponsePayload)2 StringWriter (java.io.StringWriter)1 Date (java.util.Date)1 StreamResult (javax.xml.transform.stream.StreamResult)1 Element (org.jdom2.Element)1 Namespaces (org.springframework.ws.server.endpoint.annotation.Namespaces)1