cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r589707 - in /incubator/cxf/branches/2.0.x-fixes: ./ distribution/src/main/release/samples/mtom/build.xml distribution/src/main/release/samples/mtom/src/demo/mtom/client/Client.java
Date Mon, 29 Oct 2007 16:08:34 GMT
Author: dkulp
Date: Mon Oct 29 09:08:33 2007
New Revision: 589707

URL: http://svn.apache.org/viewvc?rev=589707&view=rev
Log:
Merged revisions 589363 via svnmerge from 
https://svn.apache.org/repos/asf/incubator/cxf/trunk

........
  r589363 | gmazza | 2007-10-28 10:33:41 -0400 (Sun, 28 Oct 2007) | 1 line
  
  Simplified method of handling me.bmp file.
........

Modified:
    incubator/cxf/branches/2.0.x-fixes/   (props changed)
    incubator/cxf/branches/2.0.x-fixes/distribution/src/main/release/samples/mtom/build.xml
    incubator/cxf/branches/2.0.x-fixes/distribution/src/main/release/samples/mtom/src/demo/mtom/client/Client.java

Propchange: incubator/cxf/branches/2.0.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: incubator/cxf/branches/2.0.x-fixes/distribution/src/main/release/samples/mtom/build.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/distribution/src/main/release/samples/mtom/build.xml?rev=589707&r1=589706&r2=589707&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/distribution/src/main/release/samples/mtom/build.xml
(original)
+++ incubator/cxf/branches/2.0.x-fixes/distribution/src/main/release/samples/mtom/build.xml
Mon Oct 29 09:08:33 2007
@@ -22,7 +22,7 @@
     <import file="../common_build.xml"/>        
         
     <target name="client" description="run demo client" depends="build">
-        <copy toFile="${build.classes.dir}/demo/mtom/client/me.bmp" file="${basedir}/src/demo/mtom/client/me.bmp"/>
+        <copy toFile="${build.classes.dir}/me.bmp" file="${basedir}/src/demo/mtom/client/me.bmp"/>
         <property name="param" value=""/>
         <cxfrun classname="demo.mtom.client.Client"
             param1="${basedir}/wsdl/mtom_xop.wsdl" 
@@ -41,7 +41,7 @@
     </target>
     
     <target name="war" depends="build">
-        <copy toFile="${build.classes.dir}/demo/mtom/client/me.bmp" file="${basedir}/src/demo/mtom/client/me.bmp"/>
+        <copy toFile="${build.classes.dir}/me.bmp" file="${basedir}/src/demo/mtom/client/me.bmp"/>
         <cxfwar wsdl="*.*" filename="mtom.war"/>
 	</target>
     <property name="cxf.war.file.name" value="mtom"/>

Modified: incubator/cxf/branches/2.0.x-fixes/distribution/src/main/release/samples/mtom/src/demo/mtom/client/Client.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/distribution/src/main/release/samples/mtom/src/demo/mtom/client/Client.java?rev=589707&r1=589706&r2=589707&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/distribution/src/main/release/samples/mtom/src/demo/mtom/client/Client.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/distribution/src/main/release/samples/mtom/src/demo/mtom/client/Client.java
Mon Oct 29 09:08:33 2007
@@ -24,11 +24,11 @@
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.InputStream;
+import java.net.URI;
 import java.net.URL;
 
 import javax.activation.DataHandler;
 import javax.imageio.ImageIO;
-import javax.mail.util.ByteArrayDataSource;
 import javax.xml.namespace.QName;
 import javax.xml.ws.Binding;
 import javax.xml.ws.BindingProvider;
@@ -40,9 +40,11 @@
 
 public final class Client {
 
-    private static final QName SERVICE_NAME = new QName("http://cxf.apache.org/mime", "TestMtomService");
+    private static final QName SERVICE_NAME = new QName("http://cxf.apache.org/mime", 
+        "TestMtomService");
 
-    private static final QName PORT_NAME = new QName("http://cxf.apache.org/mime", "TestMtomPort");
+    private static final QName PORT_NAME = new QName("http://cxf.apache.org/mime", 
+        "TestMtomPort");
 
     private Client() {
     }
@@ -71,19 +73,16 @@
         Binding binding = ((BindingProvider)port).getBinding();
         ((SOAPBinding)binding).setMTOMEnabled(true);
 
-        InputStream pre = client.getClass().getResourceAsStream("me.bmp");
-        long fileSize = 0;
-        for (int i = pre.read(); i != -1; i = pre.read()) {
-            fileSize++;
-        }
+        URL fileURL = client.getClass().getClassLoader().getResource("me.bmp");
+        File aFile = new File(new URI(fileURL.toString()));
+        long fileSize = aFile.length();
         System.out.println("Filesize of me.bmp image is: " + fileSize);
 
-        Holder<byte[]> param = new Holder<byte[]>();
-        param.value = new byte[(int) fileSize];
         System.out.println("\nStarting MTOM Test using basic byte array:");
-
         Holder<String> name = new Holder<String>("Sam");
-        InputStream in = client.getClass().getResourceAsStream("me.bmp");
+        Holder<byte[]> param = new Holder<byte[]>();
+        param.value = new byte[(int) fileSize];
+        InputStream in = fileURL.openStream();
         in.read(param.value);
         System.out.println("--Sending the me.bmp image to server");
         System.out.println("--Sending a name value of " + name.value);
@@ -102,10 +101,9 @@
         System.out.println("\nStarting MTOM test with DataHandler:");        
         name.value = "Bob";
         Holder<DataHandler> handler = new Holder<DataHandler>();
-        byte[] data = new byte[(int) fileSize];
-        client.getClass().getResourceAsStream("me.bmp").read(data);
-        handler.value = new DataHandler(new ByteArrayDataSource(data, 
-            "application/octet-stream"));
+
+        handler.value = new DataHandler(fileURL);
+
         System.out.println("--Sending the me.bmp image to server");
         System.out.println("--Sending a name value of " + name.value);
 



Mime
View raw message