You are viewing a plain text version of this content. The canonical link for it is here.
Posted to yoko-commits@incubator.apache.org by br...@apache.org on 2007/01/02 20:12:03 UTC

svn commit: r491921 - in /incubator/yoko/trunk/bindings: ./ src/main/java/org/apache/yoko/bindings/corba/ src/main/java/org/apache/yoko/bindings/corba/interceptors/ src/test/java/org/apache/yoko/bindings/corba/ src/test/java/org/apache/yoko/bindings/co...

Author: bravi
Date: Tue Jan  2 12:12:02 2007
New Revision: 491921

URL: http://svn.apache.org/viewvc?view=rev&rev=491921
Log:
[YOKO-170] - Porting exception support in the corba binding. Also, fixed the xsd file prefix (in pom.xml) issue in windows & linux.

Modified:
    incubator/yoko/trunk/bindings/pom.xml
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/ContextUtils.java
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaConduit.java
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaServerConduit.java
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/interceptors/CorbaFaultInInterceptor.java
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/interceptors/CorbaFaultOutInterceptor.java
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/interceptors/CorbaInInterceptor.java
    incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaConduitTest.java
    incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/interceptors/CorbaInInterceptorTest.java

Modified: incubator/yoko/trunk/bindings/pom.xml
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/pom.xml?view=diff&rev=491921&r1=491920&r2=491921
==============================================================================
--- incubator/yoko/trunk/bindings/pom.xml (original)
+++ incubator/yoko/trunk/bindings/pom.xml Tue Jan  2 12:12:02 2007
@@ -33,6 +33,7 @@
     
     <properties>
         <topDirectoryLocation>..</topDirectoryLocation>
+        <file.url.prefix/>
     </properties>         
 
     <dependencies>
@@ -169,7 +170,7 @@
                                     <param name="groupID" expression="3" />
                                 </xslt>
                                 <xslt style="${test.resources.dir}/wsdl/type_test/type_test_wsdl.xsl" in="${test.resources.dir}/wsdl/type_test/type_test.xsd" out="${generated.resources.test}/wsdl/type_test/type_test_corba_inc.wsdl">
-                                    <param name="inc_xsd_path" expression="${generated.resources.test}/wsdl/type_test" />
+                                    <param name="inc_xsd_path" expression="${file.url.prefix}${generated.resources.test}/wsdl/type_test" />
                                     <param name="use_style" expression="document" />
                                     <param name="tns_suffix" expression="corba" />
                                 </xslt>
@@ -320,4 +321,17 @@
         </plugins>
     </build>
     
+    <profiles>
+        <profile>
+             <id>default</id>
+             <activation>
+                 <os>
+                     <family>windows</family>
+                 </os>
+             </activation>
+             <properties>
+                 <file.url.prefix>file:///</file.url.prefix>
+             </properties>
+        </profile>
+    </profiles>
 </project>

Modified: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/ContextUtils.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/ContextUtils.java?view=diff&rev=491921&r1=491920&r2=491921
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/ContextUtils.java (original)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/ContextUtils.java Tue Jan  2 12:12:02 2007
@@ -20,8 +20,11 @@
 
 package org.apache.yoko.bindings.corba;
 
+import javax.xml.stream.XMLEventReader;
 import javax.xml.stream.XMLEventWriter;
 
+import org.apache.cxf.databinding.DataReader;
+import org.apache.cxf.databinding.DataReaderFactory;
 import org.apache.cxf.databinding.DataWriter;
 import org.apache.cxf.databinding.DataWriterFactory;
 import org.apache.cxf.message.Exchange;
@@ -71,6 +74,29 @@
         }
 
         return dataWriter;
+    }
+
+    public static DataReader<XMLEventReader> getDataReader(CorbaMessage message) {
+        Service service = ServiceModelUtil.getService(message.getExchange());
+        DataReaderFactory factory = service.getDataBinding().getDataReaderFactory();
+
+        DataReader<XMLEventReader> dataReader = null;
+        if (factory != null) {
+            for (Class<?> cls : factory.getSupportedFormats()) {
+                if (cls == XMLEventReader.class) {
+                    dataReader = factory.createReader(XMLEventReader.class);
+                    break;
+                }
+            }
+        }
+
+        if (dataReader == null) {
+            //throw a fault
+            //throw new Fault(new org.apache.cxf.common.i18n.Message("NO_DATAREADER", BUNDLE, service
+            //    .getName()));
+        }
+
+        return dataReader;
     }
 
 }

Modified: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaConduit.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaConduit.java?view=diff&rev=491921&r1=491920&r2=491921
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaConduit.java (original)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaConduit.java Tue Jan  2 12:12:02 2007
@@ -28,6 +28,8 @@
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import javax.xml.namespace.QName;
+
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.io.AbstractCachedOutputStream;
 import org.apache.cxf.message.Exchange;
