Search in sources :

Example 1 with CorbaFaultStreamWriter

use of org.apache.cxf.binding.corba.runtime.CorbaFaultStreamWriter in project cxf by apache.

the class CorbaStreamFaultOutInterceptor method setUserExceptionFromFaultDetail.

protected void setUserExceptionFromFaultDetail(CorbaMessage message, org.w3c.dom.Element faultDetail, RaisesType exType, OperationInfo opInfo, DataWriter<XMLStreamWriter> writer, ServiceInfo service) throws Exception {
    QName exIdlType = exType.getException();
    QName elName = new QName("", exIdlType.getLocalPart());
    MessagePartInfo faultPart = getFaultMessagePartInfo(opInfo, elName);
    // faultDetailt.getFirstChild() skips the "detail" element
    Object fault = extractPartsInfoFromDetail((Element) faultDetail.getFirstChild(), exType);
    CorbaFaultStreamWriter faultWriter = new CorbaFaultStreamWriter(orb, exType, message.getCorbaTypeMap(), service);
    writer.write(fault, faultPart, faultWriter);
    CorbaObjectHandler[] objs = faultWriter.getCorbaObjects();
    CorbaStreamable streamable = message.createStreamableObject(objs[0], elName);
    message.setStreamableException(streamable);
}
Also used : CorbaStreamable(org.apache.cxf.binding.corba.CorbaStreamable) QName(javax.xml.namespace.QName) CorbaFaultStreamWriter(org.apache.cxf.binding.corba.runtime.CorbaFaultStreamWriter) CorbaObjectHandler(org.apache.cxf.binding.corba.types.CorbaObjectHandler) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo)

Example 2 with CorbaFaultStreamWriter

use of org.apache.cxf.binding.corba.runtime.CorbaFaultStreamWriter in project cxf by apache.

the class CorbaStreamFaultOutInterceptor method setUserException.

protected void setUserException(CorbaMessage message, Throwable ex, RaisesType exType, OperationInfo opInfo, DataWriter<XMLStreamWriter> writer, ServiceInfo service) throws Exception {
    QName exIdlType = exType.getException();
    QName elName = new QName("", exIdlType.getLocalPart());
    MessagePartInfo faultPart = getFaultMessagePartInfo(opInfo, elName);
    if (faultPart == null) {
        throw new CorbaBindingException("Coulnd't find the message fault part : " + elName);
    }
    Method faultMethod = ex.getClass().getMethod("getFaultInfo");
    if (faultMethod == null) {
        return;
    }
    Object fault = faultMethod.invoke(ex);
    // one has not been created on the servant side which throws the UserException.
    if (fault == null) {
        Class<?> faultClass = faultMethod.getReturnType();
        fault = faultClass.newInstance();
    }
    CorbaFaultStreamWriter faultWriter = new CorbaFaultStreamWriter(orb, exType, message.getCorbaTypeMap(), service);
    writer.write(fault, faultPart, faultWriter);
    CorbaObjectHandler[] objs = faultWriter.getCorbaObjects();
    CorbaStreamable streamable = message.createStreamableObject(objs[0], elName);
    message.setStreamableException(streamable);
}
Also used : CorbaBindingException(org.apache.cxf.binding.corba.CorbaBindingException) CorbaStreamable(org.apache.cxf.binding.corba.CorbaStreamable) QName(javax.xml.namespace.QName) CorbaFaultStreamWriter(org.apache.cxf.binding.corba.runtime.CorbaFaultStreamWriter) CorbaObjectHandler(org.apache.cxf.binding.corba.types.CorbaObjectHandler) Method(java.lang.reflect.Method) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo)

Aggregations

QName (javax.xml.namespace.QName)2 CorbaStreamable (org.apache.cxf.binding.corba.CorbaStreamable)2 CorbaFaultStreamWriter (org.apache.cxf.binding.corba.runtime.CorbaFaultStreamWriter)2 CorbaObjectHandler (org.apache.cxf.binding.corba.types.CorbaObjectHandler)2 MessagePartInfo (org.apache.cxf.service.model.MessagePartInfo)2 Method (java.lang.reflect.Method)1 CorbaBindingException (org.apache.cxf.binding.corba.CorbaBindingException)1