Search in sources :

Example 1 with DefaultOperationParametersBuilder

use of org.mule.runtime.extension.api.client.DefaultOperationParametersBuilder in project mule by mulesoft.

the class ReflectiveHttpConfigBasedRequester method request.

private Pair<InputStream, Map<String, String>> request(String method, String url, Map<String, String> headers, InputStream body) {
    DefaultOperationParametersBuilder params = builder().configName(configName).addParameter("method", method).addParameter("url", url).addParameter("headers", new MultiMap<>(headers)).addParameter("targetValue", "#[payload]");
    if (body != null) {
        params.addParameter("body", new TypedValue<>(body, INPUT_STREAM));
    }
    try {
        Result<Object, Object> result = client.executeAsync("HTTP", "request", params.build()).get();
        Map<String, String> httpHeaders = getHttpHeaders(result);
        InputStream content = getContent(result);
        return new Pair<>(content, httpHeaders);
    } catch (Exception e) {
        throw new DispatchingException("Could not dispatch soap message using the [" + configName + "] HTTP configuration", e);
    }
}
Also used : MultiMap(org.mule.runtime.api.util.MultiMap) InputStream(java.io.InputStream) InvocationTargetException(java.lang.reflect.InvocationTargetException) DispatchingException(org.mule.runtime.soap.api.exception.DispatchingException) DispatchingException(org.mule.runtime.soap.api.exception.DispatchingException) DefaultOperationParametersBuilder(org.mule.runtime.extension.api.client.DefaultOperationParametersBuilder) Pair(org.mule.runtime.api.util.Pair)

Aggregations

InputStream (java.io.InputStream)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 MultiMap (org.mule.runtime.api.util.MultiMap)1 Pair (org.mule.runtime.api.util.Pair)1 DefaultOperationParametersBuilder (org.mule.runtime.extension.api.client.DefaultOperationParametersBuilder)1 DispatchingException (org.mule.runtime.soap.api.exception.DispatchingException)1