@@ -45,6 +47,8 @@
 import org.apache.schemas.yoko.bindings.corba.OperationType;
 import org.apache.schemas.yoko.bindings.corba.RaisesType;
 import org.apache.schemas.yoko.bindings.corba.TypeMappingType;
+import org.apache.yoko.bindings.corba.types.CorbaHandlerUtils;
+import org.apache.yoko.bindings.corba.types.CorbaObjectHandler;
 import org.apache.yoko.wsdl.CorbaConstants;
 
 import org.omg.CORBA.Any;
@@ -56,6 +60,7 @@
 import org.omg.CORBA.ORB;
 import org.omg.CORBA.Request;
 import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.UnknownUserException;
 
 
 public class CorbaConduit implements Conduit {
@@ -105,12 +110,12 @@
         }
     }
 
-    public void close(Message message) throws IOException {            
+    public void close(Message message) throws IOException {
         BindingOperationInfo boi = message.getExchange().get(BindingOperationInfo.class);
         OperationType opType = boi.getExtensor(OperationType.class);
         
         try {
-            buildRequest((CorbaMessage)message, opType);
+            buildRequest((CorbaMessage)message, opType);            
             message.getContent(OutputStream.class).close();
         } catch (Exception ex) {
             LOG.log(Level.SEVERE, "Could not build the corba request");
@@ -162,8 +167,33 @@
         
         NVList nvlist = getArguments(message);
         NamedValue ret = getReturn(message);
-        ExceptionList exList = getExceptionList(message, opType, typeMaps);     
-        invokeRequest(message, opType.getName(), nvlist, ret, exList);
+        Map<TypeCode, RaisesType> exceptions = getOperationExceptions(opType, typeMaps);
+        ExceptionList exList = getExceptionList(exceptions, message, opType, typeMaps);
+        Request request = getRequest(message, opType.getName(), nvlist, ret, exList);
+        if (request == null) {
+            throw new CorbaBindingException("Couldn't build the corba request");
+        }
+        request.invoke();
+        Exception ex = request.env().exception();
+        if (ex != null) {
+            if (ex instanceof UnknownUserException) {
+                UnknownUserException userEx = (UnknownUserException) ex;
+                Any except = userEx.except;
+                RaisesType raises = exceptions.get(except.type());
+                if (raises == null) {
+                    throw new CorbaBindingException("Couldn't find the exception type code to unmarshall");
+                }
+                QName elName = new QName("", raises.getException().getLocalPart());
+                CorbaObjectHandler handler =
+                    CorbaHandlerUtils.initializeObjectHandler(orb, elName, raises.getException(), typeMaps);
+                
+                CorbaStreamable exStreamable = new CorbaStreamable(handler, elName);
+                exStreamable._read(except.create_input_stream());
+                message.setStreamableException(exStreamable);
+            } else {
+                message.setContent(Exception.class, ex);
+            }
+        }
     }
        
     protected NVList getArguments(CorbaMessage message) {
@@ -201,14 +231,15 @@
         return ret;        
     }
     
-    protected ExceptionList getExceptionList(CorbaMessage message, 
-                                               OperationType opType,
-                                               List<CorbaTypeMap> typeMaps) {
+    protected ExceptionList getExceptionList(Map<TypeCode, RaisesType> exceptions,
+                                             CorbaMessage message, 
+                                             OperationType opType,
+                                             List<CorbaTypeMap> typeMaps) {
         // Get the typecodes for the exceptions this operation can throw.
         // These are defined in the operation definition from WSDL.
         ExceptionList exList = orb.create_exception_list();
 
-        Map<TypeCode, RaisesType> exceptions = getOperationExceptions(opType, typeMaps);        
+               
         if (exceptions != null) {
             Object[] tcs = null;
             tcs = exceptions.keySet().toArray();
@@ -220,20 +251,22 @@
         return exList;
     }
             
-    protected void invokeRequest(CorbaMessage message, String opName,
+    protected Request getRequest(CorbaMessage message,
+                                 String opName,
                                  org.omg.CORBA.NVList nvlist, 
                                  org.omg.CORBA.NamedValue ret, 
                                  org.omg.CORBA.ExceptionList exList) 
         throws Exception {
+        Request request = null;
         ContextList ctxList = orb.create_context_list();
         Context ctx = orb.get_default_context();            
         org.omg.CORBA.Object targetObj = 
             (org.omg.CORBA.Object)message.get(CorbaConstants.CORBA_ENDPOINT_OBJECT);
         if (targetObj != null) {                
-            Request request = targetObj._create_request(ctx, opName, 
-                                                        nvlist, ret, exList, ctxList);                
-            request.invoke();
+            request = targetObj._create_request(ctx, opName, 
+                                                nvlist, ret, exList, ctxList);
         }
+        return request;
     }
         
     protected Map<TypeCode, RaisesType> getOperationExceptions(
@@ -299,9 +332,14 @@
             inMessage.setDestination(destination);
             exchange.put(ORB.class, orb);
             inMessage.setExchange(exchange);
-                        
+            CorbaMessage inCorbaMsg = new CorbaMessage(inMessage);
+            CorbaMessage corbaMsg = (CorbaMessage) message;
+            if (corbaMsg.getStreamableException() != null) {
+                exchange.setInFaultMessage(corbaMsg);
+                inCorbaMsg.setStreamableException(corbaMsg.getStreamableException());                
+            }
             LOG.log(Level.FINE, "incoming observer is " + incomingObserver);
-            incomingObserver.onMessage((Message)inMessage);          
+            incomingObserver.onMessage((Message)inCorbaMsg);          
         }
 
     }

Modified: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaServerConduit.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaServerConduit.java?view=diff&rev=491921&r1=491920&r2=491921
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaServerConduit.java (original)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaServerConduit.java Tue Jan  2 12:12:02 2007
@@ -72,8 +72,6 @@
     }
 
     public void send(Message message) throws IOException {
-        
-        System.out.println("send message...");
         try {
             AddressType address = endpointInfo.getExtensor(AddressType.class);
 
@@ -143,6 +141,9 @@
                     CorbaStreamable exception = msg.getStreamableException();
                     exAny.insert_Streamable(exception);
                     request.set_exception(exAny);
+                    if (msg.getExchange() != null) {
+                        msg.getExchange().setOutFaultMessage(msg);
+                    }
                 } else {
                     CorbaStreamable[] arguments = msg.getStreamableArguments();
                     if (arguments != null) {

Modified: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/interceptors/CorbaFaultInInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/interceptors/CorbaFaultInInterceptor.java?view=diff&rev=491921&r1=491920&r2=491921
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/interceptors/CorbaFaultInInterceptor.java (original)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/interceptors/CorbaFaultInInterceptor.java Tue Jan  2 12:12:02 2007
@@ -19,97 +19,140 @@
 
 package org.apache.yoko.bindings.corba.interceptors;
 
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+
 import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
+
+import java.util.ArrayList;
+import java.util.Iterator;
 import java.util.List;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import javax.xml.namespace.QName;
+
+import javax.xml.stream.XMLEventFactory;
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLEventWriter;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+
 import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.message.Exchange;
+import org.apache.cxf.interceptor.ClientFaultConverter;
+import org.apache.cxf.jaxb.io.EventDataReader;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.phase.AbstractPhaseInterceptor;
 import org.apache.cxf.phase.Phase;
 import org.apache.cxf.service.model.BindingOperationInfo;
+import org.apache.cxf.service.model.FaultInfo;
+import org.apache.cxf.service.model.OperationInfo;
+import org.apache.cxf.service.model.ServiceInfo;
 import org.apache.schemas.yoko.bindings.corba.OperationType;
-import org.apache.schemas.yoko.bindings.corba.RaisesType;
+import org.apache.schemas.yoko.bindings.corba.TypeMappingType;
+import org.apache.yoko.bindings.corba.ContextUtils;
 import org.apache.yoko.bindings.corba.CorbaBindingException;
 import org.apache.yoko.bindings.corba.CorbaMessage;
+import org.apache.yoko.bindings.corba.CorbaStaxObject;
 import org.apache.yoko.bindings.corba.CorbaStreamable;
-import org.apache.yoko.bindings.corba.types.CorbaObjectHandler;
-
-import org.omg.CORBA.ORB;
+import org.apache.yoko.bindings.corba.CorbaTypeMap;
 
+import org.apache.yoko.wsdl.CorbaConstants;
 
 public class CorbaFaultInInterceptor extends AbstractPhaseInterceptor<Message> {
         
     private static final Logger LOG = LogUtils.getL7dLogger(CorbaFaultInInterceptor.class);  
     
+    private XMLOutputFactory xof;
+    private XMLInputFactory xif;
+    private CorbaStaxObject corbaStaxObject;
+
     public CorbaFaultInInterceptor() {
         super();
-        setPhase(Phase.UNMARSHAL);        
-    }
-    
-    public void setOrb(ORB orb) {       
-    }
+        setPhase(Phase.UNMARSHAL);
+        addAfter(ClientFaultConverter.class.getName());
+        corbaStaxObject = new CorbaStaxObject();      
+    }    
 
     public void handleMessage(Message msg) {
         CorbaMessage message = (CorbaMessage)msg;
-    
         try {
-            Exchange exchange = msg.getExchange();
-            BindingOperationInfo boi = exchange.get(BindingOperationInfo.class);
-            OperationType opType = boi.getExtensor(OperationType.class);
-            if (opType == null) {
-                throw new CorbaBindingException("Unable to find operation definition");
-            }
-            List<RaisesType> raises = opType.getRaises();
-            //Method currentMethod = (Method)objContext.get(ObjectMessageContext.METHOD_OBJ);
-            //Class<?>[] methodExs = currentMethod.getExceptionTypes();
-
-            CorbaStreamable streamableEx = message.getStreamableException();
-            CorbaObjectHandler exObject = streamableEx.getObject();
-            String name = exObject.getName().getLocalPart();
-            
-            Class exWrapperCls = null;            
-            for (int i = 0; i < raises.size(); ++i) {
-                // Right now, this assumes that all exceptions will have unique simple names.  REVISIT.
-                RaisesType type = raises.get(i);
-                if (name.equals(raises.get(i).getException().getLocalPart())) {
-                    //exWrapperCls = methodExs[i];
-                    break;
-                }
-            }
-
-            if (exWrapperCls == null) {
-                throw new CorbaBindingException("Unable to locate exception type in " 
-                                                + "declared exception list");
-            }
-
-            try {
-                Method faultInfoMethod = exWrapperCls.getMethod("getFaultInfo");
-                Class<?> exCls = faultInfoMethod.getReturnType();
-                Object yokoEx = exCls.newInstance();
-
-               // CorbaExceptionHandler.unmarshalCorbaException((CorbaExceptionHandler)exObject, yokoEx);
+            CorbaStreamable exStreamable = message.getStreamableException();
+            if (exStreamable != null) {
+                EventDataReader reader = (EventDataReader) ContextUtils.getDataReader(message);
+
+                BindingOperationInfo bopInfo = message.getExchange().get(BindingOperationInfo.class);
+                OperationType opType = bopInfo.getExtensor(OperationType.class);
+                OperationInfo opInfo = bopInfo.getOperationInfo();
                 
-                Constructor exWrapperCtr = exWrapperCls.getConstructor(String.class, exCls);
-                Object exWrapper = exWrapperCtr.newInstance("", yokoEx);
-                Exception exception = new Exception();                
+                List<CorbaTypeMap> typeMaps = new ArrayList<CorbaTypeMap>();
+
+                ServiceInfo service = message.getExchange().get(ServiceInfo.class);
+                List<TypeMappingType> corbaTypes = service.getExtensors(TypeMappingType.class);
+                if (corbaTypes != null) {
+                    corbaStaxObject.setTypeMaps(typeMaps);
+                }
 
-                // the wrapper should always be an instance of throwable
-                //message.setException((Exception)exWrapper);    
+                org.omg.CORBA.ORB orb = (org.omg.CORBA.ORB) message.get(CorbaConstants.ORB);
+                if (orb == null) {
+                    orb = (org.omg.CORBA.ORB) message.getExchange().get(org.omg.CORBA.ORB.class); 
+                }
+                corbaStaxObject.setOrb(orb);
+                QName elName = new QName("", exStreamable.getName());
 
+                XMLInputFactory inputFactory = getXMLInputFactory();
+                XMLOutputFactory outputFactory = getXMLOutputFactory();
                 
-            } catch (java.lang.Exception ex) {
-                // rethrow to be caught below
-                throw ex;
+                ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+                XMLEventWriter evtWriter = outputFactory.createXMLEventWriter(outStream);
+                corbaStaxObject.writeObjectToStax(exStreamable.getObject(),
+                                                  evtWriter,
+                                                  XMLEventFactory.newInstance(),
+                                                  false);
+                evtWriter.flush();
+                ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());
+                XMLEventReader evtReader = inputFactory.createXMLEventReader(inStream);
+                FaultInfo fault = getFaultInfo(opInfo, elName);
+                Object e = reader.read(fault.getMessageParts().get(0), evtReader);
+                if (!(e instanceof Exception)) {
+                    Class exClass = fault.getProperty(Class.class.getName(), Class.class);
+                    Class beanClass = e.getClass();
+                    Constructor constructor =
+                        exClass.getConstructor(new Class[]{String.class, beanClass});
+                    e = constructor.newInstance(new Object[]{"", e});
+                }
+                message.setContent(Exception.class, (Exception) e);
             }
-
         } catch (java.lang.Exception ex) {
             LOG.log(Level.SEVERE, "CORBA unmarshalFault exception", ex);
             throw new CorbaBindingException("CORBA unmarshalFault exception", ex);
         }
 
     }
+
+    protected FaultInfo getFaultInfo(OperationInfo opInfo, QName faultName) {
+        Iterator<FaultInfo> faults = opInfo.getFaults().iterator();
+        while (faults.hasNext()) {
+            FaultInfo fault = faults.next();
+            if (fault.getFaultName().getLocalPart().equals(faultName.getLocalPart())) {
+                return fault;
+            }
+        }
+        return null;
+    }
+
+    protected XMLOutputFactory getXMLOutputFactory() {
+        if (xof == null) {
+            xof = XMLOutputFactory.newInstance();
+            xof.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
+        }
+        return xof;
+    }
+
+    protected XMLInputFactory getXMLInputFactory() {
+        if (xif == null) {
+            xif = XMLInputFactory.newInstance();            
+        }
+        return xif;
+    }        
 }

Modified: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/interceptors/CorbaFaultOutInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/interceptors/CorbaFaultOutInterceptor.java?view=diff&rev=491921&r1=491920&r2=491921
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/interceptors/CorbaFaultOutInterceptor.java (original)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/interceptors/CorbaFaultOutInterceptor.java Tue Jan  2 12:12:02 2007
@@ -21,7 +21,9 @@
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
+import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 import java.util.logging.Level;
@@ -32,23 +34,32 @@
 import javax.xml.stream.XMLEventWriter;
 import javax.xml.stream.XMLInputFactory;
 import javax.xml.stream.XMLOutputFactory;
-import javax.xml.ws.WebFault;
 
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.jaxb.io.EventDataWriter;
-import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.phase.AbstractPhaseInterceptor;
 import org.apache.cxf.phase.Phase;
+import org.apache.cxf.service.model.BindingInfo;
 import org.apache.cxf.service.model.BindingOperationInfo;
+import org.apache.cxf.service.model.FaultInfo;
+import org.apache.cxf.service.model.InterfaceInfo;
+import org.apache.cxf.service.model.MessagePartInfo;
+import org.apache.cxf.service.model.OperationInfo;
+import org.apache.cxf.service.model.ServiceInfo;
 import org.apache.schemas.yoko.bindings.corba.OperationType;
 import org.apache.schemas.yoko.bindings.corba.RaisesType;
+import org.apache.schemas.yoko.bindings.corba.TypeMappingType;
 import org.apache.yoko.bindings.corba.ContextUtils;
 import org.apache.yoko.bindings.corba.CorbaBindingException;
+import org.apache.yoko.bindings.corba.CorbaDestination;
 import org.apache.yoko.bindings.corba.CorbaMessage;
 import org.apache.yoko.bindings.corba.CorbaStaxObject;
 import org.apache.yoko.bindings.corba.CorbaStreamable;
+import org.apache.yoko.bindings.corba.CorbaTypeMap;
+import org.apache.yoko.bindings.corba.CorbaUtils;
 import org.apache.yoko.bindings.corba.types.CorbaObjectHandler;
+import org.apache.yoko.wsdl.CorbaConstants;
 
 public class CorbaFaultOutInterceptor extends AbstractPhaseInterceptor<Message> {
 
@@ -66,29 +77,58 @@
             CorbaMessage message = (CorbaMessage)msg;
             EventDataWriter writer = (EventDataWriter)ContextUtils.getDataWriter(message);
 
+            CorbaDestination destination = null;
+            if (message.getDestination() != null) {
+                destination = (CorbaDestination)message.getDestination();
+            } else {
+                destination = (CorbaDestination)message.getExchange().getDestination();
+            }
+
+            org.omg.CORBA.ORB orb = (org.omg.CORBA.ORB) message.get(CorbaConstants.ORB);
+            if (orb == null) {
+                orb = (org.omg.CORBA.ORB) message.getExchange().get(org.omg.CORBA.ORB.class); 
+            }
+            corbaStaxObject.setOrb(orb);
+
+            List<CorbaTypeMap> typeMaps = new ArrayList<CorbaTypeMap>();                
+            ServiceInfo service = destination.getBindingInfo().getService();        
+            List<TypeMappingType> corbaTypes = service.getExtensors(TypeMappingType.class);
+            if (corbaTypes != null) {
+                CorbaUtils.createCorbaTypeMap(typeMaps, corbaTypes);
+                corbaStaxObject.setTypeMaps(typeMaps);
+            }
+
+            Throwable ex = message.getContent(Exception.class);
+            ex = ex.getCause();
+            if (ex instanceof InvocationTargetException) {
+                ex = ex.getCause();
+            }
+
             // Get information about the operation being invoked from the WSDL
             // definition.
             // We need this to marshal data correctly
-            Exchange exchange = msg.getExchange();
-            BindingOperationInfo boi = exchange.get(BindingOperationInfo.class);
-            OperationType opType = boi.getExtensor(OperationType.class);
+
+            BindingInfo bInfo = destination.getBindingInfo();
+            InterfaceInfo info = bInfo.getInterface();        
+        
+            String opName = message.getExchange().get(String.class);
+                
+            Iterator iter = bInfo.getOperations().iterator();
+
+            BindingOperationInfo bopInfo = null;
+            OperationType opType = null;           
+            while (iter.hasNext()) {
+                bopInfo = (BindingOperationInfo)iter.next();
+                if (bopInfo.getName().getLocalPart().equals(opName)) {
+                    opType = bopInfo.getExtensor(OperationType.class);
+                    break;
+                }
+            }
             if (opType == null) {
                 throw new CorbaBindingException("Unable to find operation definition");
             }
 
-            XMLInputFactory inputFactory = XMLInputFactory.newInstance();
-            XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
-            outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
-
-            Throwable except = new Throwable();
-            Method faultInfoMethod = except.getClass().getMethod("getFaultInfo");
-            Object faultInfo = faultInfoMethod.invoke(except);
-            WebFault wfAnnotation = except.getClass().getAnnotation(WebFault.class);
-            QName elName = new QName(wfAnnotation.targetNamespace(), except.getClass().getSimpleName());
-
-            ByteArrayOutputStream outStream = new ByteArrayOutputStream();
-            XMLEventWriter evtWriter = outputFactory.createXMLEventWriter(outStream);
-            writer.write(faultInfo, evtWriter);
+            OperationInfo opInfo = bopInfo.getOperationInfo();
 
             QName exIdlType = null;
             List<RaisesType> exList = opType.getRaises();
@@ -97,29 +137,66 @@
                 // be unique. We should make
                 // sure that this is really the case.
                 RaisesType raises = i.next();
-                if (raises.getException().getLocalPart().equals(elName.getLocalPart())) {
+
+                if (raises.getException().getLocalPart().equals(ex.getClass().getSimpleName())) {
                     exIdlType = raises.getException();
+                    break;
                 }
             }
-            if (exIdlType == null) {
-                LOG.log(Level.INFO,
-                        "Could not find the exception in the raises list.  Must be a system exception.");
-                // This could be a system exception?
-            } else {
-                LOG.log(Level.INFO, "Found exception in the raises list.  Marshalling.");
-                ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());
-                XMLEventReader evtReader = inputFactory.createXMLEventReader(inStream);
-                CorbaObjectHandler obj = corbaStaxObject.readObjectFromStax(evtReader, exIdlType, false);
-                CorbaStreamable streamable = new CorbaStreamable(obj, elName);
-                message.setStreamableException(streamable);
+
+            if (exIdlType != null) {
+                setUserException(message, ex, exIdlType, opInfo, writer);
             }
 
         } catch (java.lang.Exception ex) {
-            LOG.log(Level.SEVERE, "CORBA marshalFault exception", ex);
-            // TODO: Throw a exception proper exception once implemented
-            throw new CorbaBindingException("Method unmarshalFault not implemented");
+            LOG.log(Level.SEVERE, "CORBA marshal fault exception", ex);
+            throw new CorbaBindingException("Marshal fault failed", ex);
         }
 
-    }                                
+    }
+
+    protected void setUserException(CorbaMessage message,
+                                    Throwable ex,
+                                    QName exIdlType,
+                                    OperationInfo opInfo,
+                                    EventDataWriter writer)
+        throws Exception {
+        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);
+
+        XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+        XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
+        outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
+
+        ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+        XMLEventWriter evtWriter = outputFactory.createXMLEventWriter(outStream);
+        writer.write(fault, faultPart, evtWriter);
+        LOG.log(Level.INFO, "Found exception in the raises list.  Marshalling.");
+        ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());
+        XMLEventReader evtReader = inputFactory.createXMLEventReader(inStream);
+        CorbaObjectHandler obj = corbaStaxObject.readObjectFromStax(evtReader, exIdlType, false);
+        CorbaStreamable streamable = new CorbaStreamable(obj, elName);
+        message.setStreamableException(streamable);
+    }
+
+    protected MessagePartInfo getFaultMessagePartInfo(OperationInfo opInfo, QName faultName) {
+        Iterator<FaultInfo> faults = opInfo.getFaults().iterator();
+        while (faults.hasNext()) {
+            FaultInfo fault = faults.next();
+            if (fault.getFaultName().getLocalPart().equals(faultName.getLocalPart())) {
+                return fault.getMessageParts().get(0);
+            }
+        }
+        return null;
+    }
     
 }

