cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t..@apache.org
Subject svn commit: r466021 - in /incubator/cxf/trunk: rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/interceptor/ rt/core/src/main/java/org/apache/cxf/interceptor/ rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/ systests/src/test/java/...
Date Fri, 20 Oct 2006 07:37:18 GMT
Author: tli
Date: Fri Oct 20 00:37:14 2006
New Revision: 466021

URL: http://svn.apache.org/viewvc?view=rev&rev=466021
Log:
support fault processing of rpc binding style

Modified:
    incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/interceptor/Messages.properties
    incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/interceptor/XMLFaultInInterceptor.java
    incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/interceptor/XMLFaultOutInterceptor.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/ClientFaultConverter.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java

Modified: incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/interceptor/Messages.properties
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/interceptor/Messages.properties?view=diff&rev=466021&r1=466020&r2=466021
==============================================================================
--- incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/interceptor/Messages.properties
(original)
+++ incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/interceptor/Messages.properties
Fri Oct 20 00:37:14 2006
@@ -25,6 +25,7 @@
 NO_OPERATION=No such operation: {0}
 NO_DATAREADER=No DataReader is available for Service: {0}
 NO_DATAWRITER=No DataWriter is available for Service: {0}
+UNKNOWN_EXCEPTION=Could not recogonize exception type: {0}
 COULD_NOT_UNRWAP=Could not unrwap message parts.
 REQ_NOT_UNDERSTOOD=Could not read request. Operation {0} is unknown.
 ILLEAGAL_XMLFAULT_FORMAT=Illeagal xml fault message format.

Modified: incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/interceptor/XMLFaultInInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/interceptor/XMLFaultInInterceptor.java?view=diff&rev=466021&r1=466020&r2=466021
==============================================================================
--- incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/interceptor/XMLFaultInInterceptor.java
(original)
+++ incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/interceptor/XMLFaultInInterceptor.java
Fri Oct 20 00:37:14 2006
@@ -59,7 +59,9 @@
             }
             String exMessage = reader.getElementText();
             Fault fault = new XMLFault(exMessage);
