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/08 21:14:06 UTC

svn commit: r472621 - in /webservices/axis2/trunk/java/modules/jaxws: src/org/apache/axis2/jaxws/client/ src/org/apache/axis2/jaxws/message/ src/org/apache/axis2/jaxws/spi/ test/org/apache/axis2/jaxws/dispatch/ test/org/apache/axis2/jaxws/sample/

Author: ngallardo
Date: Wed Nov  8 12:14:05 2006
New Revision: 472621

URL: http://svn.apache.org/viewvc?view=rev&rev=472621
Log:
AXIS2-1623
Contributor: Samuel Isokpunwu

Sam's patch for adding an additional flag to turn on MTOM.

Modified:
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/BaseDispatch.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/Protocol.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/JAXBSourceDispatch.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/client/BaseDispatch.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/BaseDispatch.java?view=diff&rev=472621&r1=472620&r2=472621
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/BaseDispatch.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/BaseDispatch.java Wed Nov  8 12:14:05 2006
@@ -367,6 +367,15 @@
             if (soapBinding.isMTOMEnabled())
                 msg.setMTOMEnabled(true);
         }
+        
+        // Check if the user enabled MTOM using the SOAP binding 
+        // properties for MTOM
+        String bindingID = this.port.getBindingID();
+        if((bindingID.equalsIgnoreCase(SOAPBinding.SOAP11HTTP_MTOM_BINDING) ||
+        	bindingID.equalsIgnoreCase(SOAPBinding.SOAP12HTTP_MTOM_BINDING)) &&
+        	!msg.isMTOMEnabled()){
+        	msg.setMTOMEnabled(true);
+        }
     }
     
     /*

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=472621&r1=472620&r2=472621
==============================================================================
--- 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 Wed Nov  8 12:14:05 2006
@@ -38,10 +38,12 @@
      */
     public static Protocol getProtocolForBinding(String url) throws MessageException {
         //TODO: Add support for more URLs as needed.
-        if (url.equals(SOAPBinding.SOAP11HTTP_BINDING)) {
+        if (url.equals(SOAPBinding.SOAP11HTTP_BINDING) || 
+        	url.equals(SOAPBinding.SOAP11HTTP_MTOM_BINDING)) {
             return Protocol.soap11;
         }
-        else if (url.equals(SOAPBinding.SOAP12HTTP_BINDING)) {
+        else if (url.equals(SOAPBinding.SOAP12HTTP_BINDING) ||
+        		 url.equals(SOAPBinding.SOAP12HTTP_BINDING)) {
             return Protocol.soap12;
         }
         else {

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java?view=diff&rev=472621&r1=472620&r2=472621
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java Wed Nov  8 12:14:05 2006
@@ -1,18 +1,20 @@
 /*
- * Copyright 2006 The Apache Software Foundation.
- * Copyright 2006 International Business Machines Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
  *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ *      
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  */
 
 package org.apache.axis2.jaxws.spi;
@@ -27,7 +29,6 @@
 
 import javax.xml.bind.JAXBContext;
 import javax.xml.namespace.QName;
-import javax.xml.soap.SOAPEnvelope;
 import javax.xml.soap.SOAPMessage;
 import javax.xml.transform.Source;
 import javax.xml.ws.BindingProvider;
@@ -51,7 +52,6 @@
 import org.apache.axis2.jaxws.handler.PortData;
 import org.apache.axis2.jaxws.handler.PortInfoImpl;
 import org.apache.axis2.jaxws.i18n.Messages;
-import org.apache.axis2.jaxws.registry.FactoryRegistry;
 import org.apache.axis2.jaxws.util.WSDLWrapper;
 
 /**
@@ -113,8 +113,10 @@
             throw ExceptionFactory.makeWebServiceException(Messages.getMessage("addPortErr2"));
         }
         
-        if(bindingId!=null && !(bindingId.equals(SOAPBinding.SOAP11HTTP_BINDING) ||
-                bindingId.equals(SOAPBinding.SOAP12HTTP_BINDING))){
+        if(bindingId != null && !(bindingId.equals(SOAPBinding.SOAP11HTTP_BINDING) ||
+           bindingId.equals(SOAPBinding.SOAP12HTTP_BINDING) ||
+           bindingId.equals(SOAPBinding.SOAP11HTTP_MTOM_BINDING) ||
+           bindingId.equals(SOAPBinding.SOAP12HTTP_MTOM_BINDING))) {
             // TODO Is this the correct exception. Shouldn't this be a WebServiceException ?
             throw new UnsupportedOperationException(Messages.getMessage("addPortErr0", portName.toString()));
         }

Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/JAXBSourceDispatch.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/JAXBSourceDispatch.java?view=diff&rev=472621&r1=472620&r2=472621
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/JAXBSourceDispatch.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/JAXBSourceDispatch.java Wed Nov  8 12:14:05 2006
@@ -60,8 +60,7 @@
 	        // Initialize the JAX-WS client artifacts
 	        Service svc = Service.create(serviceName);
 	        svc.addPort(portName, null, url);
-	        Dispatch<JAXBSource> dispatch = svc.createDispatch(portName, 
-	                JAXBSource.class, Service.Mode.PAYLOAD);
+	        Dispatch<Source> dispatch = svc.createDispatch(portName, Source.class, Service.Mode.PAYLOAD);
 	        
 	        //Create JAXBContext and JAXBSource here.
 	        ObjectFactory factory = new ObjectFactory();

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=472621&r1=472620&r2=472621
==============================================================================
--- 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 Wed Nov  8 12:14:05 2006
@@ -28,12 +28,18 @@
     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";     
     
-    public void testSendImageAttachment() throws Exception {
+    /*
+     * Enable attachment Optimization through the SOAPBinding method 
+     * -- setMTOMEnabled([true|false])
+     * Using SOAP11
+     */
+    public void testSendImageAttachmentAPI11() throws Exception {
         System.out.println("----------------------------------");
         System.out.println("test: " + getName());
         
-        String imageResourceDir = "test-resources"+File.separator+"image";
+        String imageResourceDir = IMAGE_DIR;
         
         //Create a DataSource from an image 
         File file = new File(imageResourceDir+File.separator+"test.jpg");
@@ -57,9 +63,96 @@
         // Create the JAX-WS client needed to send the request
         Service service = Service.create(QNAME_SERVICE);
         service.addPort(QNAME_PORT, SOAPBinding.SOAP11HTTP_BINDING, URL_ENDPOINT);
-        Dispatch<Object> dispatch = service.createDispatch(
-                QNAME_PORT, jbc, Mode.PAYLOAD);
+        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 the SOAP11 binding
+     * property for MTOM.
+     */
+    public void testSendImageAttachmentProperty11() 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.SOAP11HTTP_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 SOAP11 binding
+     * property for MTOM and the Binding API
+     */
+    public void testSendImageAttachmentAPIProperty11() 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.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);
         



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