You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by sc...@apache.org on 2007/02/15 22:20:56 UTC

svn commit: r508157 - in /webservices/axis2/trunk/java/modules: jaxws/test/org/apache/axis2/jaxws/dispatch/ jaxws/test/org/apache/axis2/jaxws/framework/ kernel/src/org/apache/axis2/ kernel/src/org/apache/axis2/engine/ saaj/src/org/apache/axis2/saaj/

Author: scheu
Date: Thu Feb 15 13:20:56 2007
New Revision: 508157

URL: http://svn.apache.org/viewvc?view=rev&rev=508157
Log:
AXIS2-2183
Contributor: Mike Rheinheimer
SOAPFault changes

Modified:
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/SOAP12Dispatch.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/AxisFault.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisEngine.java
    webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPFaultImpl.java

Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/SOAP12Dispatch.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/SOAP12Dispatch.java?view=diff&rev=508157&r1=508156&r2=508157
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/SOAP12Dispatch.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/SOAP12Dispatch.java Thu Feb 15 13:20:56 2007
@@ -31,6 +31,7 @@
 import javax.xml.ws.Service;
 import javax.xml.ws.Service.Mode;
 import javax.xml.ws.soap.SOAPBinding;
+import javax.xml.ws.soap.SOAPFaultException;
 
 import junit.framework.TestCase;
 
@@ -53,6 +54,14 @@
     private static final String sampleEnvelopeHead = 
         "<soapenv:Envelope xmlns:soapenv=\"http://www.w3.org/2003/05/soap-envelope\">" +
         "<soapenv:Header /><soapenv:Body>";
+    private static final String sampleEnvelopeHead_MustUnderstand = 
+        "<soapenv:Envelope xmlns:soapenv=\"http://www.w3.org/2003/05/soap-envelope\">" +
+        "<soapenv:Header>" +
+        "<soapenv:codeHeaderSOAP12 soapenv:mustUnderstand=\"true\">" +
+        "<code>default</code>" +
+        "</soapenv:codeHeaderSOAP12>" +
+        "</soapenv:Header>" +
+        "<soapenv:Body>";
     private static final String sampleEnvelopeTail = 
         "</soapenv:Body></soapenv:Envelope>";
     private static final String sampleEnvelope = 
@@ -60,6 +69,11 @@
         sampleRequest + 
         sampleEnvelopeTail;
     
+    private static final String sampleEnvelope_MustUnderstand = 
+        sampleEnvelopeHead_MustUnderstand + 
+        sampleRequest + 
+        sampleEnvelopeTail;
+    
     public SOAP12Dispatch(String name) {
         super(name);
     }
@@ -141,5 +155,35 @@
         // purposes of the test.
         assertTrue(responseText.contains("http://www.w3.org/2003/05/soap-envelope"));
         assertTrue(!responseText.contains("http://schemas.xmlsoap.org/soap/envelope"));
+    }
+    
+    /**
+     * Test sending a SOAP 1.2 request in MESSAGE mode
+     */
+    public void testSOAP12DispatchMessageMode_MustUnderstand() throws Exception {
+        // Create the JAX-WS client needed to send the request
+        Service service = Service.create(QNAME_SERVICE);
+        service.addPort(QNAME_PORT, SOAPBinding.SOAP12HTTP_BINDING, URL_ENDPOINT);
+        Dispatch<Source> dispatch = service.createDispatch(
+                QNAME_PORT, Source.class, Mode.MESSAGE);
+        
+        // Create the Source object with the message contents.  Since
+        // we're in MESSAGE mode, we'll need to make sure we create this
+        // with the right protocol.
+        byte[] bytes = sampleEnvelope_MustUnderstand.getBytes();
+        ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+        StreamSource request = new StreamSource(bais);
+        
+        SOAPFaultException e = null;
+        try {
+            Source response = dispatch.invoke(request);
+        } catch (SOAPFaultException ex) {
+            e = ex;
+        }
+        
+        assertNotNull("We should have an exception, but none was thrown.", e);
+        assertEquals("FaultCode should be \"MustUnderstand\"", "MustUnderstand", e.getFault().getFaultCodeAsQName().getLocalPart());
+        
+        
     }
 }

Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java?view=diff&rev=508157&r1=508156&r2=508157
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java Thu Feb 15 13:20:56 2007
@@ -92,7 +92,9 @@
         TestSuite suite = new TestSuite();
         
         // Add each of the test suites
+        /*
         suite = DispatchTestSuite.addTestSuites(suite);
+        */
         suite.addTestSuite(SOAP12Dispatch.class);
         suite.addTestSuite(DispatchSoapActionTests.class);
         suite.addTestSuite(ProxySoapActionTests.class);
