Search in sources :

Example 11 with FaultInfo

use of org.apache.cxf.service.model.FaultInfo in project cxf by apache.

the class URIDomainExpressionTest method mockInfoObjects.

private void mockInfoObjects() {
    si = control.createMock(ServiceInfo.class);
    ei = control.createMock(EndpointInfo.class);
    boi = control.createMock(BindingOperationInfo.class);
    bmi = control.createMock(BindingMessageInfo.class);
    bfi = control.createMock(BindingFaultInfo.class);
    InterfaceInfo ii = control.createMock(InterfaceInfo.class);
    EasyMock.expect(si.getTargetNamespace()).andReturn(TARGET_NAMESPACE).anyTimes();
    EasyMock.expect(si.getName()).andReturn(SERVICE_QNAME).anyTimes();
    EasyMock.expect(si.getInterface()).andReturn(ii).anyTimes();
    EasyMock.expect(ii.getName()).andReturn(INTERFACE_QNAME).anyTimes();
    EasyMock.expect(ei.getName()).andReturn(PORT_QNAME).anyTimes();
    EasyMock.expect(ei.getService()).andReturn(si).anyTimes();
    BindingInfo bi = control.createMock(BindingInfo.class);
    OperationInfo oi = control.createMock(OperationInfo.class);
    EasyMock.expect(boi.getName()).andReturn(OPERATION_QNAME).anyTimes();
    EasyMock.expect(boi.getBinding()).andReturn(bi).anyTimes();
    EasyMock.expect(bi.getName()).andReturn(BINDING_QNAME).anyTimes();
    EasyMock.expect(boi.getOperationInfo()).andReturn(oi).anyTimes();
    EasyMock.expect(oi.getInterface()).andReturn(ii).anyTimes();
    EasyMock.expect(oi.getName()).andReturn(OPERATION_QNAME).anyTimes();
    mi = control.createMock(MessageInfo.class);
    EasyMock.expect(bmi.getMessageInfo()).andReturn(mi).anyTimes();
    EasyMock.expect(mi.getName()).andReturn(MESSAGE_QNAME).anyTimes();
    EasyMock.expect(bmi.getBindingOperation()).andReturn(boi).anyTimes();
    FaultInfo fi = control.createMock(FaultInfo.class);
    bfi = control.createMock(BindingFaultInfo.class);
    EasyMock.expect(bfi.getBindingOperation()).andReturn(boi).anyTimes();
    EasyMock.expect(bfi.getFaultInfo()).andReturn(fi).anyTimes();
    EasyMock.expect(fi.getFaultName()).andReturn(FAULT_QNAME).anyTimes();
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) BindingFaultInfo(org.apache.cxf.service.model.BindingFaultInfo) FaultInfo(org.apache.cxf.service.model.FaultInfo) BindingMessageInfo(org.apache.cxf.service.model.BindingMessageInfo) BindingInfo(org.apache.cxf.service.model.BindingInfo) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) BindingFaultInfo(org.apache.cxf.service.model.BindingFaultInfo) MessageInfo(org.apache.cxf.service.model.MessageInfo) BindingMessageInfo(org.apache.cxf.service.model.BindingMessageInfo)

Example 12 with FaultInfo

use of org.apache.cxf.service.model.FaultInfo in project cxf by apache.

the class Wsdl11AttachmentPolicyProvider method getEffectivePolicy.

public Policy getEffectivePolicy(BindingFaultInfo bfi, Message m) {
    ServiceInfo si = bfi.getBindingOperation().getBinding().getService();
    DescriptionInfo di = si.getDescription();
    Policy p = getElementPolicy(bfi, false, di);
    FaultInfo fi = bfi.getFaultInfo();
    p = mergePolicies(p, getElementPolicy(fi, true, di));
    Extensible ex = getMessageTypeInfo(fi.getName(), di);
    p = mergePolicies(p, getElementPolicy(ex, false, di));
    return p;
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) Policy(org.apache.neethi.Policy) BindingFaultInfo(org.apache.cxf.service.model.BindingFaultInfo) FaultInfo(org.apache.cxf.service.model.FaultInfo) Extensible(org.apache.cxf.service.model.Extensible) DescriptionInfo(org.apache.cxf.service.model.DescriptionInfo)

