Example #1
0
    @Override
    public Source respond(SoapOperation invokedOperation, SoapMessage message) {
      Exchange exchange = new DefaultExchange(getCamelContext(), ExchangePattern.InOut);

      Document messageDocument = message.getDocument();
      String requestBody = envelopeWrapper.unwrap(messageDocument, getCamelContext());

      exchange.getIn().setBody(requestBody);
      exchange.getIn().setHeader(OPERATION, invokedOperation.getOperationName());

      try {
        getProcessor().process(exchange);
        if (exchange.getException() != null) {
          throw exchange.getException();
        }
        Message responseMessage = exchange.getOut(Message.class);
        if (responseMessage != null) {
          String responseBody = responseMessage.getBody(String.class);
          return envelopeWrapper.wrapToSource(responseBody, getCamelContext());
        } else {
          throw new IllegalArgumentException(
              "Could not find output message, exchange: " + exchange);
        }
      } catch (Exception ex) {
        throw new SoapServerException(ex);
      }
    }
Example #2
0
  public List<String> getOperations(String url) {
    List<String> result = new ArrayList<>();
    try {
      Wsdl wsdl = Wsdl.parse(url);
      List<QName> bindings = wsdl.getBindings();
      for (QName binding : bindings) {
        SoapBuilder builder = wsdl.binding().localPart(binding.getLocalPart()).find();
        for (SoapOperation operation : builder.getOperations())
          result.add(operation.getOperationName());
      }

    } catch (Exception e) {
      logger.info(e.getLocalizedMessage());
    }

    return result;
  }