Search in sources :

Example 1 with ForwardingSoapClient

use of org.mule.runtime.module.extension.soap.internal.runtime.connection.ForwardingSoapClient in project mule by mulesoft.

the class InvokeKeysResolver method buildServiceKey.

private MetadataKey buildServiceKey(ForwardingSoapClient connection, WebServiceDefinition ws) {
    String serviceId = ws.getServiceId();
    SoapMetadataResolver resolver = connection.getSoapClient(serviceId).getMetadataResolver();
    MetadataKeyBuilder key = newKey(serviceId).withDisplayName(ws.getFriendlyName());
    List<String> excludedOperations = ws.getExcludedOperations();
    resolver.getAvailableOperations().stream().filter(ope -> !excludedOperations.contains(ope)).forEach(ope -> key.withChild(newKey(ope).withDisplayName(NameUtils.titleize(ope))));
    return key.build();
}
Also used : MultilevelMetadataKeyBuilder.newKey(org.mule.runtime.module.extension.api.metadata.MultilevelMetadataKeyBuilder.newKey) ImmutableSet(com.google.common.collect.ImmutableSet) NameUtils(org.mule.runtime.extension.api.util.NameUtils) Set(java.util.Set) WebServiceDefinition(org.mule.runtime.extension.api.soap.WebServiceDefinition) MetadataKeyBuilder(org.mule.runtime.api.metadata.MetadataKeyBuilder) MetadataKey(org.mule.runtime.api.metadata.MetadataKey) List(java.util.List) ConnectionException(org.mule.runtime.api.connection.ConnectionException) MetadataContext(org.mule.runtime.api.metadata.MetadataContext) ForwardingSoapClient(org.mule.runtime.module.extension.soap.internal.runtime.connection.ForwardingSoapClient) MetadataResolvingException(org.mule.runtime.api.metadata.MetadataResolvingException) TypeKeysResolver(org.mule.runtime.api.metadata.resolving.TypeKeysResolver) SoapMetadataResolver(org.mule.runtime.soap.api.client.metadata.SoapMetadataResolver) MetadataKeyBuilder(org.mule.runtime.api.metadata.MetadataKeyBuilder) SoapMetadataResolver(org.mule.runtime.soap.api.client.metadata.SoapMetadataResolver)

Example 2 with ForwardingSoapClient

use of org.mule.runtime.module.extension.soap.internal.runtime.connection.ForwardingSoapClient in project mule by mulesoft.

the class InvokeKeysResolver method getKeys.

/**
 * {@inheritDoc}
 *
 * Resolves multi-level metadata keys with the services available to hit and for each of the services exposes all
 * available operations.
 */
@Override
public Set<MetadataKey> getKeys(MetadataContext context) throws MetadataResolvingException, ConnectionException {
    ForwardingSoapClient connection = getConnection(context);
    ImmutableSet.Builder<MetadataKey> keys = ImmutableSet.builder();
    connection.getAllWebServices().forEach(ws -> keys.add(buildServiceKey(connection, ws)));
    return keys.build();
}
Also used : ForwardingSoapClient(org.mule.runtime.module.extension.soap.internal.runtime.connection.ForwardingSoapClient) ImmutableSet(com.google.common.collect.ImmutableSet) MetadataKey(org.mule.runtime.api.metadata.MetadataKey)

Example 3 with ForwardingSoapClient

use of org.mule.runtime.module.extension.soap.internal.runtime.connection.ForwardingSoapClient in project mule by mulesoft.

the class SoapOperationExecutor method execute.

/**
 * {@inheritDoc}
 */