Example 13 with FaultInfo

use of org.apache.cxf.service.model.FaultInfo in project cxf by apache.

the class OperationProcessor method process.

public void process(JavaInterface intf, OperationInfo operation) throws ToolException {
    JavaMethod method = new MethodMapper().map(operation);
    method.setInterface(intf);
    processMethod(method, operation);
    Collection<FaultInfo> faults = operation.getFaults();
    FaultProcessor faultProcessor = new FaultProcessor(context);
    faultProcessor.process(method, faults);
    method.annotate(new WSActionAnnotator(operation));
    intf.addMethod(method);
}
Also used : FaultInfo(org.apache.cxf.service.model.FaultInfo) WSActionAnnotator(org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal.annotator.WSActionAnnotator) JavaMethod(org.apache.cxf.tools.common.model.JavaMethod) MethodMapper(org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal.mapper.MethodMapper)

Example 14 with FaultInfo

use of org.apache.cxf.service.model.FaultInfo in project cxf by apache.

the class WSActionAnnotator method annotate.

public void annotate(JavaAnnotatable ja) {
    JavaMethod method;
    if (ja instanceof JavaMethod) {
        method = (JavaMethod) ja;
    } else {
        throw new RuntimeException("Action can only annotate JavaMethod");
    }
    boolean required = false;
    JavaInterface intf = method.getInterface();
    MessageInfo inputMessage = operation.getInput();
    MessageInfo outputMessage = operation.getOutput();
    JAnnotation actionAnnotation = new JAnnotation(Action.class);
    if (inputMessage.getExtensionAttributes() != null) {
        String inputAction = getAction(inputMessage);
        if (inputAction != null) {
            actionAnnotation.addElement(new JAnnotationElement("input", inputAction));
            required = true;
        }
    }
    if (outputMessage != null && outputMessage.getExtensionAttributes() != null) {
        String outputAction = getAction(outputMessage);
        if (outputAction != null) {
            actionAnnotation.addElement(new JAnnotationElement("output", outputAction));
            required = true;
        }
    }
    if (operation.hasFaults()) {
        List<JAnnotation> faultAnnotations = new ArrayList<>();
        for (FaultInfo faultInfo : operation.getFaults()) {
            if (faultInfo.getExtensionAttributes() != null) {
                String faultAction = getAction(faultInfo);
                if (faultAction == null) {
                    continue;
                }
                JavaException exceptionClass = getExceptionClass(method, faultInfo);
                if (!StringUtils.isEmpty(exceptionClass.getPackageName()) && !exceptionClass.getPackageName().equals(intf.getPackageName())) {
                    intf.addImport(exceptionClass.getClassName());
                }
                JAnnotation faultAnnotation = new JAnnotation(FaultAction.class);
                faultAnnotation.addElement(new JAnnotationElement("className", exceptionClass));
                faultAnnotation.addElement(new JAnnotationElement("value", faultAction));
                faultAnnotations.add(faultAnnotation);
                required = true;
            }
        }
        actionAnnotation.addElement(new JAnnotationElement("fault", faultAnnotations));
    }
    if (required) {
        method.addAnnotation("Action", actionAnnotation);
    }
}
Also used : JavaInterface(org.apache.cxf.tools.common.model.JavaInterface) FaultInfo(org.apache.cxf.service.model.FaultInfo) JavaException(org.apache.cxf.tools.common.model.JavaException) JAnnotation(org.apache.cxf.tools.common.model.JAnnotation) JAnnotationElement(org.apache.cxf.tools.common.model.JAnnotationElement) ArrayList(java.util.ArrayList) JavaMethod(org.apache.cxf.tools.common.model.JavaMethod) MessageInfo(org.apache.cxf.service.model.MessageInfo)

Example 15 with FaultInfo

use of org.apache.cxf.service.model.FaultInfo in project cxf by apache.

the class CorbaStreamFaultInInterceptor method handleMessage.

