Author: mmao
Date: Wed Oct 10 17:33:43 2007
New Revision: 583653
URL: http://svn.apache.org/viewvc?rev=583653&view=rev
Log:
CXF-1064
* Add support of MTOMFeature for the client side
* Add support of MTOM Annotation for the service implementation
* A system test show the usage
Added:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom_feature/
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom_feature/HelloImpl.java
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom_feature/ImageHelper.java
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom_feature/MtomFeatureClientServerTest.java
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom_feature/Server.java
incubator/cxf/trunk/systests/src/test/resources/java.jpg (with props)
incubator/cxf/trunk/systests/src/test/resources/wsdl/mtom.wsdl
Modified:
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBeanTest.java
incubator/cxf/trunk/systests/pom.xml
Modified:
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java?rev=583653&r1=583652&r2=583653&view=diff
==============================================================================
---
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
(original)
+++
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
Wed Oct 10 17:33:43 2007
@@ -28,7 +28,10 @@
import javax.xml.transform.Source;
import javax.xml.ws.Binding;
import javax.xml.ws.EndpointReference;
+import javax.xml.ws.WebServiceFeature;
import javax.xml.ws.WebServicePermission;
+import javax.xml.ws.soap.MTOM;
+import javax.xml.ws.soap.MTOMFeature;
import org.w3c.dom.Element;
@@ -112,9 +115,9 @@
this.bindingUri = bindingUri;
wsdlLocation = wsdl == null ? null : new String(wsdl);
serverFactory = new JaxWsServerFactoryBean();
+ loadWSFeatureAnnotation();
}
-
-
+
public EndpointImpl(Bus b, Object i, String bindingUri) {
this(b, i, bindingUri, (String)null);
}
@@ -122,6 +125,15 @@
public EndpointImpl(Bus bus, Object implementor) {
this(bus, implementor, (String) null);
}
+
+ private void loadWSFeatureAnnotation() {
+ List<WebServiceFeature> wsFeatures = new
ArrayList<WebServiceFeature>();
+ MTOM mtom = implementor.getClass().getAnnotation(MTOM.class);
+ if (mtom != null) {
+ wsFeatures.add(new MTOMFeature(mtom.enabled(), mtom.threshold()));
+ }
+ ((JaxWsServiceFactoryBean)
serverFactory.getServiceFactory()).setWsFeatures(wsFeatures);
+ }
public Binding getBinding() {
return ((JaxWsEndpointImpl) getEndpoint()).getJaxwsBinding();
Modified:
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java?rev=583653&r1=583652&r2=583653&view=diff
==============================================================================
---
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
(original)
+++
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
Wed Oct 10 17:33:43 2007
@@ -21,6 +21,7 @@
import java.net.MalformedURLException;
import java.net.URL;
+import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
@@ -241,15 +242,23 @@
return handlerResolver;
}
- public <T> T getPort(Class<T> type) {
+ public <T> T getPort(Class<T> serviceEndpointInterface) {
+ return getPort(serviceEndpointInterface, new WebServiceFeature[]{});
+ }
+
+ public <T> T getPort(Class<T> serviceEndpointInterface,
WebServiceFeature... features) {
try {
- return createPort(null, null, type);
+ return createPort(null, null, serviceEndpointInterface, features);
} catch (ServiceConstructionException e) {
throw new WebServiceException(e);
- }
+ }
+ }
+
+ public <T> T getPort(QName portName, Class<T> serviceEndpointInterface) {
+ return getPort(portName, serviceEndpointInterface, new
WebServiceFeature[]{});
}
- public <T> T getPort(QName portName, Class<T> type) {
+ public <T> T getPort(QName portName, Class<T> serviceEndpointInterface,
WebServiceFeature... features) {
if (portName == null) {
throw new
WebServiceException(BUNDLE.getString("PORT_NAME_NULL_EXC"));
}
@@ -259,12 +268,12 @@
}
try {
- return createPort(portName, null, type);
+ return createPort(portName, null, serviceEndpointInterface,
features);
} catch (ServiceConstructionException e) {
throw new WebServiceException(e);
- }
+ }
}
-
+
public <T> T getPort(EndpointReferenceType endpointReference,
Class<T> type) {
endpointReference = EndpointReferenceUtils.resolve(endpointReference,
bus);
@@ -308,13 +317,19 @@
}
protected <T> T createPort(QName portName, EndpointReferenceType epr,
Class<T> serviceEndpointInterface) {
+ return createPort(portName, epr, serviceEndpointInterface, new
WebServiceFeature[]{});
+ }
+
+ protected <T> T createPort(QName portName, EndpointReferenceType epr,
Class<T> serviceEndpointInterface,
+ WebServiceFeature... features) {
LOG.log(Level.FINE, "creating port for portName", portName);
LOG.log(Level.FINE, "endpoint reference:", epr);
LOG.log(Level.FINE, "endpoint interface:", serviceEndpointInterface);
JaxWsProxyFactoryBean proxyFac = new JaxWsProxyFactoryBean();
JaxWsClientFactoryBean clientFac = (JaxWsClientFactoryBean)
proxyFac.getClientFactoryBean();
- ReflectionServiceFactoryBean serviceFactory =
proxyFac.getServiceFactory();
+ JaxWsServiceFactoryBean serviceFactory = (JaxWsServiceFactoryBean)
proxyFac.getServiceFactory();
+ serviceFactory.setWsFeatures(Arrays.asList(features));
proxyFac.setBus(bus);
proxyFac.setServiceClass(serviceEndpointInterface);
@@ -330,7 +345,7 @@
Service service = serviceFactory.getService();
if (service == null) {
serviceFactory.setServiceClass(serviceEndpointInterface);
- serviceFactory.setBus(getBus());
+ serviceFactory.setBus(getBus());
service = serviceFactory.create();
}
@@ -511,17 +526,6 @@
JAXBContext context,
Mode mode,
WebServiceFeature... features) {
- throw new UnsupportedOperationException();
- }
-
- public <T> T getPort(Class<T> serviceEndpointInterface,
- WebServiceFeature... features) {
- throw new UnsupportedOperationException();
- }
-
- public <T> T getPort(QName portName,
- Class<T> serviceEndpointInterface,
- WebServiceFeature... features) {
throw new UnsupportedOperationException();
}
Modified:
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java?rev=583653&r1=583652&r2=583653&view=diff
==============================================================================
---
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java
(original)
+++
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java
Wed Oct 10 17:33:43 2007
@@ -22,6 +22,9 @@
import java.util.List;
import javax.xml.ws.Binding;
+import javax.xml.ws.WebServiceFeature;
+import javax.xml.ws.soap.MTOMFeature;
+import javax.xml.ws.soap.SOAPBinding;
import org.apache.cxf.Bus;
import org.apache.cxf.binding.soap.SoapBinding;
@@ -63,15 +66,18 @@
private Binding jaxwsBinding;
private JaxWsImplementorInfo implInfo;
+ private List<WebServiceFeature> wsFeatures;
public JaxWsEndpointImpl(Bus bus, Service s, EndpointInfo ei) throws
EndpointException {
- this(bus, s, ei, null);
+ this(bus, s, ei, null, null);
}
- public JaxWsEndpointImpl(Bus bus, Service s, EndpointInfo ei,
JaxWsImplementorInfo implementorInfo)
+ public JaxWsEndpointImpl(Bus bus, Service s, EndpointInfo ei,
JaxWsImplementorInfo implementorInfo,
+ List<WebServiceFeature> features)
throws EndpointException {
super(bus, s, ei);
this.implInfo = implementorInfo;
+ this.wsFeatures = features;
createJaxwsBinding();
@@ -130,9 +136,25 @@
return jaxwsBinding;
}
+ private MTOMFeature getMTOMFeature() {
+ if (wsFeatures == null) {
+ return null;
+ }
+ for (WebServiceFeature feature : wsFeatures) {
+ if (feature instanceof MTOMFeature) {
+ return (MTOMFeature)feature;
+ }
+ }
+ return null;
+ }
+
final void createJaxwsBinding() {
if (getBinding() instanceof SoapBinding) {
jaxwsBinding = new SOAPBindingImpl(getEndpointInfo().getBinding());
+ MTOMFeature mtomFeature = getMTOMFeature();
+ if (mtomFeature != null && mtomFeature.isEnabled()) {
+ ((SOAPBinding)jaxwsBinding).setMTOMEnabled(true);
+ }
} else if (getBinding() instanceof XMLBinding) {
jaxwsBinding = new HTTPBindingImpl(getEndpointInfo().getBinding());
} else {
Modified:
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java?rev=583653&r1=583652&r2=583653&view=diff
==============================================================================
---
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
(original)
+++
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
Wed Oct 10 17:33:43 2007
@@ -26,12 +26,12 @@
import java.util.Arrays;
import java.util.List;
import java.util.logging.Logger;
-
import javax.wsdl.Operation;
import javax.xml.namespace.QName;
import javax.xml.ws.AsyncHandler;
import javax.xml.ws.Service;
import javax.xml.ws.Service.Mode;
+import javax.xml.ws.WebServiceFeature;
import org.apache.cxf.binding.AbstractBindingFactory;
import org.apache.cxf.common.i18n.Message;
@@ -72,6 +72,8 @@
private JaxWsImplementorInfo implInfo;
private JAXWSMethodDispatcher methodDispatcher;
+
+ private List<WebServiceFeature> wsFeatures;
public JaxWsServiceFactoryBean() {
getIgnoredClasses().add(Service.class.getName());
@@ -135,7 +137,7 @@
@Override
public Endpoint createEndpoint(EndpointInfo ei) throws EndpointException {
- return new JaxWsEndpointImpl(getBus(), getService(), ei, implInfo);
+ return new JaxWsEndpointImpl(getBus(), getService(), ei, implInfo,
wsFeatures);
}
@Override
@@ -442,5 +444,13 @@
getServiceConfigurations().add(0, jaxWsConfiguration);
}
methodDispatcher = new JAXWSMethodDispatcher(implInfo);
+ }
+
+ public List<WebServiceFeature> getWsFeatures() {
+ return wsFeatures;
+ }
+
+ public void setWsFeatures(List<WebServiceFeature> wsFeatures) {
+ this.wsFeatures = wsFeatures;
}
}
Modified:
incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBeanTest.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBeanTest.java?rev=583653&r1=583652&r2=583653&view=diff
==============================================================================
---
incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBeanTest.java
(original)
+++
incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBeanTest.java
Wed Oct 10 17:33:43 2007
@@ -20,18 +20,23 @@
package org.apache.cxf.jaxws.support;
import java.net.URL;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
-
import javax.wsdl.Definition;
import javax.wsdl.factory.WSDLFactory;
import javax.xml.namespace.QName;
+import javax.xml.ws.Binding;
+import javax.xml.ws.WebServiceFeature;
+import javax.xml.ws.soap.MTOMFeature;
+import javax.xml.ws.soap.SOAPBinding;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import org.apache.cxf.Bus;
+import org.apache.cxf.endpoint.Endpoint;
import org.apache.cxf.jaxws.AbstractJaxWsTest;
import org.apache.cxf.mtom_xop.TestMtomImpl;
import org.apache.cxf.service.Service;
@@ -235,8 +240,18 @@
}
-
-
-
-
+ @Test
+ public void testMtomFeature() throws Exception {
+ JaxWsServiceFactoryBean bean = new JaxWsServiceFactoryBean();
+ bean.setBus(getBus());
+ bean.setServiceClass(GreeterImpl.class);
+ bean.setWsdlURL(getClass().getResource("/wsdl/hello_world.wsdl"));
+ bean.setWsFeatures(Arrays.asList(new WebServiceFeature[]{new
MTOMFeature()}));
+ Service service = bean.create();
+ Endpoint endpoint = service.getEndpoints().values().iterator().next();
+ assertTrue(endpoint instanceof JaxWsEndpointImpl);
+ Binding binding = ((JaxWsEndpointImpl)endpoint).getJaxwsBinding();
+ assertTrue(binding instanceof SOAPBinding);
+ assertTrue(((SOAPBinding)binding).isMTOMEnabled());
+ }
}
Modified: incubator/cxf/trunk/systests/pom.xml
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/pom.xml?rev=583653&r1=583652&r2=583653&view=diff
==============================================================================
--- incubator/cxf/trunk/systests/pom.xml (original)
+++ incubator/cxf/trunk/systests/pom.xml Wed Oct 10 17:33:43 2007
@@ -60,6 +60,10 @@
<wsdl>${basedir}/src/test/resources/wsdl/cxf-993.wsdl</wsdl>
</wsdlOption>
+ <wsdlOption>
+
<wsdl>${basedir}/src/test/resources/wsdl/mtom.wsdl</wsdl>
+ </wsdlOption>
+
</wsdlOptions>
</configuration>
<goals>
Added:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom_feature/HelloImpl.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom_feature/HelloImpl.java?rev=583653&view=auto
==============================================================================
---
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom_feature/HelloImpl.java
(added)
+++
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom_feature/HelloImpl.java
Wed Oct 10 17:33:43 2007
@@ -0,0 +1,35 @@
+/**
+ * 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.
+ */
+
+package org.apache.cxf.systest.mtom_feature;
+
+import java.awt.Image;
+import javax.xml.ws.Holder;
+import javax.xml.ws.soap.MTOM;
+
[EMAIL PROTECTED]
+public class HelloImpl implements Hello {
+ public void detail(Holder<byte[]> photo, Holder<Image> image) {
+ // echo through Holder
+ }
+
+ public void echoData(Holder<byte[]> data) {
+ // echo through Holder
+ }
+}
Added:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom_feature/ImageHelper.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom_feature/ImageHelper.java?rev=583653&view=auto
==============================================================================
---
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom_feature/ImageHelper.java
(added)
+++
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom_feature/ImageHelper.java
Wed Oct 10 17:33:43 2007
@@ -0,0 +1,78 @@
+/**
+ * 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.
+ */
+
+package org.apache.cxf.systest.mtom_feature;
+
+import java.awt.Graphics;
+import java.awt.Image;
+import java.awt.MediaTracker;
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Iterator;
+import javax.imageio.ImageIO;
+import javax.imageio.ImageWriter;
+import javax.imageio.stream.ImageOutputStream;
+
+public final class ImageHelper {
+ private ImageHelper() {
+ // empty
+ }
+ public static byte[] getImageBytes(Image image, String type) throws
IOException {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ BufferedImage bufImage = convertToBufferedImage(image);
+ ImageWriter writer = null;
+ Iterator i = ImageIO.getImageWritersByMIMEType(type);
+ if (i.hasNext()) {
+ writer = (ImageWriter)i.next();
+ }
+ if (writer != null) {
+ ImageOutputStream stream = null;
+ stream = ImageIO.createImageOutputStream(baos);
+ writer.setOutput(stream);
+ writer.write(bufImage);
+ stream.close();
+ return baos.toByteArray();
+ }
+ return null;
+ }
+
+ private static BufferedImage convertToBufferedImage(Image image) throws
IOException {
+ if (image instanceof BufferedImage) {
+ return (BufferedImage)image;
+ } else {
+ /*not sure how this is used*/
+ MediaTracker tracker = new MediaTracker(null);
+ tracker.addImage(image, 0);
+ try {
+ tracker.waitForAll();
+ } catch (InterruptedException e) {
+ throw new IOException(e.getMessage());
+ }
+ BufferedImage bufImage = new BufferedImage(
+ image.getWidth(null),
+ image.getHeight(null),
+
BufferedImage.TYPE_INT_RGB);
+ Graphics g = bufImage.createGraphics();
+ g.drawImage(image, 0, 0, null);
+ return bufImage;
+ }
+ }
+}
Added:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom_feature/MtomFeatureClientServerTest.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom_feature/MtomFeatureClientServerTest.java?rev=583653&view=auto
==============================================================================
---
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom_feature/MtomFeatureClientServerTest.java
(added)
+++
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom_feature/MtomFeatureClientServerTest.java
Wed Oct 10 17:33:43 2007
@@ -0,0 +1,74 @@
+/**
+ * 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.
+ */
+
+package org.apache.cxf.systest.mtom_feature;
+
+import java.awt.Image;
+import java.net.URL;
+import javax.imageio.ImageIO;
+import javax.xml.namespace.QName;
+import javax.xml.ws.Holder;
+import javax.xml.ws.soap.MTOMFeature;
+
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class MtomFeatureClientServerTest extends
AbstractBusClientServerTestBase {
+
+ private final QName serviceName = new
QName("http://apache.org/cxf/systest/mtom_feature",
+ "HelloService");
+ private Hello port = getPort();
+
+ @BeforeClass
+ public static void startServers() throws Exception {
+ assertTrue("server did not launch correctly",
launchServer(Server.class));
+ }
+
+ @Test
+ public void testDetail() throws Exception {
+ Holder<byte[]> photo = new Holder<byte[]>("CXF".getBytes());
+ Holder<Image> image = new Holder<Image>(getImage("/java.jpg"));
+ port.detail(photo, image);
+ assertEquals("CXF", new String(photo.value));
+ assertNotNull(image.value);
+ }
+
+ @Test
+ public void testEcho() throws Exception {
+ byte[] bytes = ImageHelper.getImageBytes(getImage("/java.jpg"),
"image/jpeg");
+ Holder<byte[]> image = new Holder<byte[]>(bytes);
+ port.echoData(image);
+ assertNotNull(image);
+ }
+
+ private Image getImage(String name) throws Exception {
+ return ImageIO.read(getClass().getResource(name));
+ }
+
+ private Hello getPort() {
+ URL wsdl = getClass().getResource("/wsdl/mtom.wsdl");
+ assertNotNull("WSDL is null", wsdl);
+
+ HelloService service = new HelloService(wsdl, serviceName);
+ assertNotNull("Service is null ", service);
+ //return service.getHelloPort();
+ return service.getHelloPort(new MTOMFeature());
+ }
+}
Added:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom_feature/Server.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom_feature/Server.java?rev=583653&view=auto
==============================================================================
---
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom_feature/Server.java
(added)
+++
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom_feature/Server.java
Wed Oct 10 17:33:43 2007
@@ -0,0 +1,45 @@
+/**
+ * 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.
+ */
+
+package org.apache.cxf.systest.mtom_feature;
+
+import javax.xml.ws.Endpoint;
+
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+
+public class Server extends AbstractBusTestServerBase {
+
+ protected void run() {
+ Object implementor = new HelloImpl();
+ String address = "http://localhost:9090/jaxws-mtom/hello";
+ Endpoint.publish(address, implementor);
+ }
+
+ public static void main(String[] args) {
+ try {
+ Server s = new Server();
+ s.start();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ System.exit(-1);
+ } finally {
+ System.out.println("done!");
+ }
+ }
+}
Added: incubator/cxf/trunk/systests/src/test/resources/java.jpg
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/resources/java.jpg?rev=583653&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/cxf/trunk/systests/src/test/resources/java.jpg
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/cxf/trunk/systests/src/test/resources/wsdl/mtom.wsdl
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/resources/wsdl/mtom.wsdl?rev=583653&view=auto
==============================================================================
--- incubator/cxf/trunk/systests/src/test/resources/wsdl/mtom.wsdl (added)
+++ incubator/cxf/trunk/systests/src/test/resources/wsdl/mtom.wsdl Wed Oct 10
17:33:43 2007
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<wsdl:definitions
xmlns:types="http://apache.org/cxf/systest/mtom_feature/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://apache.org/cxf/systest/mtom_feature"
+ name="jaxws mtom feature"
+ targetNamespace="http://apache.org/cxf/systest/mtom_feature">
+
+ <wsdl:types>
+ <schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:xmime="http://www.w3.org/2005/05/xmlmime"
+
targetNamespace="http://apache.org/cxf/systest/mtom_feature/types"
+ elementFormDefault="qualified">
+ <complexType name="DetailType">
+ <sequence>
+ <element name="photo" type="base64Binary"></element>
+ <element name="image" type="base64Binary"
xmime:expectedContentTypes="image/jpeg"></element>
+ </sequence>
+ </complexType>
+ <element name="Detail" type="types:DetailType"></element>
+ <element name="DetailResponse" type="types:DetailType"></element>
+ <element name="data" type="base64Binary"></element>
+ </schema>
+ </wsdl:types>
+
+ <wsdl:message name="echoDataIn">
+ <wsdl:part name="data" element="types:data"></wsdl:part>
+ </wsdl:message>
+
+ <wsdl:message name="echoDataOut">
+ <wsdl:part name="data" element="types:data"></wsdl:part>
+ </wsdl:message>
+
+ <wsdl:message name="HelloIn">
+ <wsdl:part name="data" element="types:Detail"></wsdl:part>
+ </wsdl:message>
+
+ <wsdl:message name="HelloOut">
+ <wsdl:part name="data" element="types:DetailResponse"></wsdl:part>
+ </wsdl:message>
+
+ <wsdl:portType name="Hello">
+ <wsdl:operation name="echoData">
+ <wsdl:input message="tns:echoDataIn"></wsdl:input>
+ <wsdl:output message="tns:echoDataOut"></wsdl:output>
+ </wsdl:operation>
+
+ <!-- mtom test -->
+ <wsdl:operation name="Detail">
+ <wsdl:input message="tns:HelloIn"></wsdl:input>
+ <wsdl:output message="tns:HelloOut"></wsdl:output>
+ </wsdl:operation>
+
+ </wsdl:portType>
+
+ <wsdl:binding name="HelloBinding" type="tns:Hello">
+ <soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"></soap:binding>
+
+ <wsdl:operation name="echoData">
+ <soap:operation soapAction=""></soap:operation>
+ <wsdl:input>
+ <soap:body use="literal"></soap:body>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"></soap:body>
+ </wsdl:output>
+ </wsdl:operation>
+
+ <wsdl:operation name="Detail">
+ <soap:operation soapAction=""></soap:operation>
+ <wsdl:input>
+ <soap:body use="literal"></soap:body>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"></soap:body>
+ </wsdl:output>
+ </wsdl:operation>
+
+ </wsdl:binding>
+
+ <wsdl:service name="HelloService">
+ <wsdl:port name="HelloPort" binding="tns:HelloBinding">
+ <soap:address
location="http://localhost:9090/jaxws-mtom/hello"></soap:address>
+ </wsdl:port>
+ </wsdl:service>
+
+</wsdl:definitions>
\ No newline at end of file