List<PDElement> pdeList = new ArrayList<PDElement>();
// Count
int totalBodyBlocks = 0;
for (int i = 0; i < params.length; i++) {
ParameterDescription pd = params[i];
if (pd.getMode() == Mode.IN && isInput ||
pd.getMode() == Mode.INOUT ||
pd.getMode() == Mode.OUT && !isInput) {
if (!pd.isHeader() && !isSWAAttachment(pd)) {
totalBodyBlocks++;
}
}
}
if (!isInput && hasReturnInBody) {
totalBodyBlocks++;
}
int index = (!isInput && hasReturnInBody) ? 1 : 0;
// TODO What if return is an swa attachment, then this should start
// at 1 not 0.
int swaIndex = 0;
for (int i = 0; i < params.length; i++) {
ParameterDescription pd = params[i];
if (pd.getMode() == Mode.IN && isInput ||
pd.getMode() == Mode.INOUT ||
pd.getMode() == Mode.OUT && !isInput) {
// Don't consider async handlers, they are are not represented on the wire,
// thus they don't have a PDElement
// TODO
//if (isAsyncHandler(param)) {
// continue;
//}
Block block = null;
JAXBBlockContext context = new JAXBBlockContext(packages);
AttachmentDescription attachmentDesc = pd.getAttachmentDescription();
if (attachmentDesc == null) {
// Normal Processing: Not an Attachment
// Trigger unmarshal by java type if necessary
if (unmarshalByJavaType != null && unmarshalByJavaType[i] != null) {
context.setProcessType(unmarshalByJavaType[i]);
context.setIsxmlList(pd.isListType());
}
boolean consume = true;
// Unmarshal the object into a JAXB object or JAXBElement
if (pd.isHeader()) {
// Get the Block from the header
// NOTE The parameter name is always used to get the header
// element...even if the style is RPC.
String localName = pd.getParameterName();
block = message.getHeaderBlock(pd.getTargetNamespace(),
localName,
context,
factory);
consume = false;
} else {
if (totalBodyBlocks > 1) {
// You must use this method if there are more than one body block
// This method may cause OM expansion
block = message.getBodyBlock(index, context, factory);
} else {
// Use this method if you know there is only one body block.
// This method prevents OM expansion.
block = message.getBodyBlock(context, factory);
}
index++;
}
Element element;
if (block != null) {
element = new Element(block.getBusinessObject(true),
block.getQName());
} else {
// The block could be null if the header is missing (which is allowed)
QName qName = new QName(pd.getTargetNamespace(),pd.getParameterName());
if (log.isDebugEnabled()) {
log.debug("There is no value in the incoming message for " + qName);
}
element = new Element(null, qName, pd.getParameterActualType());
}
PDElement pde =
new PDElement(pd, element, unmarshalByJavaType == null ? null
: unmarshalByJavaType[i]);
pdeList.add(pde);
} else {
// Attachment Processing
if (attachmentDesc.getAttachmentType() == AttachmentType.SWA) {
String partName = pd.getPartName();
String cid = null;
if (log.isDebugEnabled()) {
log.debug("Getting the attachment dataHandler for partName=" + partName);
}
if (partName != null && partName.length() > 0) {