public void handleMessage(Message msg) {
    CorbaMessage message = (CorbaMessage) msg;
    try {
        SystemException sysEx = message.getSystemException();
        if (sysEx != null) {
            message.setContent(Exception.class, sysEx);
            return;
        }
        CorbaStreamable exStreamable = message.getStreamableException();
        if (exStreamable != null) {
            DataReader<XMLStreamReader> reader = getDataReader(message);
            BindingOperationInfo bopInfo = message.getExchange().getBindingOperationInfo();
            OperationInfo opInfo = bopInfo.getOperationInfo();
            ServiceInfo service = message.getExchange().getEndpoint().getEndpointInfo().getService();
            org.omg.CORBA.ORB orb = (org.omg.CORBA.ORB) message.get(CorbaConstants.ORB);
            if (orb == null) {
                orb = message.getExchange().get(org.omg.CORBA.ORB.class);
            }
            QName elName = new QName("", exStreamable.getName());
            FaultInfo fault = getFaultInfo(opInfo, elName);
            CorbaTypeEventProducer faultEventProducer = CorbaHandlerUtils.getTypeEventProducer(exStreamable.getObject(), service, orb);
            CorbaStreamReader streamReader = new CorbaStreamReader(faultEventProducer);
            Object e = reader.read(fault.getMessageParts().get(0), streamReader);
            if (!(e instanceof Exception)) {
                Class<?> exClass = fault.getProperty(Class.class.getName(), Class.class);
                if (exClass != null) {
                    Class<?> beanClass = e.getClass();
                    Constructor<?> constructor = exClass.getConstructor(new Class[] { String.class, beanClass });
                    String repId = (message.getStreamableException()._type().id() != null) ? message.getStreamableException()._type().id() : "";
                    e = constructor.newInstance(new Object[] { repId, e });
                } else {
                    // Get the Fault
                    Fault faultEx = (Fault) message.getContent(Exception.class);
                    if (e instanceof Document) {
                        createFaultDetail((Document) e, fault, faultEx);
                    }
                    e = faultEx;
                }
            }
            message.setContent(Exception.class, e);
        }
    } catch (java.lang.Exception ex) {
        LOG.log(Level.SEVERE, "CORBA unmarshalFault exception", ex);
        throw new CorbaBindingException("CORBA unmarshalFault exception", ex);
    }
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) CorbaBindingException(org.apache.cxf.binding.corba.CorbaBindingException) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) FaultInfo(org.apache.cxf.service.model.FaultInfo) XMLStreamReader(javax.xml.stream.XMLStreamReader) Fault(org.apache.cxf.interceptor.Fault) Document(org.w3c.dom.Document) CorbaStreamReader(org.apache.cxf.binding.corba.runtime.CorbaStreamReader) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) SystemException(org.omg.CORBA.SystemException) CorbaTypeEventProducer(org.apache.cxf.binding.corba.types.CorbaTypeEventProducer) CorbaStreamable(org.apache.cxf.binding.corba.CorbaStreamable) CorbaMessage(org.apache.cxf.binding.corba.CorbaMessage) QName(javax.xml.namespace.QName) SystemException(org.omg.CORBA.SystemException) CorbaBindingException(org.apache.cxf.binding.corba.CorbaBindingException)

Aggregations

FaultInfo (org.apache.cxf.service.model.FaultInfo)27 QName (javax.xml.namespace.QName)12 BindingFaultInfo (org.apache.cxf.service.model.BindingFaultInfo)11 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)11 MessagePartInfo (org.apache.cxf.service.model.MessagePartInfo)11 OperationInfo (org.apache.cxf.service.model.OperationInfo)10 MessageInfo (org.apache.cxf.service.model.MessageInfo)8 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)7 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)4 Service (org.apache.cxf.service.Service)3 BindingMessageInfo (org.apache.cxf.service.model.BindingMessageInfo)3 UnwrappedOperationInfo (org.apache.cxf.service.model.UnwrappedOperationInfo)3 Method (java.lang.reflect.Method)2 HashMap (java.util.HashMap)2 BindingFault (javax.wsdl.BindingFault)2 Fault (javax.wsdl.Fault)2 Input (javax.wsdl.Input)2 Output (javax.wsdl.Output)2 XMLStreamReader (javax.xml.stream.XMLStreamReader)2