cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject svn commit: r546430 - in /incubator/cxf/trunk/distribution/src/main/release/samples/mtom: src/demo/mtom/client/Client.java src/demo/mtom/server/TestMtomImpl.java wsdl/mtom_xop.wsdl
Date Tue, 12 Jun 2007 09:08:07 GMT
Author: ffang
Date: Tue Jun 12 02:08:06 2007
New Revision: 546430

URL: http://svn.apache.org/viewvc?view=rev&rev=546430
Log:
[CXF-700] MTOM sample doesn't show how mtom work

Modified:
    incubator/cxf/trunk/distribution/src/main/release/samples/mtom/src/demo/mtom/client/Client.java
    incubator/cxf/trunk/distribution/src/main/release/samples/mtom/src/demo/mtom/server/TestMtomImpl.java
    incubator/cxf/trunk/distribution/src/main/release/samples/mtom/wsdl/mtom_xop.wsdl

Modified: incubator/cxf/trunk/distribution/src/main/release/samples/mtom/src/demo/mtom/client/Client.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/mtom/src/demo/mtom/client/Client.java?view=diff&rev=546430&r1=546429&r2=546430
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/mtom/src/demo/mtom/client/Client.java
(original)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/mtom/src/demo/mtom/client/Client.java
Tue Jun 12 02:08:06 2007
@@ -26,8 +26,9 @@
 import java.io.InputStream;
 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;
@@ -76,7 +77,7 @@
         }
         Holder<byte[]> param = new Holder<byte[]>();
         param.value = new byte[(int) fileSize];
-        System.out.println("Start test the XML-binary Optimized Packaging!");
+        System.out.println("Start test without Mtom enable!");
         System.out.println("Sending out the me.bmp Image content to server, data size is
" + fileSize);
 
         InputStream in = client.getClass().getResourceAsStream("me.bmp");
@@ -88,7 +89,24 @@
         Image image = ImageIO.read(new ByteArrayInputStream(param.value));
         System.out.println("build image with the returned byte[] back from server successfully,
hashCode="
                 + image.hashCode());
-        System.out.println("Successfully run demo mtom/xop");
+        System.out.println("Successfully run demo without mtom enable");
+
+        System.out.println("Start test with Mtom enable!");        
+        System.out.println("Sending out the me.bmp Image content to server, data size is
" + fileSize);
+        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"));
+        port.testMtom(name, handler);
+        InputStream mtomIn = handler.value.getInputStream();
+        fileSize = 0;
+        
+        for (int i = mtomIn.read(); i != -1; i = mtomIn.read()) {
+            fileSize++;
+        }
+
+        System.out.println("received DataHandler back from server, the size is " + fileSize);
+        System.out.println("Successfully run demo with mtom enable");
         System.exit(0);
     }
 

Modified: incubator/cxf/trunk/distribution/src/main/release/samples/mtom/src/demo/mtom/server/TestMtomImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/mtom/src/demo/mtom/server/TestMtomImpl.java?view=diff&rev=546430&r1=546429&r2=546430
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/mtom/src/demo/mtom/server/TestMtomImpl.java
(original)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/mtom/src/demo/mtom/server/TestMtomImpl.java
Tue Jun 12 02:08:06 2007
@@ -18,7 +18,9 @@
  */
 
 package demo.mtom.server;
+import java.io.InputStream;
 
+import javax.activation.DataHandler;
 import javax.jws.WebService;
 import javax.xml.ws.Holder;
 
@@ -37,5 +39,18 @@
         System.out.println("The image holder data length is " + attachinfo.value.length);
       
         name.value = "return detail + " + name.value;        
     }
+
+    public void testMtom(Holder<String> name, Holder<DataHandler> attachinfo)
{
+        try {
+            System.out.println("Received image holder data with mtom enable from client");
+            InputStream mtomIn = attachinfo.value.getInputStream();
+            long fileSize = 0;
+            System.out.println("The image holder data length is " + mtomIn.available());
+            name.value = "return detail + " + name.value;
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
 
 }

Modified: incubator/cxf/trunk/distribution/src/main/release/samples/mtom/wsdl/mtom_xop.wsdl
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/mtom/wsdl/mtom_xop.wsdl?view=diff&rev=546430&r1=546429&r2=546430
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/mtom/wsdl/mtom_xop.wsdl (original)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/mtom/wsdl/mtom_xop.wsdl Tue
Jun 12 02:08:06 2007
@@ -22,7 +22,9 @@
 <wsdl:definitions name="SOAPBuilders-mime-cr-test" xmlns:types="http://cxf.apache.org/mime/types"
     xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
     xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://cxf.apache.org/mime"
-    xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" targetNamespace="http://cxf.apache.org/mime">
+    xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" 
+    xmlns:xmime="http://www.w3.org/2005/05/xmlmime"    
+    targetNamespace="http://cxf.apache.org/mime">
 
     <wsdl:types>
         <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://cxf.apache.org/mime/types"
@@ -30,11 +32,20 @@
             <complexType name="XopType">
                 <sequence>
                     <element name="name" type="xsd:string" />
-                    <element name="attachinfo" type="xsd:base64Binary" />
+                    <element name="attachinfo" type="xsd:base64Binary"/>
                 </sequence>
             </complexType>
             <element name="testXop" type="types:XopType" />
             <element name="testXopResponse" type="types:XopType" />
+            
+            <complexType name="MtomType">
+                <sequence>
+                    <element name="name" type="xsd:string" />
+                    <element name="attachinfo" type="xsd:base64Binary" xmime:expectedContentTypes="application/octet-stream"/>
+                </sequence>
+            </complexType>
+            <element name="testMtom" type="types:MtomType" />
+            <element name="testMtomResponse" type="types:MtomType" />
         </schema>
 
     </wsdl:types>
@@ -49,6 +60,15 @@
     </wsdl:message>
 
 
+    <wsdl:message name="testMtomIn">
+        <wsdl:part name="data" element="types:testMtom" />
+    </wsdl:message>
+
+    <wsdl:message name="testMtomOut">
+        <wsdl:part name="data" element="types:testMtomResponse" />
+    </wsdl:message>
+
+
     <wsdl:portType name="TestMtom">
 
         <wsdl:operation name="testXop">
@@ -56,12 +76,26 @@
             <wsdl:output message="tns:testXopOut" />
         </wsdl:operation>
 
+        <wsdl:operation name="testMtom">
+            <wsdl:input message="tns:testMtomIn" />
+            <wsdl:output message="tns:testMtomOut" />
+        </wsdl:operation>
     </wsdl:portType>
 
     <wsdl:binding name="TestMtomBinding" type="tns:TestMtom">
         <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"
/>
 
         <wsdl:operation name="testXop">
+            <soap:operation soapAction="" />
+            <wsdl:input>
+                <soap:body use="literal" />
+            </wsdl:input>
+            <wsdl:output>
+                <soap:body use="literal" />
+            </wsdl:output>
+        </wsdl:operation>
+
+        <wsdl:operation name="testMtom">
             <soap:operation soapAction="" />
             <wsdl:input>
                 <soap:body use="literal" />



Mime
View raw message