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 {
// Use byJavaType marshalling if necessary
Class byJavaType = null;
if (MethodMarshallerUtils.isNotJAXBRootElement(returnType, marshalDesc)) {
byJavaType = returnType;
}
Element returnElement = null;
QName returnQName = new QName(operationDesc.getResultTargetNamespace(),
operationDesc.getResultName());
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,
byJavaType,
operationDesc.isResultHeader());
}
}
// Convert the holder objects into a list of JAXB objects for marshalling
List<PDElement> pdeList = MethodMarshallerUtils.getPDElements(marshalDesc,
pds,
signatureArgs,
false, // output
false, false);
// We want to use "by Java Type" marshalling for
// all body elements and all non-JAXB objects
for (PDElement pde : pdeList) {
ParameterDescription pd = pde.getParam();
Class type = pd.getParameterActualType();
if (MethodMarshallerUtils.isNotJAXBRootElement(type, marshalDesc)) {
pde.setByJavaTypeClass(type);
}
}
// Put values onto the message
MethodMarshallerUtils.toMessage(pdeList, m, packages, null);
// Enable SWA for nested SwaRef attachments
if (operationDesc.hasResponseSwaRefAttachments()) {
m.setDoingSWA(true);
}
return m;
} catch (Exception e) {
throw ExceptionFactory.makeWebServiceException(e);