class OrderHistoryClient {

  public OrderHistory getOrderHistory(String userId) throws IOException {
    // create the request
    ObjectFactory factory = new ObjectFactory();
    GetOrderHistoryRequest getOrderHistoryRequest = factory.createGetOrderHistoryRequest();
    getOrderHistoryRequest.setUserId(userId);

    // marshal the request
    WebServiceMessage request = webServiceTemplate.getMessageFactory().createWebServiceMessage();
    MarshallingUtils.marshal(webServiceTemplate.getMarshaller(), getOrderHistoryRequest, request);

    // call the service
    DOMResult responseResult = new DOMResult();
    webServiceTemplate.sendSourceAndReceiveToResult(request.getPayloadSource(), responseResult);

    // extract the needed elements
    List<Order> orders = orderXPath.evaluate(responseResult.getNode(), new NodeMapper<Order>() {

      @Override
      public Order mapNode(Node node, int nodeNum) {
        // get the orderId
        String orderId = orderIdXPath.evaluateAsString(node);
        // create an order
        return new Order(orderId);
      }
    });

    OrderHistory result = new OrderHistory();
    result.setOrders(orders);
    LOGGER.info("found '{}' orders for userId='{}'", result.getOrders().size(), userId);

    return result;
  }

}