Search in sources :

Example 11 with WebFault

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();
}
Also used : WebFault(javax.xml.ws.WebFault) SoapFault(org.apache.cxf.binding.soap.SoapFault) Fault(org.apache.cxf.interceptor.Fault) WebFault(javax.xml.ws.WebFault) IOException(java.io.IOException)

Example 12 with WebFault

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());
}
Also used : WebFault(javax.xml.ws.WebFault) QName(javax.xml.namespace.QName) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo)

Example 13 with WebFault

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());
}
Also used : WebFault(javax.xml.ws.WebFault) AbstractCodeGenTest(org.apache.cxf.tools.wsdlto.AbstractCodeGenTest) Test(org.junit.Test)

Aggregations

WebFault (javax.xml.ws.WebFault)13 QName (javax.xml.namespace.QName)8 IOException (java.io.IOException)3 Method (java.lang.reflect.Method)3 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)3 Fault (org.apache.cxf.interceptor.Fault)3 MessagePartInfo (org.apache.cxf.service.model.MessagePartInfo)3 AbstractCodeGenTest (org.apache.cxf.tools.wsdlto.AbstractCodeGenTest)3 Test (org.junit.Test)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 JAXBElement (javax.xml.bind.JAXBElement)2 SOAPException (javax.xml.soap.SOAPException)2 XMLStreamWriter (javax.xml.stream.XMLStreamWriter)2 RuntimeCamelException (org.apache.camel.RuntimeCamelException)2 SoapFault (org.apache.cxf.binding.soap.SoapFault)2 FaultMode (org.apache.cxf.message.FaultMode)2 OperationInfo (org.apache.cxf.service.model.OperationInfo)2 File (java.io.File)1 Locale (java.util.Locale)1 Schema (javax.xml.validation.Schema)1