Modified: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/interceptors/CorbaInInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/interceptors/CorbaInInterceptor.java?view=diff&rev=491921&r1=491920&r2=491921
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/interceptors/CorbaInInterceptor.java (original)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/interceptors/CorbaInInterceptor.java Tue Jan  2 12:12:02 2007
@@ -34,8 +34,7 @@
 import javax.xml.stream.XMLOutputFactory;
 import javax.xml.ws.Holder;
 
-import org.apache.cxf.databinding.DataReader;
-import org.apache.cxf.databinding.DataReaderFactory;
+import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.jaxb.JAXBUtils;
 import org.apache.cxf.jaxb.WrapperHelper;
@@ -44,7 +43,6 @@
 import org.apache.cxf.message.Message;
 import org.apache.cxf.phase.AbstractPhaseInterceptor;
 import org.apache.cxf.phase.Phase;
-import org.apache.cxf.service.Service;
 import org.apache.cxf.service.model.BindingInfo;
 import org.apache.cxf.service.model.BindingOperationInfo;
 import org.apache.cxf.service.model.EndpointInfo;
@@ -53,7 +51,6 @@
 import org.apache.cxf.service.model.MessagePartInfo;
 import org.apache.cxf.service.model.OperationInfo;
 import org.apache.cxf.service.model.ServiceInfo;
