cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t..@apache.org
Subject svn commit: r467247 - in /incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml: XMLBindingFactory.java interceptor/XMLFaultInInterceptor.java interceptor/XMLFaultOutInterceptor.java
Date Tue, 24 Oct 2006 05:43:21 GMT
Author: tli
Date: Mon Oct 23 22:43:20 2006
New Revision: 467247

URL: http://svn.apache.org/viewvc?view=rev&rev=467247
Log:
add handling for xml fault not raised by SEI Impl

Modified:
    incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/XMLBindingFactory.java
    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

Modified: incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/XMLBindingFactory.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/XMLBindingFactory.java?view=diff&rev=467247&r1=467246&r2=467247
==============================================================================
--- incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/XMLBindingFactory.java
(original)
+++ incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/XMLBindingFactory.java
Mon Oct 23 22:43:20 2006
@@ -78,7 +78,6 @@
         xb.getInInterceptors().add(new StaxInInterceptor());
         xb.getInInterceptors().add(new XMLMessageInInterceptor());
         
-        xb.getInFaultInterceptors().add(new StaxInInterceptor());
         xb.getInFaultInterceptors().add(new XMLFaultInInterceptor());
         
         xb.getOutInterceptors().add(new StaxOutInterceptor());

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=467247&r1=467246&r2=467247
==============================================================================
--- 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
Mon Oct 23 22:43:20 2006
@@ -52,16 +52,14 @@
         XMLStreamReader xsr = message.getContent(XMLStreamReader.class);
         DepthXMLStreamReader reader = new DepthXMLStreamReader(xsr);
 
-        try {
+        try {            
             reader.nextTag();
             if (!StaxUtils.toNextElement(reader)) {
                 throw new Fault(new org.apache.cxf.common.i18n.Message("ILLEAGAL_XMLFAULT_FORMAT",
BUNDLE));
             }
             String exMessage = reader.getElementText();
             Fault fault = new XMLFault(exMessage);
-            while (!StaxUtils.toNextElement(reader)) {
-                StaxUtils.nextEvent(reader);
-            }
+            reader.nextTag();
             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=467247&r1=467246&r2=467247
==============================================================================
--- 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
Mon Oct 23 22:43:20 2006
@@ -49,7 +49,7 @@
         setPhase(Phase.MARSHAL);
     }
 
-    public void handleMessage(Message message) throws Fault {        
+    public void handleMessage(Message message) throws Fault {
         message.put(org.apache.cxf.message.Message.RESPONSE_CODE, new Integer(500));
         NSStack nsStack = new NSStack();
         nsStack.push();
@@ -63,63 +63,52 @@
 
             StaxUtils.writeStartElement(writer, prefix, XMLFault.XML_FAULT_ROOT, XMLConstants.NS_XML_FORMAT);
 
-            StaxUtils.writeStartElement(writer, prefix, XMLFault.XML_FAULT_STRING, 
-                    XMLConstants.NS_XML_FORMAT);
-            Throwable t = xmlFault.getCause();
-            StringBuffer str = new StringBuffer(t.toString());
-            QName elName = null;
+            StaxUtils
+                    .writeStartElement(writer, prefix, XMLFault.XML_FAULT_STRING, XMLConstants.NS_XML_FORMAT);
+            Throwable t = xmlFault.getCause();            
+            writer.writeCharacters(t == null ? xmlFault.getMessage() : t.toString());
+            // fault string
+            writer.writeEndElement();
+
+            // call data writer to marshal exception
             BindingOperationInfo bop = message.getExchange().get(BindingOperationInfo.class);
-            if (!bop.isUnwrappedCapable()) {
-                bop = bop.getUnwrappedOperation();
-            }
-            Iterator<FaultInfo> it = bop.getOperationInfo().getFaults().iterator();
-            // Boolean isWebFault = null;
-            while (it.hasNext()) {
-                FaultInfo fi = it.next();
-                for (MessagePartInfo mpi : fi.getMessageParts()) {
-                    Class cls = mpi.getProperty(Class.class.getName(), Class.class);
-                    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 {
-                            elName = mpi.getTypeQName();
+            if (bop != null) {
+                QName elName = null;
+                if (!bop.isUnwrappedCapable()) {
+                    bop = bop.getUnwrappedOperation();
+                }
+                Iterator<FaultInfo> it = bop.getOperationInfo().getFaults().iterator();
+                while (it.hasNext()) {
+                    FaultInfo fi = it.next();
+                    for (MessagePartInfo mpi : fi.getMessageParts()) {
+                        Class cls = mpi.getProperty(Class.class.getName(), Class.class);
+                        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 {
+                                elName = mpi.getTypeQName();
+                            }
+                            break;
                         }
-                        // isWebFault = mpi.getProperty("javax.xml.ws.WebFault", Boolean.class);
-                        break;
                     }
                 }
-            }
-            /*
-             * do not send stack trace information to client
-            if (!(isWebFault != null && isWebFault.booleanValue())) {
-                str.append("\n");
-                for (StackTraceElement s : t.getStackTrace()) {
-                    str.append(s.toString());
-                    str.append("\n");
+                if (elName != null) {
+                    StaxUtils.writeStartElement(writer, prefix, XMLFault.XML_FAULT_DETAIL,
+                            XMLConstants.NS_XML_FORMAT);
+                    DataWriter<Message> dataWriter = getMessageDataWriter(message);
+                    dataWriter.write(getFaultInfo(t), elName, message);
+                    writer.writeEndElement();
                 }
             }
-             */
-            writer.writeCharacters(str.toString());
-            // fault string
-            writer.writeEndElement();
-            
-            // call data writer to marshal exception
-            if (elName != null) {
-                StaxUtils.writeStartElement(writer, prefix, XMLFault.XML_FAULT_DETAIL,
-                        XMLConstants.NS_XML_FORMAT);
-                DataWriter<Message> dataWriter = getMessageDataWriter(message);
-                dataWriter.write(getFaultInfo(t), elName, message);
-                writer.writeEndElement();
-            }
             // fault root
             writer.writeEndElement();
-            
+
             writer.flush();
 
         } catch (NoSuchMethodException ne) {
-            throw new Fault(new org.apache.cxf.common.i18n.Message("UNKNOWN_EXCEPTION", BUNDLE),
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);
         }



Mime
View raw message