Author: gmazza
Date: Sat Oct 27 03:49:07 2007
New Revision: 589072
URL: http://svn.apache.org/viewvc?rev=589072&view=rev
Log:
Improved MTOM sample.
Added:
incubator/cxf/trunk/distribution/src/main/release/samples/mtom/src/demo/mtom/server/TestMtomPortTypeImpl.java
- copied, changed from r589048,
incubator/cxf/trunk/distribution/src/main/release/samples/mtom/src/demo/mtom/server/TestMtomImpl.java
Removed:
incubator/cxf/trunk/distribution/src/main/release/samples/mtom/src/demo/mtom/server/TestMtomImpl.java
Modified:
incubator/cxf/trunk/distribution/src/main/release/samples/mtom/README.txt
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/Server.java
incubator/cxf/trunk/distribution/src/main/release/samples/mtom/wsdl/cxf-servlet.xml
incubator/cxf/trunk/distribution/src/main/release/samples/mtom/wsdl/mtom_xop.wsdl
Modified:
incubator/cxf/trunk/distribution/src/main/release/samples/mtom/README.txt
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/mtom/README.txt?rev=589072&r1=589071&r2=589072&view=diff
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/mtom/README.txt
(original)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/mtom/README.txt
Sat Oct 27 03:49:07 2007
@@ -116,17 +116,14 @@
Build the war file with the command:
ant war
-
+
The war file will be included in the directory
samples/mtom/build/war. Simply copy the war file into
the servlet container's deployment directory. For example,
with Tomcat copy the war file into the directory
-<installationDirectory>/webapps. The servlet container will
+$CATALINA_HOME/webapps. The servlet container will
extract the war and deploy the application.
-
-Make sure already copy all jars from CXF_HOME/lib to
-<TomcatInstallationDirectory>/shared/lib
Using ant, run the client application with the command:
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?rev=589072&r1=589071&r2=589072&view=diff
==============================================================================
---
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
Sat Oct 27 03:49:07 2007
@@ -35,7 +35,7 @@
import javax.xml.ws.Holder;
import javax.xml.ws.soap.SOAPBinding;
-import org.apache.cxf.mime.TestMtom;
+import org.apache.cxf.mime.TestMtomPortType;
import org.apache.cxf.mime.TestMtomService;
public final class Client {
@@ -66,7 +66,8 @@
System.out.println(wsdlURL);
TestMtomService tms = new TestMtomService(wsdlURL, SERVICE_NAME);
- TestMtom port = (TestMtom) tms.getPort(PORT_NAME, TestMtom.class);
+ TestMtomPortType port = (TestMtomPortType) tms.getPort(PORT_NAME,
+ TestMtomPortType.class);
Binding binding = ((BindingProvider)port).getBinding();
((SOAPBinding)binding).setMTOMEnabled(true);
@@ -75,38 +76,52 @@
for (int i = pre.read(); i != -1; i = pre.read()) {
fileSize++;
}
+ 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("Start test without MTOM enabled:");
- System.out.println("Sending out the me.bmp image content to server,
data size is " + 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");
in.read(param.value);
- Holder<String> name = new Holder<String>("call detail");
- port.testXop(name, param);
- System.out.println("Received byte[] back from server, returned size is
" + param.value.length);
+ System.out.println("--Sending the me.bmp image to server");
+ System.out.println("--Sending a name value of " + name.value);
+
+ port.testByteArray(name, param);
+
+ System.out.println("--Received byte[] back from server, returned size
is "
+ + param.value.length);
+ System.out.println("--Returned string value is " + name.value);
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 ran demo without MTOM enabled");
+ System.out.println("--Loaded image from byte[] successfully,
hashCode=" +
+ image.hashCode());
+ System.out.println("Successfully ran MTOM/byte array demo");
- System.out.println("Start test with MTOM enabled:");
- System.out.println("Sending out the me.bmp Image content to server,
data size is " + fileSize);
+ 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"));
- port.testMtom(name, handler);
+ handler.value = new DataHandler(new ByteArrayDataSource(data,
+ "application/octet-stream"));
+ System.out.println("--Sending the me.bmp image to server");
+ System.out.println("--Sending a name value of " + name.value);
+
+ port.testDataHandler(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, returned
size is " + fileSize);
- System.out.println("Successfully ran demo with MTOM enabled");
+ System.out.println("--Received DataHandler back from server, " +
+ "returned size is " + fileSize);
+ System.out.println("--Returned string value is " + name.value);
+
+ System.out.println("Successfully ran MTOM/DataHandler demo");
System.exit(0);
}
Modified:
incubator/cxf/trunk/distribution/src/main/release/samples/mtom/src/demo/mtom/server/Server.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/mtom/src/demo/mtom/server/Server.java?rev=589072&r1=589071&r2=589072&view=diff
==============================================================================
---
incubator/cxf/trunk/distribution/src/main/release/samples/mtom/src/demo/mtom/server/Server.java
(original)
+++
incubator/cxf/trunk/distribution/src/main/release/samples/mtom/src/demo/mtom/server/Server.java
Sat Oct 27 03:49:07 2007
@@ -27,7 +27,7 @@
protected Server() throws Exception {
System.out.println("Starting Server");
- Object implementor = new TestMtomImpl();
+ Object implementor = new TestMtomPortTypeImpl();
String address = "http://localhost:9000/mime-test";
Endpoint ep = Endpoint.publish(address, implementor);
Binding binding = ep.getBinding();
Copied:
incubator/cxf/trunk/distribution/src/main/release/samples/mtom/src/demo/mtom/server/TestMtomPortTypeImpl.java
(from r589048,
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/TestMtomPortTypeImpl.java?p2=incubator/cxf/trunk/distribution/src/main/release/samples/mtom/src/demo/mtom/server/TestMtomPortTypeImpl.java&p1=incubator/cxf/trunk/distribution/src/main/release/samples/mtom/src/demo/mtom/server/TestMtomImpl.java&r1=589048&r2=589072&rev=589072&view=diff
==============================================================================
---
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/TestMtomPortTypeImpl.java
Sat Oct 27 03:49:07 2007
@@ -24,33 +24,31 @@
import javax.jws.WebService;
import javax.xml.ws.Holder;
-import org.apache.cxf.mime.TestMtom;
+import org.apache.cxf.mime.TestMtomPortType;
@WebService(serviceName = "TestMtomService",
portName = "TestMtomPort",
- endpointInterface = "org.apache.cxf.mime.TestMtom",
+ endpointInterface = "org.apache.cxf.mime.TestMtomPortType",
targetNamespace = "http://cxf.apache.org/mime")
-public class TestMtomImpl implements TestMtom {
+public class TestMtomPortTypeImpl implements TestMtomPortType {
- public void testXop(Holder<String> name, Holder<byte[]> attachinfo) {
- System.out.println("Received image holder data from client");
- System.out.println("The image holder data length is " +
attachinfo.value.length);
- name.value = "return detail + " + name.value;
+ public void testByteArray(Holder<String> name, Holder<byte[]> attachinfo) {
+ System.out.println("Received image from client");
+ System.out.println("The image data size is " +
attachinfo.value.length);
+ name.value = "Hello " + name.value;
}
- public void testMtom(Holder<String> name, Holder<DataHandler> attachinfo) {
+ public void testDataHandler(Holder<String> name, Holder<DataHandler>
attachinfo) {
try {
- System.out.println("Received image holder data with mtom enable
from client");
+ System.out.println("Received image with mtom enabled 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;
+ System.out.println("The image data size is " + mtomIn.available());
+ name.value = "Hello " + name.value;
} catch (Exception e) {
e.printStackTrace();
}
}
-
-
}
Modified:
incubator/cxf/trunk/distribution/src/main/release/samples/mtom/wsdl/cxf-servlet.xml
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/mtom/wsdl/cxf-servlet.xml?rev=589072&r1=589071&r2=589072&view=diff
==============================================================================
---
incubator/cxf/trunk/distribution/src/main/release/samples/mtom/wsdl/cxf-servlet.xml
(original)
+++
incubator/cxf/trunk/distribution/src/main/release/samples/mtom/wsdl/cxf-servlet.xml
Sat Oct 27 03:49:07 2007
@@ -29,7 +29,7 @@
<jaxws:endpoint
id="mtom"
- implementor="demo.mtom.server.TestMtomImpl"
+ implementor="demo.mtom.server.TestMtomPortTypeImpl"
wsdlLocation="WEB-INF/wsdl/mtom_xop.wsdl"
address="/mtom" />
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?rev=589072&r1=589071&r2=589072&view=diff
==============================================================================
---
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
Sat Oct 27 03:49:07 2007
@@ -29,63 +29,63 @@
<wsdl:types>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://cxf.apache.org/mime/types"
xmlns:xmime="http://www.w3.org/2005/05/xmlmime"
elementFormDefault="qualified">
- <complexType name="XopType">
+ <complexType name="ByteArrayType">
<sequence>
<element name="name" type="xsd:string" />
<element name="attachinfo" type="xsd:base64Binary"/>
</sequence>
</complexType>
- <element name="testXop" type="types:XopType" />
- <element name="testXopResponse" type="types:XopType" />
+ <element name="testByteArray" type="types:ByteArrayType" />
+ <element name="testByteArrayResponse" type="types:ByteArrayType" />
- <complexType name="MtomType">
+ <complexType name="DataHandlerType">
<sequence>
<element name="name" type="xsd:string" />
- <element name="attachinfo" type="xsd:base64Binary"
xmime:expectedContentTypes="application/octet-stream"/>
+ <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" />
+ <element name="testDataHandler" type="types:DataHandlerType" />
+ <element name="testDataHandlerResponse"
type="types:DataHandlerType" />
</schema>
</wsdl:types>
- <wsdl:message name="testXopIn">
- <wsdl:part name="data" element="types:testXop" />
+ <wsdl:message name="testByteArrayIn">
+ <wsdl:part name="data" element="types:testByteArray" />
</wsdl:message>
- <wsdl:message name="testXopOut">
- <wsdl:part name="data" element="types:testXopResponse" />
+ <wsdl:message name="testByteArrayOut">
+ <wsdl:part name="data" element="types:testByteArrayResponse" />
</wsdl:message>
- <wsdl:message name="testMtomIn">
- <wsdl:part name="data" element="types:testMtom" />
+ <wsdl:message name="testDataHandlerIn">
+ <wsdl:part name="data" element="types:testDataHandler" />
</wsdl:message>
- <wsdl:message name="testMtomOut">
- <wsdl:part name="data" element="types:testMtomResponse" />
+ <wsdl:message name="testDataHandlerOut">
+ <wsdl:part name="data" element="types:testDataHandlerResponse" />
</wsdl:message>
- <wsdl:portType name="TestMtom">
-
- <wsdl:operation name="testXop">
- <wsdl:input message="tns:testXopIn" />
- <wsdl:output message="tns:testXopOut" />
+ <wsdl:portType name="TestMtomPortType">
+ <wsdl:operation name="testByteArray">
+ <wsdl:input message="tns:testByteArrayIn" />
+ <wsdl:output message="tns:testByteArrayOut" />
</wsdl:operation>
- <wsdl:operation name="testMtom">
- <wsdl:input message="tns:testMtomIn" />
- <wsdl:output message="tns:testMtomOut" />
+ <wsdl:operation name="testDataHandler">
+ <wsdl:input message="tns:testDataHandlerIn" />
+ <wsdl:output message="tns:testDataHandlerOut" />
</wsdl:operation>
</wsdl:portType>
- <wsdl:binding name="TestMtomBinding" type="tns:TestMtom">
+ <wsdl:binding name="TestMtomBinding" type="tns:TestMtomPortType">
<soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http" />
- <wsdl:operation name="testXop">
+ <wsdl:operation name="testByteArray">
<soap:operation soapAction="" />
<wsdl:input>
<soap:body use="literal" />
@@ -95,7 +95,7 @@
</wsdl:output>
</wsdl:operation>
- <wsdl:operation name="testMtom">
+ <wsdl:operation name="testDataHandler">
<soap:operation soapAction="" />
<wsdl:input>
<soap:body use="literal" />