return new WebServiceException(ex);
}
@SuppressWarnings("unchecked")
public T invoke(T obj, boolean isOneWay) {
StaxSource createdSource = null;
checkError();
try {
if (obj instanceof SOAPMessage) {
SOAPMessage msg = (SOAPMessage)obj;
if (msg.countAttachments() > 0) {
client.getRequestContext().put(AttachmentOutInterceptor.WRITE_ATTACHMENTS, Boolean.TRUE);
}
} else if (context != null) {
Boolean unwrapProperty = obj instanceof JAXBElement ? Boolean.FALSE : Boolean.TRUE;
getRequestContext().put("unwrap.jaxb.element", unwrapProperty);
}
QName opName = (QName)getRequestContext().get(MessageContext.WSDL_OPERATION);
if (opName == null) {
opName = new QName(DISPATCH_NS,
isOneWay ? INVOKE_ONEWAY_NAME : INVOKE_NAME);
}
//CXF-2836 : find the operation for the dispatched object
boolean wsaEnabled = false;
for (AbstractFeature feature : ((JaxWsClientEndpointImpl)client.getEndpoint()).getFeatures()) {
if (feature instanceof WSAddressingFeature) {
wsaEnabled = true;
}
}
Map<String, QName> payloadOPMap =
createPayloadEleOpNameMap(client.getEndpoint().getBinding().getBindingInfo());
if (wsaEnabled && !payloadOPMap.isEmpty()) {
String payloadElementName = null;
if (obj instanceof javax.xml.transform.Source) {
try {
XMLStreamReader reader = StaxUtils
.createXMLStreamReader((javax.xml.transform.Source)obj);
Document document = StaxUtils.read(reader);
createdSource = new StaxSource(StaxUtils.createXMLStreamReader(document));
payloadElementName = getPayloadElementName(document.getDocumentElement());
} catch (Exception e) {
// ignore, we are tring to get the operation name
}
}