targetWrapperHandler = getWrapperHandler(targetDataBinding, targetWrapped);
if ((!sourceWrapped &&!sourceBare) && targetWrapped) {
// Unwrapped --> Wrapped
WrapperInfo wrapper = targetOp.getWrapper();
ElementInfo wrapperElement = wrapper.getOutputWrapperElement();
List<ElementInfo> childElements = wrapper.getOutputChildElements();
Class<?> targetWrapperClass = wrapper != null ? wrapper.getOutputWrapperClass() : null;
// If the source can be wrapped, wrapped it first
if (sourceWrapperHandler != null) {
WrapperInfo sourceWrapperInfo = sourceOp.getWrapper();
DataType sourceWrapperType =
sourceWrapperInfo != null ? sourceWrapperInfo.getOutputWrapperType() : null;
if (sourceWrapperType != null && matches(sourceOp.getWrapper(), targetOp.getWrapper())) {
Class<?> sourceWrapperClass = sourceWrapperType.getPhysical();
Object sourceWrapper = sourceWrapperHandler.create(sourceOp, false);
if (sourceWrapper != null) {
if (!childElements.isEmpty()) {
// Set the return value
sourceWrapperHandler.setChildren(sourceWrapper,
new Object[] {response},
sourceOp,
false);
}
Object targetWrapper =
mediator.mediate(sourceWrapper, sourceWrapperType, targetType.getLogical(), context
.getMetadata());
return targetWrapper;
}
}
}
Object targetWrapper = targetWrapperHandler.create(targetOp, false);
if (childElements.isEmpty()) {
// void output
return targetWrapper;
}
DataType<XMLType> argType = wrapper.getUnwrappedOutputType();
Object child = response;
child = mediator.mediate(response, sourceType.getLogical(), argType, context.getMetadata());
targetWrapperHandler.setChildren(targetWrapper, new Object[] {child}, targetOp, false);
return targetWrapper;
} else if (sourceWrapped && (!targetWrapped && !targetBare)) {
// Wrapped to Unwrapped
Object sourceWrapper = response;
List<ElementInfo> childElements = sourceOp.getWrapper().getOutputChildElements();
if (childElements.isEmpty()) {
// The void output
return null;
}
if (targetWrapperHandler != null) {
ElementInfo wrapperElement = sourceOp.getWrapper().getOutputWrapperElement();
// FIXME: This is a workaround for the wsdless support as it passes in child elements
// under the wrapper that only matches by position
if (sourceWrapperHandler.isInstance(sourceWrapper, sourceOp, false)) {