ComponentSupport component = getComponent(context, element);
if (component == null) {
throw new MessagingException("Could not find a component on which to perform the service invocation!");
}
TransformerImpl transformer = context.getTransformer();
PrefixResolver namespaceContext = transformer.getXPathContext().getNamespaceContext();
QName service = getQNameAttribute(namespaceContext, element, "service");
QName interfaceName = getQNameAttribute(namespaceContext, element, "interface");
QName operation = getQNameAttribute(namespaceContext, element, "operation");
InOut outExchange = component.createInOutExchange(service, interfaceName, operation);
NormalizedMessage out = outExchange.createMessage();
outExchange.setInMessage(out);
// lets copy the content into the body
Document document = getTransformer().createDocument();
DOMBuilder builder = new DOMBuilder(document);
transformer.executeChildTemplates(element, context.getContextNode(), context.getMode(), builder);
out.setContent(new DOMSource(document));
// now lets perform the invocation
if (component.getDeliveryChannel().sendSync(outExchange)) {
NormalizedMessage result = outExchange.getOutMessage();
String outVarName = getAttribute(element, "outVar", "out");
transformer.setParameter(outVarName, result);
}
else {
Exception error = outExchange.getError();
if (error != null) {
transformer.setParameter("error", error);
}
Fault fault = outExchange.getFault();
if (fault != null) {
transformer.setParameter("fault", fault);
}
}
}