&& (Future.class.equals(m.getReturnType())
|| Response.class.equals(m.getReturnType()));
}
static SOAPFault createSoapFault(SOAPBinding binding, Exception ex) throws SOAPException {
SOAPFault soapFault;
try {
soapFault = binding.getSOAPFactory().createFault();
} catch (Throwable t) {
//probably an old version of saaj or something that is not allowing createFault
//method to work. Try the saaj 1.2 method of doing this.
try {
soapFault = binding.getMessageFactory().createMessage()
.getSOAPPart().getEnvelope().getBody().addFault();
} catch (Throwable t2) {
//still didn't work, we'll just throw what we have
return null;
}
}
if (ex instanceof SoapFault) {
if (!soapFault.getNamespaceURI().equals(((SoapFault)ex).getFaultCode().getNamespaceURI())
&& SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE
.equals(((SoapFault)ex).getFaultCode().getNamespaceURI())) {
//change to 1.1
try {
soapFault = SAAJFactoryResolver.createSOAPFactory(null).createFault();
} catch (Throwable t) {
//ignore
}
}
final boolean isSoap11 = SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE.equals(soapFault.getNamespaceURI());
if (isSoap11 || ((SoapFault)ex).getLang() == null) {
soapFault.setFaultString(((SoapFault)ex).getReason());
} else {
soapFault.setFaultString(((SoapFault)ex).getReason(), stringToLocale(((SoapFault)ex).getLang()));
}
SAAJUtils.setFaultCode(soapFault, ((SoapFault)ex).getFaultCode());
String role = ((SoapFault)ex).getRole();
if (role != null) {
soapFault.setFaultActor(role);
}
if (((SoapFault)ex).getSubCodes() != null && !isSoap11) {
// set the subcode only if it is supported (e.g, 1.2)
for (QName fsc : ((SoapFault)ex).getSubCodes()) {
soapFault.appendFaultSubcode(fsc);
}
}
if (((SoapFault)ex).hasDetails()) {
Node nd = soapFault.getOwnerDocument().importNode(((SoapFault)ex).getDetail(),
true);
nd = nd.getFirstChild();
soapFault.addDetail();
while (nd != null) {
Node next = nd.getNextSibling();
soapFault.getDetail().appendChild(nd);
nd = next;
}
}
} else {
String msg = ex.getMessage();
if (msg != null) {
soapFault.setFaultString(msg);
}
}
return soapFault;
}