@@ -145,7 +147,6 @@
         // TODO: This test intermittently fails on Linux and with trace enabled.
 //        suite.addTestSuite(ParallelAsyncTests.class);
         suite.addTestSuite(FaultyWebServiceTests.class);
-        
         suite.addTestSuite(FaultsServiceTests.class);
 
         suite.addTestSuite(EndpointLifecycleTests.class);
@@ -154,6 +155,7 @@
         suite.addTestSuite(PolymorphicTests.class);
         suite.addTestSuite(NS2PkgTest.class);
         suite.addTestSuite(JAXBContextTest.class);
+        
         // Start (and stop) the server only once for all the tests
         TestSetup testSetup = new TestSetup(suite) {
             public void setUp() {

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/AxisFault.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/AxisFault.java?view=diff&rev=508157&r1=508156&r2=508157
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/AxisFault.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/AxisFault.java Thu Feb 15 13:20:56 2007
@@ -444,6 +444,8 @@
     }
 
     public void setFaultCode(String soapFaultCode) {
+        // TODO: is it really safe to assume that the passed string is always the localpart?
+        // What if someone passes soapenv:Sender?
         faultCode = new QName(soapFaultCode);
     }
 

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisEngine.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisEngine.java?view=diff&rev=508157&r1=508156&r2=508157
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisEngine.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisEngine.java Thu Feb 15 13:20:56 2007
@@ -102,23 +102,32 @@
                 }
                 if (role != null) {
                     if (!SOAP12Constants.SOAP_ROLE_NEXT.equals(role)) {
+                        // TODO: should we be using a prefix on the faultcode?  What about
+                        // the QName object Constants.FAULT_SOAP12_MUSTUNDERSTAND?
                         throw new AxisFault(Messages.getMessage(
-                                "mustunderstandfailed",
-                                prefix, SOAP12Constants.FAULT_CODE_MUST_UNDERSTAND));
+                                        "mustunderstandfailed",
+                                        prefix, SOAP12Constants.FAULT_CODE_MUST_UNDERSTAND),
+                                        SOAP12Constants.FAULT_CODE_MUST_UNDERSTAND);
                     }
                 } else {
+                    // TODO: should we be using a prefix on the faultcode?  What about
+                    // the QName object Constants.FAULT_SOAP12_MUSTUNDERSTAND?
                     throw new AxisFault(Messages.getMessage(
                             "mustunderstandfailed",
-                            prefix, SOAP12Constants.FAULT_CODE_MUST_UNDERSTAND));
+                            prefix, SOAP12Constants.FAULT_CODE_MUST_UNDERSTAND),
+                            SOAP12Constants.FAULT_CODE_MUST_UNDERSTAND);
                 }
             } else {
 
                 // if must understand and soap 1.1 the actor should be NEXT , if it is null we considerr
                 // it to be NEXT
                 if ((role != null) && !SOAP11Constants.SOAP_ACTOR_NEXT.equals(role)) {
+                    // TODO: should we be using a prefix on the faultcode?  What about
+                    // the QName object Constants.FAULT_MUSTUNDERSTAND?
                     throw new AxisFault(Messages.getMessage(
                             "mustunderstandfailed",
-                            prefix, SOAP12Constants.FAULT_CODE_MUST_UNDERSTAND));
+                            prefix, SOAP11Constants.FAULT_CODE_MUST_UNDERSTAND),
+                            SOAP11Constants.FAULT_CODE_MUST_UNDERSTAND);
                 }
             }
         }

Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPFaultImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPFaultImpl.java?view=diff&rev=508157&r1=508156&r2=508157
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPFaultImpl.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPFaultImpl.java Thu Feb 15 13:20:56 2007
@@ -773,7 +773,9 @@
         SOAPFaultCode soapFaultCode = soapFactory.createSOAPFaultCode(this.fault);
         
         SOAPFaultValue soapFaultValue = soapFactory.createSOAPFaultValue(soapFaultCode);
-        soapFaultValue.setText(qname.getPrefix()+":"+qname.getLocalPart());
+        // don't just use the default prefix, use the passed one or the parent's
+        String prefix = ((qname.getPrefix() != null) && !qname.getPrefix().equals("")) ? qname.getPrefix() : this.fault.getQName().getPrefix();
+        soapFaultValue.setText(prefix+":"+qname.getLocalPart());
         OMNamespace omNamespace = new OMNamespaceImpl(qname.getNamespaceURI(),qname.getPrefix());
         soapFaultValue.setNamespace(omNamespace);
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org