MethodMarshallerUtils.getMarshalDesc(endpointDesc);
TreeSet<String> packages = marshalDesc.getPackages();
// Create the message
MessageFactory mf = (MessageFactory)FactoryRegistry.getFactory(MessageFactory.class);
Message m = mf.create(protocol);
// Indicate the style and wrapper element name. This triggers the message to
// put the data blocks underneath the operation element
m.setStyle(Style.DOCUMENT);
m.setIndirection(1);
QName responseOp = getResponseWrapperQName(operationDesc);
m.setOperationElement(responseOp);
// Put the return object onto the message
Class returnType = operationDesc.getResultActualType();
String returnNS = null;
String returnLocalPart = null;
if (operationDesc.isResultHeader()) {
returnNS = operationDesc.getResultTargetNamespace();
returnLocalPart = operationDesc.getResultName();
} else {
returnNS = operationDesc.getResultTargetNamespace();
returnLocalPart = operationDesc.getResultPartName();
}
if (returnType != void.class) {
Element returnElement = null;
QName returnQName = new QName(returnNS, returnLocalPart);
if (representAsOccurrence(returnObject, returnType)) {
if (log.isDebugEnabled()) {
log.debug("Return element isListOrArray");
}
OccurrenceArray occurrenceArray = new OccurrenceArray(returnObject);
JAXBElement jaxb = new JAXBElement(returnQName, returnType, occurrenceArray);
returnElement = new Element(jaxb, returnQName);
} else if (marshalDesc.getAnnotationDesc(returnType).hasXmlRootElement()) {
returnElement = new Element(returnObject, returnQName);
} else {
returnElement = new Element(returnObject, returnQName, returnType);
}
MethodMarshallerUtils.toMessage(returnElement,
returnType,
operationDesc.isListType(),
marshalDesc,
m,
returnType, // force marshal by type
operationDesc.isResultHeader());
}
// Convert the holder objects into a list of JAXB objects for marshalling
List<PDElement> pdeList =
MethodMarshallerUtils.getPDElements(marshalDesc,
pds,
signatureArgs,
false, // output
true, // doc/lit wrapped
false); // not rpc
// We want to use "by Java Type" marshalling for
// all objects
for (int i=0; i<pdeList.size(); i++) {
PDElement pde = pdeList.get(i);
// If the actual value is an array or list
// this should be modeled as an
// occurrence of elements
pde = processOccurrence(pde);
pdeList.set(i, pde);
// Set by java type marshaling
ParameterDescription pd = pde.getParam();
Class type = pd.getParameterActualType();
pde.setByJavaTypeClass(type);
}
// TODO Should we check for null output body values? Should we check for null output header values ?
// Put values onto the message
MethodMarshallerUtils.toMessage(pdeList, m, packages, null);
// Enable SWA for nested SwaRef attachments
if (operationDesc.hasResponseSwaRefAttachments()) {
m.setDoingSWA(true);
}
if (log.isDebugEnabled()) {
log.debug("exit marshalResponse");
}