-import org.apache.cxf.service.model.ServiceModelUtil;
 import org.apache.cxf.ws.addressing.EndpointReferenceType;
 import org.apache.schemas.yoko.bindings.corba.ArgType;
 import org.apache.schemas.yoko.bindings.corba.ModeType;
@@ -90,12 +87,13 @@
     }
     
     public void setOrb(ORB mOrb) {
-        this.orb = mOrb;
+        orb = mOrb;
     }
 
     public void handleMessage(Message msg) {
         try {
-            CorbaMessage message = (CorbaMessage) msg;                
+            CorbaMessage message = (CorbaMessage) msg;
+               
             CorbaDestination destination = null;
             if (message.getDestination() != null) {
                 destination = (CorbaDestination)message.getDestination();
@@ -133,8 +131,8 @@
         OperationType opType = null;
         BindingInfo bInfo = destination.getBindingInfo();              
         InterfaceInfo info = bInfo.getInterface();        
-        EventDataReader reader = (EventDataReader)getDataReader(message);
-        
+        EventDataReader reader = (EventDataReader) ContextUtils.getDataReader(message);
+         
         Exchange exchange = message.getExchange();
         orb = (ORB)exchange.get(ORB.class);        
         if (corbaStaxObject != null) {
@@ -187,9 +185,18 @@
             corbaStaxObject.setOrb(orb);
         } else {
             corbaStaxObject = new CorbaStaxObject(orb);
-        }        
+        }
+        if (message.getStreamableException() != null) {
+            Endpoint ep = message.getExchange().get(Endpoint.class);
+            message.getInterceptorChain().abort();
+            if (ep.getInFaultObserver() != null) {
+                ep.getInFaultObserver().onMessage(message);
+                return;
+            }
+        }
+
         EventDataReader reader;
-        reader = (EventDataReader)getDataReader(message);
+        reader = (EventDataReader) ContextUtils.getDataReader(message);
         BindingInfo bInfo = destination.getBindingInfo();              
         InterfaceInfo info = bInfo.getInterface();
         
@@ -499,29 +506,6 @@
         }
         return xif;
     }        
