// we always generate an xsi:type attribute. This is an implemenation detail
// and is not defined by any spec.
// Get the operation information
ParameterDescription[] pds = operationDesc.getParameterDescriptions();
MarshalServiceRuntimeDescription marshalDesc =
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 operation element name. This triggers the message to
// put the data blocks underneath the operation element
m.setStyle(Style.RPC);
QName rpcOpQName = getRPCOperationQName(operationDesc, false);
String localPart = rpcOpQName.getLocalPart() + "Response";
QName responseOp =
new QName(rpcOpQName.getNamespaceURI(), localPart, rpcOpQName.getPrefix());
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 = ""; // According to WSI BP the body part is unqualified
returnLocalPart = operationDesc.getResultPartName();
}
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 {
// TODO should we allow null if the return is a header?
//Validate input parameters for operation and make sure no input parameters are null.
//As per JAXWS Specification section 3.6.2.3 if a null value is passes as an argument
//to a method then an implementation MUST throw WebServiceException.
if (returnObject == null) {
throw ExceptionFactory.makeWebServiceException(
Messages.getMessage("NullParamErr3",operationDesc.getJavaMethodName()));
}
Element returnElement = null;
QName returnQName = new QName(returnNS, returnLocalPart);
if (marshalDesc.getAnnotationDesc(returnType).hasXmlRootElement()) {
returnElement = new Element(returnObject, returnQName);
} else {
returnElement = new Element(returnObject, returnQName, returnType);
}