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 ng...@apache.org on 2006/11/20 16:25:05 UTC

svn commit: r477222 - in /webservices/axis2/trunk/java/modules/jaxws: src/org/apache/axis2/jaxws/BindingProvider.java src/org/apache/axis2/jaxws/message/Protocol.java test/org/apache/axis2/jaxws/sample/MtomSampleTests.java

Author: ngallardo
Date: Mon Nov 20 07:25:05 2006
New Revision: 477222

URL: http://svn.apache.org/viewvc?view=rev&rev=477222
Log:
Contributor: Samuel Isokpunwu

Fixing issues related to SOAP 1.2 MTOM enablement via the binding type property.

Modified:
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/BindingProvider.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/Protocol.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/MtomSampleTests.java

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/BindingProvider.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/BindingProvider.java?view=diff&rev=477222&r1=477221&r2=477222
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/BindingProvider.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/BindingProvider.java Mon Nov 20 07:25:05 2006
@@ -109,7 +109,7 @@
             throw ExceptionFactory.makeWebServiceException(Messages.getMessage("NoMaintainSessionProperty"));
         }
 
-        if(sessionValue != null){
+        if(sessionValue == null){
             throw ExceptionFactory.makeWebServiceException(Messages.getMessage("NullValueForMaintainSessionProperty",sessionKey));
         }
     }

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/Protocol.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/Protocol.java?view=diff&rev=477222&r1=477221&r2=477222
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/Protocol.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/Protocol.java Mon Nov 20 07:25:05 2006
@@ -43,7 +43,7 @@
             return Protocol.soap11;
         }
         else if (url.equals(SOAPBinding.SOAP12HTTP_BINDING) ||
-        		 url.equals(SOAPBinding.SOAP12HTTP_BINDING)) {
+        		 url.equals(SOAPBinding.SOAP12HTTP_MTOM_BINDING)) {
             return Protocol.soap12;
         }
         else {

Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/MtomSampleTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/MtomSampleTests.java?view=diff&rev=477222&r1=477221&r2=477222
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/MtomSampleTests.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/MtomSampleTests.java Mon Nov 20 07:25:05 2006
@@ -28,7 +28,7 @@
     private static final QName QNAME_SERVICE = new QName("urn://mtom.test.org", "MtomSampleService");
     private static final QName QNAME_PORT    = new QName("urn://mtom.test.org", "MtomSample");
     private static final String URL_ENDPOINT = "http://localhost:8080/axis2/services/MtomSampleService";
-    private static final String IMAGE_DIR = "test-resources"+File.separator+"image";     
+    private static final String IMAGE_DIR = "test-resources"+File.separator+"image";   
     
     /*
      * Enable attachment Optimization through the SOAPBinding method 
@@ -149,6 +149,93 @@
         // property for MTOM
         Service service = Service.create(QNAME_SERVICE);
         service.addPort(QNAME_PORT, SOAPBinding.SOAP11HTTP_MTOM_BINDING, URL_ENDPOINT);
+        Dispatch<Object> dispatch = service.createDispatch(QNAME_PORT, jbc, Mode.PAYLOAD);
+        
+        
+        //Enable attachment optimization
+        SOAPBinding binding = (SOAPBinding) dispatch.getBinding();
+        binding.setMTOMEnabled(true);
+        
+        SendImageResponse response = (SendImageResponse) dispatch.invoke(request);
+        
+        assertNotNull(response);
+        assertNotNull(response.getOutput().getImageData());
+    }
+    
+    /*
+     * Enable attachment optimization using both the SOAP12 binding
+     * property for MTOM
+     */
+    public void testSendImageAttachmentProperty12() throws Exception {
+        System.out.println("----------------------------------");
+        System.out.println("test: " + getName());
+        
+        String imageResourceDir = IMAGE_DIR;
+        
+        //Create a DataSource from an image 
+        File file = new File(imageResourceDir+File.separator+"test.jpg");
+        ImageInputStream fiis = new FileImageInputStream(file);
+        Image image = ImageIO.read(fiis);
+        DataSource imageDS = new DataSourceImpl("image/jpeg","test.jpg",image);
+        
+        //Create a DataHandler with the String DataSource object
+        DataHandler dataHandler = new DataHandler(imageDS);
+        
+        //Store the data handler in ImageDepot bean
+        ImageDepot imageDepot = new ObjectFactory().createImageDepot();
+        imageDepot.setImageData(dataHandler);
+        
+        SendImage request = new ObjectFactory().createSendImage();
+        request.setInput(imageDepot);
+        
+        //Create the necessary JAXBContext
+        JAXBContext jbc = JAXBContext.newInstance("org.test.mtom");
+        
+        // Create the JAX-WS client needed to send the request with soap 11 binding
+        // property for MTOM
+        Service service = Service.create(QNAME_SERVICE);
+        service.addPort(QNAME_PORT, SOAPBinding.SOAP12HTTP_MTOM_BINDING, URL_ENDPOINT);
+        Dispatch<Object> dispatch = service.createDispatch(QNAME_PORT, jbc, Mode.PAYLOAD);
+        
+        SendImageResponse response = (SendImageResponse) dispatch.invoke(request);
+        
+        assertNotNull(response);
+        assertNotNull(response.getOutput().getImageData());
+    }
+    
+    /*
+     * Enable attachment optimization using both the SOAP12 binding API
+     * for MTOM
+     */
+    public void testSendImageAttachmentAPI12() throws Exception {
+        System.out.println("----------------------------------");
+        System.out.println("test: " + getName());
+        
+        String imageResourceDir = IMAGE_DIR;
+        
+        //Create a DataSource from an image 
+        File file = new File(imageResourceDir+File.separator+"test.jpg");
+        ImageInputStream fiis = new FileImageInputStream(file);
+        Image image = ImageIO.read(fiis);
+        DataSource imageDS = new DataSourceImpl("image/jpeg","test.jpg",image);
+        
+        //Create a DataHandler with the String DataSource object
+        DataHandler dataHandler = new DataHandler(imageDS);
+        
+        //Store the data handler in ImageDepot bean
+        ImageDepot imageDepot = new ObjectFactory().createImageDepot();
+        imageDepot.setImageData(dataHandler);
+        
+        SendImage request = new ObjectFactory().createSendImage();
+        request.setInput(imageDepot);
+        
+        //Create the necessary JAXBContext
+        JAXBContext jbc = JAXBContext.newInstance("org.test.mtom");
+        
+        // Create the JAX-WS client needed to send the request with soap 11 binding
+        // property for MTOM
+        Service service = Service.create(QNAME_SERVICE);
+        service.addPort(QNAME_PORT, SOAPBinding.SOAP12HTTP_BINDING, URL_ENDPOINT);
         Dispatch<Object> dispatch = service.createDispatch(QNAME_PORT, jbc, Mode.PAYLOAD);
         
         



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