-    
-    protected DataReader<XMLEventReader> getDataReader(CorbaMessage message) {
-        Service service = ServiceModelUtil.getService(message.getExchange());
-        DataReaderFactory factory = service.getDataBinding().getDataReaderFactory();
-
-        DataReader<XMLEventReader> dataReader = null;
-        if (factory != null) {
-            for (Class<?> cls : factory.getSupportedFormats()) {
-                if (cls == XMLEventReader.class) {
-                    dataReader = factory.createReader(XMLEventReader.class);
-                    break;
-                }
-            }
-        }
-
-        if (dataReader == null) {
-            //throw a fault
-            //throw new Fault(new org.apache.cxf.common.i18n.Message("NO_DATAREADER", BUNDLE, service
-            //    .getName()));
-        }
-
-        return dataReader;
-    }    
 
     protected MessagePartInfo getMessagePartInfo(MessageInfo msgInfo,
                                                  int index,

Modified: incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaConduitTest.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaConduitTest.java?view=diff&rev=491921&r1=491920&r2=491921
==============================================================================
--- incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaConduitTest.java (original)
+++ incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaConduitTest.java Tue Jan  2 12:12:02 2007
@@ -217,6 +217,7 @@
         ServiceInfo service = control.createMock(ServiceInfo.class);
         EasyMock.expect(exchange.get(ServiceInfo.class)).andReturn(service);
         List<CorbaTypeMap> list = control.createMock(List.class);
+        List<CorbaTypeMap> typeMaps = control.createMock(List.class);
         EasyMock.expect(service.getExtensors(CorbaTypeMap.class)).andReturn(list);                
         
         OperationType opType = control.createMock(OperationType.class);
@@ -224,10 +225,13 @@
         EasyMock.expectLastCall().andReturn(null);  
         conduit.getReturn(message);
         EasyMock.expectLastCall().andReturn(null);
-        conduit.getExceptionList(message, opType, list);
+        conduit.getExceptionList(conduit.getOperationExceptions(opType, typeMaps),
+                                 message,
+                                 opType,
+                                 list);
         EasyMock.expectLastCall().andReturn(null);
         
-        conduit.invokeRequest(message, "Hello", null, null, null);
+	conduit.getRequest(message, "Hello", null, null, null);
         EasyMock.expectLastCall();
     }
     
