use of org.mule.runtime.http.api.domain.entity.InputStreamHttpEntity in project mule by mulesoft.
the class DefaultHttpMessageDispatcher method dispatch.
/**
* {@inheritDoc}
* <p>
* Dispatches a Soap message through http adding the SoapAction header, if required, and the content-type.
*/
@Override
public DispatchingResponse dispatch(DispatchingRequest context) {
InputStream content = logIfNeeded("Soap Request to [" + context.getAddress() + "]", context.getContent());
HttpRequest request = HttpRequest.builder().uri(context.getAddress()).method(POST).entity(new InputStreamHttpEntity(content)).headers(new MultiMap<>(context.getHeaders())).build();
try {
HttpResponse response = client.send(request, DEFAULT_TIMEOUT_MILLIS, false, null);
return new DispatchingResponse(logIfNeeded("Soap Response", response.getEntity().getContent()), toHeadersMap(response));
} catch (IOException e) {
throw new DispatchingException("An error occurred while sending the SOAP request");
} catch (TimeoutException e) {
throw new DispatchingException("The SOAP request timed out", e);
}
}
Aggregations