private Object[] invoke(SoapRequest request, Exchange exchange, MessageDispatcher dispatcher) {
String operation = request.getOperation();
XMLStreamReader xmlBody = getXmlBody(request);
try {
Map<String, Object> ctx = getInvocationContext(request, dispatcher);
return client.invoke(getInvocationOperation(), new Object[] {xmlBody}, ctx, exchange);
} catch (SoapFault sf) {
throw new SoapFaultException(sf.getFaultCode(), sf.getSubCode(), parseExceptionDetail(sf.getDetail()).orElse(null),
sf.getReason(), sf.getNode(), sf.getRole(), sf);
} catch (Fault f) {
if (f.getMessage().contains("COULD_NOT_READ_XML")) {
throw new BadRequestException("Error consuming the operation [" + operation + "], the request body is not a valid XML");
}
throw new SoapFaultException(f.getFaultCode(), parseExceptionDetail(f.getDetail()).orElse(null), f);
} catch (DispatchingException e) {
throw e;
} catch (OperationNotFoundException e) {
String location = wsdlModel.getLocation();
throw new BadRequestException("The provided [" + operation + "] does not exist in the WSDL file [" + location + "]", e);
} catch (Exception e) {
throw new SoapServiceException("Unexpected error while consuming the web service operation [" + operation + "]", e);
}
}