@@ -283,7 +287,10 @@
         List<CorbaTypeMap> typeMaps = new ArrayList<CorbaTypeMap>();
         OperationType opType = new OperationType();
         opType.setName("review_data");
-        ExceptionList exList = conduit.getExceptionList(message, opType, typeMaps);
+        ExceptionList exList = conduit.getExceptionList(conduit.getOperationExceptions(opType, typeMaps),
+                                                        message,
+                                                        opType,
+                                                        typeMaps);
         assertNotNull("ExcepitonList is not null", exList != null);
         assertEquals("The list should be empty", exList.count(), 0);        
     }
@@ -305,7 +312,10 @@
             CorbaUtils.createCorbaTypeMap(typeMaps, corbaTypes);
         }
         
-        ExceptionList exList = conduit.getExceptionList(message, opType, typeMaps);
+        ExceptionList exList = conduit.getExceptionList(conduit.getOperationExceptions(opType, typeMaps),
+                                                        message,
+                                                        opType,
+                                                        typeMaps);
         
         assertNotNull("ExcepitonList is not null", exList != null);
         assertNotNull("TypeCode is not null", exList.item(0) != null);
@@ -324,7 +334,9 @@
         /*String opName = "GreetMe";
         NVList nvlist = (NVList)orb.create_list(0);
         
-        conduit.invokeRequest(message, "GreetMe", nvlist, null, null);*/   
+        Request request = conduit.getRequest(message, "GreetMe", nvlist, null, null);
+        request.invoke();
+        */   
         
         org.omg.CORBA.Object obj = control.createMock(org.omg.CORBA.Object.class); 
         EasyMock.expect(message.get(CorbaConstants.CORBA_ENDPOINT_OBJECT)).andReturn(obj);