@Override
public Publisher<Object> execute(ExecutionContext<OperationModel> context) {
    try {
        String serviceId = context.getParameter(SERVICE_PARAM);
        ForwardingSoapClient connection = (ForwardingSoapClient) connectionResolver.resolve(context).get();
        Map<String, String> customHeaders = connection.getCustomHeaders(serviceId, getOperation(context));
        SoapRequest request = getRequest(context, customHeaders);
        SoapClient soapClient = connection.getSoapClient(serviceId);
        SoapResponse response = connection.getExtensionsClientDispatcher(() -> new ExtensionsClientArgumentResolver(registry, policyManager).resolve(context).get()).map(d -> soapClient.consume(request, d)).orElseGet(() -> soapClient.consume(request));
        return justOrEmpty(response.getAsResult(streamingHelperArgumentResolver.resolve(context).get()));
    } catch (MessageTransformerException | TransformerException e) {
        return error(e);
    } catch (Exception e) {
        return error(soapExceptionEnricher.enrich(e));
    } catch (Throwable t) {
        return error(wrapFatal(t));
    }
}
Also used : HEADERS_PARAM(org.mule.runtime.module.extension.soap.internal.loader.SoapInvokeOperationDeclarer.HEADERS_PARAM) Exceptions.wrapFatal(org.mule.runtime.core.api.rx.Exceptions.wrapFatal) OperationModel(org.mule.runtime.api.meta.model.operation.OperationModel) MessageTransformerException(org.mule.runtime.core.api.transformer.MessageTransformerException) BindingContext(org.mule.runtime.api.el.BindingContext) MuleExpressionLanguage(org.mule.runtime.api.el.MuleExpressionLanguage) ComponentExecutor(org.mule.runtime.extension.api.runtime.operation.ComponentExecutor) ATTACHMENTS_PARAM(org.mule.runtime.module.extension.soap.internal.loader.SoapInvokeOperationDeclarer.ATTACHMENTS_PARAM) HashMap(java.util.HashMap) SoapRequestBuilder(org.mule.runtime.soap.api.message.SoapRequestBuilder) Inject(javax.inject.Inject) ExtensionsClientArgumentResolver(org.mule.runtime.module.extension.internal.runtime.resolver.ExtensionsClientArgumentResolver) ConnectionArgumentResolver(org.mule.runtime.module.extension.internal.runtime.resolver.ConnectionArgumentResolver) MESSAGE_GROUP(org.mule.runtime.module.extension.soap.internal.loader.SoapInvokeOperationDeclarer.MESSAGE_GROUP) SoapClient(org.mule.runtime.soap.api.client.SoapClient) Map(java.util.Map) SoapResponse(org.mule.runtime.soap.api.message.SoapResponse) Registry(org.mule.runtime.api.artifact.Registry) IOUtils(org.mule.runtime.core.api.util.IOUtils) PolicyManager(org.mule.runtime.core.internal.policy.PolicyManager) Mono.error(reactor.core.publisher.Mono.error) INPUT_STREAM(org.mule.runtime.api.metadata.DataType.INPUT_STREAM) BODY_PARAM(org.mule.runtime.module.extension.soap.internal.loader.SoapInvokeOperationDeclarer.BODY_PARAM) TransformationService(org.mule.runtime.api.transformation.TransformationService) ExecutionContext(org.mule.runtime.extension.api.runtime.operation.ExecutionContext) OPERATION_PARAM(org.mule.runtime.module.extension.soap.internal.loader.SoapInvokeOperationDeclarer.OPERATION_PARAM) DataType(org.mule.runtime.api.metadata.DataType) Publisher(org.reactivestreams.Publisher) SoapRequest(org.mule.runtime.soap.api.message.SoapRequest) Mono.justOrEmpty(reactor.core.publisher.Mono.justOrEmpty) TransformerException(org.mule.runtime.core.api.transformer.TransformerException) SoapAttachment(org.mule.runtime.extension.api.soap.SoapAttachment) SERVICE_PARAM(org.mule.runtime.module.extension.soap.internal.loader.SoapInvokeOperationDeclarer.SERVICE_PARAM) TypedValue(org.mule.runtime.api.metadata.TypedValue) TRANSPORT_HEADERS_PARAM(org.mule.runtime.module.extension.soap.internal.loader.SoapInvokeOperationDeclarer.TRANSPORT_HEADERS_PARAM) StreamingHelperArgumentResolver(org.mule.runtime.module.extension.internal.runtime.resolver.StreamingHelperArgumentResolver) ForwardingSoapClient(org.mule.runtime.module.extension.soap.internal.runtime.connection.ForwardingSoapClient) ExtensionsClient(org.mule.runtime.extension.api.client.ExtensionsClient) Optional(java.util.Optional) SoapExceptionEnricher(org.mule.runtime.soap.api.exception.error.SoapExceptionEnricher) InputStream(java.io.InputStream) SoapClient(org.mule.runtime.soap.api.client.SoapClient) ForwardingSoapClient(org.mule.runtime.module.extension.soap.internal.runtime.connection.ForwardingSoapClient) MessageTransformerException(org.mule.runtime.core.api.transformer.MessageTransformerException) TransformerException(org.mule.runtime.core.api.transformer.TransformerException) ForwardingSoapClient(org.mule.runtime.module.extension.soap.internal.runtime.connection.ForwardingSoapClient) SoapRequest(org.mule.runtime.soap.api.message.SoapRequest) SoapResponse(org.mule.runtime.soap.api.message.SoapResponse) ExtensionsClientArgumentResolver(org.mule.runtime.module.extension.internal.runtime.resolver.ExtensionsClientArgumentResolver) MessageTransformerException(org.mule.runtime.core.api.transformer.MessageTransformerException) MessageTransformerException(org.mule.runtime.core.api.transformer.MessageTransformerException) TransformerException(org.mule.runtime.core.api.transformer.TransformerException)

Aggregations

ForwardingSoapClient (org.mule.runtime.module.extension.soap.internal.runtime.connection.ForwardingSoapClient)3 ImmutableSet (com.google.common.collect.ImmutableSet)2 MetadataKey (org.mule.runtime.api.metadata.MetadataKey)2 InputStream (java.io.InputStream)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Set (java.util.Set)1 Inject (javax.inject.Inject)1 Registry (org.mule.runtime.api.artifact.Registry)1 ConnectionException (org.mule.runtime.api.connection.ConnectionException)1 BindingContext (org.mule.runtime.api.el.BindingContext)1 MuleExpressionLanguage (org.mule.runtime.api.el.MuleExpressionLanguage)1 OperationModel (org.mule.runtime.api.meta.model.operation.OperationModel)1 DataType (org.mule.runtime.api.metadata.DataType)1 INPUT_STREAM (org.mule.runtime.api.metadata.DataType.INPUT_STREAM)1 MetadataContext (org.mule.runtime.api.metadata.MetadataContext)1 MetadataKeyBuilder (org.mule.runtime.api.metadata.MetadataKeyBuilder)1 MetadataResolvingException (org.mule.runtime.api.metadata.MetadataResolvingException)1