use of javax.xml.ws.WebFault in project cxf by apache.
the class MAPAggregatorImpl method getFaultNameFromMessage.
private String getFaultNameFromMessage(final Message message) {
Exception e = message.getContent(Exception.class);
Throwable cause = e.getCause();
if (cause == null) {
cause = e;
}
if (e instanceof Fault) {
WebFault t = cause.getClass().getAnnotation(WebFault.class);
if (t != null) {
return t.name();
}
}
return cause.getClass().getSimpleName();
}
use of javax.xml.ws.WebFault in project cxf by apache.
the class InternalContextUtils method matchFault.
private static boolean matchFault(Throwable t, FaultInfo fi) {
// REVISIT not sure if this class-based comparison works in general as the fault class defined
// in the service interface has no direct relationship to the message body's type.
MessagePartInfo fmpi = fi.getFirstMessagePart();
Class<?> fiTypeClass = fmpi.getTypeClass();
if (fiTypeClass != null && t.getClass().isAssignableFrom(fiTypeClass)) {
return true;
}
// CXF-6575
QName fiName = fmpi.getConcreteName();
WebFault wf = t.getClass().getAnnotation(WebFault.class);
return wf != null && fiName != null && wf.targetNamespace() != null && wf.targetNamespace().equals(fiName.getNamespaceURI()) && wf.name() != null && wf.name().equals(fiName.getLocalPart());
}
use of javax.xml.ws.WebFault in project cxf by apache.
the class CodeGenTest method testWebFaultAnnotation.
@Test
public void testWebFaultAnnotation() throws Exception {
env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/jms_test_rpc_fault.wsdl"));
env.put(ToolConstants.CFG_SERVICENAME, "HelloWorldService");
// testing some technically invalid fault message formats
env.remove(ToolConstants.CFG_VALIDATE_WSDL);
processor.setContext(env);
processor.execute();
Class<?> cls = classLoader.loadClass("org.apache.cxf.w2j.hello_world_jms.BadRecordLitFault");
WebFault webFault = AnnotationUtil.getPrivClassAnnotation(cls, WebFault.class);
assertEquals("http://www.w3.org/2001/XMLSchema", webFault.targetNamespace());
}
Aggregations