@@ -345,7 +357,8 @@
         EasyMock.expectLastCall();
         
         control.replay();
-        conduit.invokeRequest(message, "greetMe", nvList, ret, exList);
+        Request request = conduit.getRequest(message, "greetMe", nvList, ret, exList);
+        request.invoke();
         control.verify();
         
           /* try {

Modified: incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/interceptors/CorbaInInterceptorTest.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/interceptors/CorbaInInterceptorTest.java?view=diff&rev=491921&r1=491920&r2=491921
==============================================================================
--- incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/interceptors/CorbaInInterceptorTest.java (original)
+++ incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/interceptors/CorbaInInterceptorTest.java Tue Jan  2 12:12:02 2007
@@ -246,9 +246,7 @@
         control.verify();           
        }
     
-    public void testHandleRequestMessage() throws Exception {        
-        Method m = CorbaInInterceptor.class.getDeclaredMethod("getDataReader", 
-                                   new Class[] {CorbaMessage.class});        
+    public void testHandleRequestMessage() throws Exception {    
         Method m2 = CorbaInInterceptor.class.getDeclaredMethod("writeReturnValue", 
                                    new Class[] {CorbaMessage.class, 
                                                 CorbaMessage.class,
@@ -258,7 +256,7 @@
                     new Class[] {CorbaMessage.class, CorbaMessage.class, List.class, 
                         InterfaceInfo.class, OperationType.class, EventDataReader.class});                                                                                                                    
         CorbaInInterceptor inInterceptor = 
-            control.createMock(CorbaInInterceptor.class, new Method[] {m, m2, m3});
+            control.createMock(CorbaInInterceptor.class, new Method[] {m2, m3});
         
         CorbaDestination destination = control.createMock(CorbaDestination.class);
         BindingInfo bInfo = control.createMock(BindingInfo.class);
@@ -389,24 +387,5 @@
         List<Object> args = message.getContent(List.class);
         assertNotNull("args should exist and be empty", args !=  null);
     }
-    
-    
-    public void testGetDataReader() throws Exception {        
-        
-        CorbaInInterceptor inInterceptor = new CorbaInInterceptor();        
-        CorbaMessage message = control.createMock(CorbaMessage.class);
-        Exchange exchange = control.createMock(Exchange.class);
-        Service service = control.createMock(Service.class);
-        DataBinding databinding = control.createMock(DataBinding.class);        
-        
-        EasyMock.expect(message.getExchange()).andReturn(exchange);
-        EasyMock.expect(ServiceModelUtil.getService(exchange)).andReturn(service);
-        EasyMock.expect(service.getDataBinding()).andReturn(databinding);
-        EasyMock.expect(databinding.getDataReaderFactory()).andReturn(null);
-        
-        control.replay();
-        inInterceptor.getDataReader(message);
-        control.verify();                
-    }
-        
+               
 }