MethodMarshallerUtils.getMarshalDesc(endpointDesc);
TreeSet<String> packages = marshalDesc.getPackages();
// Create the message
MessageFactory mf = (MessageFactory)FactoryRegistry.getFactory(MessageFactory.class);
Message m = mf.create(protocol);
// Put the return object onto the message
Class returnType = operationDesc.getResultActualType();
if (returnType != void.class) {
AttachmentDescription attachmentDesc =
operationDesc.getResultAttachmentDescription();
if (attachmentDesc != null) {
if (attachmentDesc.getAttachmentType() == AttachmentType.SWA) {
// Create an Attachment object with the signature value
Attachment attachment = new Attachment(returnObject,
returnType,
attachmentDesc,
operationDesc.getResultPartName());
m.addDataHandler(attachment.getDataHandler(),
attachment.getContentID());
m.setDoingSWA(true);
} else {
throw ExceptionFactory.
makeWebServiceException(Messages.getMessage("pdElementErr"));
}
} else {
Element returnElement = null;
QName returnQName = new QName(operationDesc.getResultTargetNamespace(),
operationDesc.getResultName());
if (marshalDesc.getAnnotationDesc(returnType).hasXmlRootElement()) {
returnElement = new Element(returnObject, returnQName);
} else {
/* when a schema defines a SimpleType with xsd list jaxws tooling generates art-effects with array rather than a java.util.List
* However the ObjectFactory definition uses a List and thus marshalling fails. Lets convert the Arrays to List.
*/
if(operationDesc.isListType()){
List list= new ArrayList();
if(returnType.isArray()){
for(int count = 0; count < Array.getLength(returnObject); count++){
Object obj = Array.get(returnObject, count);
list.add(obj);
}
returnElement = new Element(list, returnQName, List.class);
}
}
else{
returnElement = new Element(returnObject, returnQName, returnType);
}
}
MethodMarshallerUtils.toMessage(returnElement,
returnType,
operationDesc.isListType(),
marshalDesc,
m,
null, // always marshal using "by element" mode
operationDesc.isResultHeader());
}
}
// Convert the holder objects into a list of JAXB objects for marshalling
List<PDElement> pvList = MethodMarshallerUtils.getPDElements(marshalDesc,
pds,
signatureArgs,
false, // output
false,
false);
// Put values onto the message
MethodMarshallerUtils.toMessage(pvList, m, packages, null);
// Enable SWA for nested SwaRef attachments
if (operationDesc.hasResponseSwaRefAttachments()) {
m.setDoingSWA(true);
}
return m;
} catch (Exception e) {
throw ExceptionFactory.makeWebServiceException(e);