if (opMetaData.isRPCEncoded())
XOPContext.setMTOMEnabled(false);
else XOPContext.setMTOMEnabled(isMTOMEnabled());
// Associate current message with message context
SOAPMessageImpl resMessage = (SOAPMessageImpl)createMessage(opMetaData);
msgContext.setSOAPMessage(resMessage);
// R2714 For one-way operations, an INSTANCE MUST NOT return a HTTP response that contains a SOAP envelope.
// Specifically, the HTTP response entity-body must be empty.
if (opMetaData.isOneWay())
{
resMessage.getSOAPPart().setContent(null);
return resMessage;
}
SOAPEnvelope soapEnvelope = resMessage.getSOAPPart().getEnvelope();
SOAPHeader soapHeader = soapEnvelope.getHeader();
SOAPBody soapBody = soapEnvelope.getBody();
// Get the namespace registry
NamespaceRegistry namespaceRegistry = msgContext.getNamespaceRegistry();
Style style = opMetaData.getStyle();
SOAPElement soapBodyElement = soapBody;
if (style == Style.RPC)
{
QName opQName = opMetaData.getResponseName();
Name opName = new NameImpl(namespaceRegistry.registerQName(opQName));
soapBodyElement = new SOAPBodyElementRpc(opName);
soapBodyElement = (SOAPBodyElement)soapBody.addChildElement(soapBodyElement);
// Add soap encodingStyle
if (opMetaData.getUse() == Use.ENCODED)
{
String envURI = soapEnvelope.getNamespaceURI();
String envPrefix = soapEnvelope.getPrefix();
soapBodyElement.setAttributeNS(envURI, envPrefix + ":encodingStyle", Constants.URI_SOAP11_ENC);
}
}
// Add the return to the message
ParameterMetaData retMetaData = opMetaData.getReturnParameter();
if (retMetaData != null)
{
Object value = epInv.getReturnValue();
// TODO calls to ParameterWrapping should be elsewhere
if (opMetaData.isDocumentWrapped())
value = ParameterWrapping.wrapResponseParameters(retMetaData, value, epInv.getOutParameters());
if (retMetaData.isSwA())
{
CIDGenerator cidGenerator = resMessage.getCidGenerator();
AttachmentPart part = createAttachmentPart(retMetaData, value, cidGenerator);
resMessage.addAttachmentPart(part);
epInv.setReturnValue(part);
// Add the attachment to the standard property
if (part.getDataHandler() != null && msgContext instanceof MessageContextJAXWS)
{
DataHandler dataHandler = part.getDataHandler();
Map<String, DataHandler> attachments = (Map<String, DataHandler>)msgContext.get(MessageContext.OUTBOUND_MESSAGE_ATTACHMENTS);
attachments.put(part.getContentId(), dataHandler);
}
}
else
{
SOAPContentElement soapElement = addParameterToMessage(retMetaData, value, soapBodyElement);
epInv.setReturnValue(soapElement);
soapElement.setObjectValue(value);
}
}
// Add the out parameters to the message
for (ParameterMetaData paramMetaData : opMetaData.getOutputParameters())
{
QName xmlName = paramMetaData.getXmlName();
Object value = epInv.getResponseParamValue(xmlName);
if (paramMetaData.isSwA())
{
CIDGenerator cidGenerator = resMessage.getCidGenerator();
AttachmentPart part = createAttachmentPart(paramMetaData, value, cidGenerator);
resMessage.addAttachmentPart(part);
// Add the attachment to the standard property
if (value instanceof DataHandler && msgContext instanceof MessageContextJAXWS)
{
DataHandler dataHandler = (DataHandler)value;