-            reader.next();
+            while (!StaxUtils.toNextElement(reader)) {
+                StaxUtils.nextEvent(reader);
+            }
             if (StaxUtils.toNextElement(reader)) {
                 // handling detail
                 Element detail = StaxUtils.read(new FragmentStreamReader(reader)).getDocumentElement();

Modified: incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/interceptor/XMLFaultOutInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/interceptor/XMLFaultOutInterceptor.java?view=diff&rev=466021&r1=466020&r2=466021
==============================================================================
--- incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/interceptor/XMLFaultOutInterceptor.java
(original)
+++ incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/interceptor/XMLFaultOutInterceptor.java
Fri Oct 20 00:37:14 2006
@@ -78,7 +78,9 @@
                 FaultInfo fi = it.next();
                 for (MessagePartInfo mpi : fi.getMessageParts()) {
                     Class cls = mpi.getProperty(Class.class.getName(), Class.class);
-                    if (cls != null && cls.equals(t.getClass())) {
+                    Method method = t.getClass().getMethod("getFaultInfo", new Class[0]);
+                    Class sub = method.getReturnType();
+                    if (cls != null && cls.equals(sub)) {
                         if (mpi.isElement()) {
                             elName = mpi.getElementQName();
                         } else {
@@ -113,6 +115,8 @@
             
             writer.flush();
 
+        } catch (NoSuchMethodException ne) {
+            throw new Fault(new org.apache.cxf.common.i18n.Message("UNKNOWN_EXCEPTION", BUNDLE),
ne);        
         } catch (XMLStreamException xe) {
             throw new Fault(new org.apache.cxf.common.i18n.Message("XML_WRITE_EXC", BUNDLE),
xe);
         }

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/ClientFaultConverter.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/ClientFaultConverter.java?view=diff&rev=466021&r1=466020&r2=466021
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/ClientFaultConverter.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/ClientFaultConverter.java
Fri Oct 20 00:37:14 2006
@@ -42,14 +42,14 @@
  * @author Dan Diephouse
  */
 public class ClientFaultConverter extends AbstractPhaseInterceptor<Message> {
-    
+
     public ClientFaultConverter() {
         super();
         setPhase(Phase.UNMARSHAL);
     }
 
     public void handleMessage(Message msg) {
-        Fault fault = (Fault)msg.getContent(Exception.class);
+        Fault fault = (Fault) msg.getContent(Exception.class);
 
         if (fault.getDetail() != null) {
             processFaultDetail(fault, msg);
@@ -57,52 +57,54 @@
     }
 
     protected void processFaultDetail(Fault fault, Message msg) {
-        Element exDetail = (Element)DOMUtils.getChild(fault.getDetail(), Node.ELEMENT_NODE);
+        Element exDetail = (Element) DOMUtils.getChild(fault.getDetail(), Node.ELEMENT_NODE);
         QName qname = new QName(exDetail.getNamespaceURI(), exDetail.getLocalName());
+        FaultInfo faultWanted = null;        
+        Class cls = null;
+        BindingOperationInfo boi = msg.getExchange().get(BindingOperationInfo.class);
+        for (FaultInfo faultInfo : boi.getOperationInfo().getFaults()) {
+            for (MessagePartInfo mpi : faultInfo.getMessageParts()) {
+                String ns = null;
+                if (mpi.isElement()) {
+                    ns = mpi.getElementQName().getNamespaceURI();
+                } else {
+                    ns = mpi.getTypeQName().getNamespaceURI();
+                }
+                if (qname.getLocalPart().equals(mpi.getConcreteName().getLocalPart()) 
+                        && qname.getNamespaceURI().equals(ns)) {
+                    cls = (Class)mpi.getProperty(Class.class.getName());
+                    faultWanted = faultInfo;
+                    break;
+                }
+            }
+            if (faultWanted != null) {
+                break;
+            }
+        }
 
-        FaultInfo faultInfo = getFaultInfo(msg.getExchange().get(BindingOperationInfo.class),
-                                           qname,
-                                           exDetail);
-        if (faultInfo == null) {
+        if (faultWanted == null) {
             return;
         }
-        
+
         Service s = msg.getExchange().get(Service.class);
         DataBinding dataBinding = s.getDataBinding();
-        
+
         DataReader<Node> reader = dataBinding.getDataReaderFactory().createReader(Node.class);
-        Object e = reader.read(exDetail);
-        
+        Object e = reader.read(qname, exDetail, cls);
+
         if (!(e instanceof Exception)) {
-            Class exClass = faultInfo.getProperty(Class.class.getName(), Class.class);
+            Class exClass = faultWanted.getProperty(Class.class.getName(), Class.class);
             Class beanClass = e.getClass();
 
             try {
-                Constructor constructor = exClass.getConstructor(new Class[] {String.class,
-                                                                              beanClass});
-                e = constructor.newInstance(new Object[] {fault.getMessage(), e});
+                Constructor constructor = exClass.getConstructor(new Class[]{String.class,
beanClass});
+                e = constructor.newInstance(new Object[]{fault.getMessage(), e});
             } catch (Exception e1) {
                 throw new Fault(e1);
             }
         }
 
         msg.setContent(Exception.class, e);
-    }
-
-    protected FaultInfo getFaultInfo(BindingOperationInfo operation, 
-                                     QName qname,
-                                     Element exDetail) {
-        
-        for (FaultInfo faultInfo : operation.getOperationInfo().getFaults()) {
-
-            for (MessagePartInfo mpi : faultInfo.getMessageParts()) {
-                if (qname.equals(mpi.getConcreteName())) {
-                    return faultInfo;
-                }
-            }
-        }
-
-        return null;
     }
 
 }

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java?view=diff&rev=466021&r1=466020&r2=466021
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
Fri Oct 20 00:37:14 2006
@@ -178,9 +178,22 @@
             
             for (FaultInfo fi : o.getFaults()) {
                 for (MessagePartInfo mpi : fi.getMessageParts()) {
-                    if (mpi.getConcreteName().equals(name)) {
-                        fi.setProperty(Class.class.getName(), exClass);
-                        mpi.setProperty(Class.class.getName(), beanClass);
+                    String ns = null;
+                    if (mpi.isElement()) {
+                        ns = mpi.getElementQName().getNamespaceURI();
+                    } else {
+                        ns = mpi.getTypeQName().getNamespaceURI();
+                    }
+                    if (mpi.getConcreteName().getLocalPart().equals(name.getLocalPart())

+                            && name.getNamespaceURI().equals(ns)) {
+                        try {
+                            Method method = beanClass.getMethod("getFaultInfo", new Class[0]);
+                            Class sub = method.getReturnType();
+                            fi.setProperty(Class.class.getName(), exClass);
+                            mpi.setProperty(Class.class.getName(), sub);
+                        } catch (NoSuchMethodException nsme) {
+                            nsme.printStackTrace();
+                        }
                     }
                 }
             }

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java?view=diff&rev=466021&r1=466020&r2=466021
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java
Fri Oct 20 00:37:14 2006
@@ -31,14 +31,14 @@
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
-//import org.apache.cxf.hello_world_jms.BadRecordLitFault;
+import org.apache.cxf.hello_world_jms.BadRecordLitFault;
 import org.apache.cxf.hello_world_jms.HelloWorldOneWayPort;
 import org.apache.cxf.hello_world_jms.HelloWorldOneWayQueueService;
 import org.apache.cxf.hello_world_jms.HelloWorldPortType;
 import org.apache.cxf.hello_world_jms.HelloWorldPubSubPort;
 import org.apache.cxf.hello_world_jms.HelloWorldPubSubService;
 import org.apache.cxf.hello_world_jms.HelloWorldService;
-//import org.apache.cxf.hello_world_jms.NoSuchCodeLitFault;
+import org.apache.cxf.hello_world_jms.NoSuchCodeLitFault;
 import org.apache.cxf.systest.common.ClientServerSetupBase;
 import org.apache.cxf.systest.common.ClientServerTestBase;
 import org.apache.cxf.transport.jms.JMSConstants;
@@ -134,7 +134,7 @@
                 assertNotNull("no response received from service", reply);
                 assertEquals(response2, reply);
                 
-                /*try {
+                try {
                     greeter.testRpcLitFault("BadRecordLitFault");
                     fail("Should have thrown BadRecoedLitFault");
                 } catch (BadRecordLitFault ex) {
@@ -147,7 +147,7 @@
                 } catch (NoSuchCodeLitFault nslf) {
                     assertNotNull(nslf.getFaultInfo());
                     assertNotNull(nslf.getFaultInfo().getCode());
-                } */
+                } 
             }
         } catch (UndeclaredThrowableException ex) {
             throw (Exception)ex.getCause();



Mime
View raw message