Author: veithen Date: Mon Mar 19 21:15:52 2012 New Revision: 1302659 URL: http://svn.apache.org/viewvc?rev=1302659&view=rev Log: Allow changing the Java class associated with an XML type in maven-wsdl2java-plugin. This feature can be used to enable MTOM in client stubs.
Note that this requires a minor change in the toJava.Emitter, so that the BaseTypeMapping can be overridden (in the previous version of the code it was always reset to the default BaseTypeMapping implementation). Added: axis/axis1/java/trunk/maven/maven-wsdl2java-plugin/src/main/java/org/apache/axis/maven/wsdl2java/CustomizableBaseTypeMapping.java (with props) axis/axis1/java/trunk/maven/maven-wsdl2java-plugin/src/main/java/org/apache/axis/maven/wsdl2java/JavaXmlTypeMapping.java (with props) axis/axis1/java/trunk/maven/maven-wsdl2java-plugin/src/site/apt/java-xml-type-mappings.apt.vm axis/axis1/java/trunk/samples/mtomstub-sample/ (with props) axis/axis1/java/trunk/samples/mtomstub-sample/pom.xml (with props) axis/axis1/java/trunk/samples/mtomstub-sample/src/ axis/axis1/java/trunk/samples/mtomstub-sample/src/main/ axis/axis1/java/trunk/samples/mtomstub-sample/src/main/java/ axis/axis1/java/trunk/samples/mtomstub-sample/src/main/java/samples/ axis/axis1/java/trunk/samples/mtomstub-sample/src/main/java/samples/mtomstub/ axis/axis1/java/trunk/samples/mtomstub-sample/src/main/java/samples/mtomstub/service/ axis/axis1/java/trunk/samples/mtomstub-sample/src/main/java/samples/mtomstub/service/DownloadFile.java (with props) axis/axis1/java/trunk/samples/mtomstub-sample/src/main/java/samples/mtomstub/service/DownloadFileImpl.java (with props) axis/axis1/java/trunk/samples/mtomstub-sample/src/main/java/samples/mtomstub/service/ResponseDownloadFile.java (with props) axis/axis1/java/trunk/samples/mtomstub-sample/src/main/resources/ axis/axis1/java/trunk/samples/mtomstub-sample/src/main/resources/client-config.wsdd axis/axis1/java/trunk/samples/mtomstub-sample/src/test/ axis/axis1/java/trunk/samples/mtomstub-sample/src/test/java/ axis/axis1/java/trunk/samples/mtomstub-sample/src/test/java/samples/ axis/axis1/java/trunk/samples/mtomstub-sample/src/test/java/samples/mtomstub/ axis/axis1/java/trunk/samples/mtomstub-sample/src/test/java/samples/mtomstub/TestDownloadFile.java (with props) Modified: axis/axis1/java/trunk/axis/src/main/java/org/apache/axis/wsdl/toJava/Emitter.java axis/axis1/java/trunk/maven/maven-wsdl2java-plugin/src/main/java/org/apache/axis/maven/wsdl2java/AbstractWsdl2JavaMojo.java axis/axis1/java/trunk/maven/maven-wsdl2java-plugin/src/site/site.xml axis/axis1/java/trunk/samples/pom.xml axis/axis1/java/trunk/src/site/apt/changelogs/1_4_1.apt Modified: axis/axis1/java/trunk/axis/src/main/java/org/apache/axis/wsdl/toJava/Emitter.java URL: http://svn.apache.org/viewvc/axis/axis1/java/trunk/axis/src/main/java/org/apache/axis/wsdl/toJava/Emitter.java?rev=1302659&r1=1302658&r2=1302659&view=diff ============================================================================== --- axis/axis1/java/trunk/axis/src/main/java/org/apache/axis/wsdl/toJava/Emitter.java (original) +++ axis/axis1/java/trunk/axis/src/main/java/org/apache/axis/wsdl/toJava/Emitter.java Mon Mar 19 21:15:52 2012 @@ -22,10 +22,8 @@ import org.apache.axis.encoding.TypeMapp import org.apache.axis.encoding.TypeMappingRegistryImpl; import org.apache.axis.i18n.Messages; import org.apache.axis.utils.ClassUtils; -import org.apache.axis.utils.JavaUtils; import org.apache.axis.wsdl.gen.GeneratorFactory; import org.apache.axis.wsdl.gen.Parser; -import org.apache.axis.wsdl.symbolTable.BaseTypeMapping; import org.apache.axis.wsdl.symbolTable.SymTabEntry; import org.apache.axis.wsdl.symbolTable.SymbolTable; import org.w3c.dom.Document; @@ -66,9 +64,6 @@ public class Emitter extends Parser { /** Field typeMappingVersion */ protected String typeMappingVersion = "1.2"; - /** Field baseTypeMapping */ - protected BaseTypeMapping baseTypeMapping = null; - /** Field namespaces */ protected Namespaces namespaces = null; @@ -646,13 +641,8 @@ public class Emitter extends Parser { * @throws IOException */ private void setup() throws IOException { - - if (baseTypeMapping == null) { - setTypeMappingVersion(typeMappingVersion); - } - - getFactory().setBaseTypeMapping(baseTypeMapping); - + tmr.doRegisterFromVersion(typeMappingVersion); + namespaces = new Namespaces(outputDir); if (packageName != null) { @@ -793,26 +783,6 @@ public class Emitter extends Parser { */ public void setTypeMappingVersion(String typeMappingVersion) { this.typeMappingVersion = typeMappingVersion; - tmr.doRegisterFromVersion(typeMappingVersion); - baseTypeMapping = new BaseTypeMapping() { - - final TypeMapping defaultTM = getDefaultTypeMapping(); - - public String getBaseName(QName qNameIn) { - - javax.xml.namespace.QName qName = - new javax.xml.namespace.QName(qNameIn.getNamespaceURI(), - qNameIn.getLocalPart()); - Class cls = - defaultTM.getClassForQName(qName); - - if (cls == null) { - return null; - } else { - return JavaUtils.getTextClassName(cls.getName()); - } - } - }; } // The remainder are deprecated methods. Modified: axis/axis1/java/trunk/maven/maven-wsdl2java-plugin/src/main/java/org/apache/axis/maven/wsdl2java/AbstractWsdl2JavaMojo.java URL: http://svn.apache.org/viewvc/axis/axis1/java/trunk/maven/maven-wsdl2java-plugin/src/main/java/org/apache/axis/maven/wsdl2java/AbstractWsdl2JavaMojo.java?rev=1302659&r1=1302658&r2=1302659&view=diff ============================================================================== --- axis/axis1/java/trunk/maven/maven-wsdl2java-plugin/src/main/java/org/apache/axis/maven/wsdl2java/AbstractWsdl2JavaMojo.java (original) +++ axis/axis1/java/trunk/maven/maven-wsdl2java-plugin/src/main/java/org/apache/axis/maven/wsdl2java/AbstractWsdl2JavaMojo.java Mon Mar 19 21:15:52 2012 @@ -21,9 +21,12 @@ package org.apache.axis.maven.wsdl2java; import java.io.File; import java.net.MalformedURLException; +import javax.xml.namespace.QName; + import org.apache.axis.constants.Scope; import org.apache.axis.maven.shared.nsmap.Mapping; import org.apache.axis.maven.shared.nsmap.MappingUtil; +import org.apache.axis.wsdl.gen.GeneratorFactory; import org.apache.axis.wsdl.toJava.Emitter; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; @@ -148,6 +151,14 @@ public abstract class AbstractWsdl2JavaM */ private boolean helperGen; + /** + * A set of Java to XML type mappings that override the default mappings. This can be used to + * change the Java class associated with an XML type. + * + * @parameter + */ + private JavaXmlTypeMapping[] javaXmlTypeMappings; + public void execute() throws MojoExecutionException, MojoFailureException { String wsdlUrl; if (file != null && url != null) { @@ -217,6 +228,23 @@ public abstract class AbstractWsdl2JavaM // ClassUtils.setDefaultClassLoader(cl); // } + if (javaXmlTypeMappings != null && javaXmlTypeMappings.length > 0) { + GeneratorFactory factory = emitter.getFactory(); + CustomizableBaseTypeMapping btm = new CustomizableBaseTypeMapping(factory.getBaseTypeMapping()); + for (int i=0; i<javaXmlTypeMappings.length; i++) { + String xmlTypeName = javaXmlTypeMappings[i].getXmlType(); + if (xmlTypeName.length() == 0 || xmlTypeName.charAt(0) != '{') { + throw new MojoFailureException("Invalid XML type '" + xmlTypeName + "'"); + } + int idx = xmlTypeName.indexOf('}', 1); + if (idx == -1) { + throw new MojoFailureException("Invalid XML type '" + xmlTypeName + "'"); + } + btm.addMapping(new QName(xmlTypeName.substring(1, idx), xmlTypeName.substring(idx+1)), javaXmlTypeMappings[i].getJavaType()); + } + factory.setBaseTypeMapping(btm); + } + configureEmitter(emitter); getLog().info("Processing " + wsdlUrl); Added: axis/axis1/java/trunk/maven/maven-wsdl2java-plugin/src/main/java/org/apache/axis/maven/wsdl2java/CustomizableBaseTypeMapping.java URL: http://svn.apache.org/viewvc/axis/axis1/java/trunk/maven/maven-wsdl2java-plugin/src/main/java/org/apache/axis/maven/wsdl2java/CustomizableBaseTypeMapping.java?rev=1302659&view=auto ============================================================================== --- axis/axis1/java/trunk/maven/maven-wsdl2java-plugin/src/main/java/org/apache/axis/maven/wsdl2java/CustomizableBaseTypeMapping.java (added) +++ axis/axis1/java/trunk/maven/maven-wsdl2java-plugin/src/main/java/org/apache/axis/maven/wsdl2java/CustomizableBaseTypeMapping.java Mon Mar 19 21:15:52 2012 @@ -0,0 +1,44 @@ +/* + * 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.axis.maven.wsdl2java; + +import java.util.HashMap; +import java.util.Map; + +import javax.xml.namespace.QName; + +import org.apache.axis.wsdl.symbolTable.BaseTypeMapping; + +public class CustomizableBaseTypeMapping extends BaseTypeMapping { + private final BaseTypeMapping parent; + private final Map/*<QName,String>*/ mappings = new HashMap(); + + public CustomizableBaseTypeMapping(BaseTypeMapping parent) { + this.parent = parent; + } + + public void addMapping(QName xmlType, String javaType) { + mappings.put(xmlType, javaType); + } + + public String getBaseName(QName qName) { + String javaType = (String)mappings.get(qName); + return javaType != null ? javaType : parent.getBaseName(qName); + } +} Propchange: axis/axis1/java/trunk/maven/maven-wsdl2java-plugin/src/main/java/org/apache/axis/maven/wsdl2java/CustomizableBaseTypeMapping.java ------------------------------------------------------------------------------ svn:eol-style = native Added: axis/axis1/java/trunk/maven/maven-wsdl2java-plugin/src/main/java/org/apache/axis/maven/wsdl2java/JavaXmlTypeMapping.java URL: http://svn.apache.org/viewvc/axis/axis1/java/trunk/maven/maven-wsdl2java-plugin/src/main/java/org/apache/axis/maven/wsdl2java/JavaXmlTypeMapping.java?rev=1302659&view=auto ============================================================================== --- axis/axis1/java/trunk/maven/maven-wsdl2java-plugin/src/main/java/org/apache/axis/maven/wsdl2java/JavaXmlTypeMapping.java (added) +++ axis/axis1/java/trunk/maven/maven-wsdl2java-plugin/src/main/java/org/apache/axis/maven/wsdl2java/JavaXmlTypeMapping.java Mon Mar 19 21:15:52 2012 @@ -0,0 +1,40 @@ +/* + * 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.axis.maven.wsdl2java; + +public class JavaXmlTypeMapping { + private String javaType; + private String xmlType; + + public String getJavaType() { + return javaType; + } + + public void setJavaType(String javaType) { + this.javaType = javaType; + } + + public String getXmlType() { + return xmlType; + } + + public void setXmlType(String xmlType) { + this.xmlType = xmlType; + } +} Propchange: axis/axis1/java/trunk/maven/maven-wsdl2java-plugin/src/main/java/org/apache/axis/maven/wsdl2java/JavaXmlTypeMapping.java ------------------------------------------------------------------------------ svn:eol-style = native Added: axis/axis1/java/trunk/maven/maven-wsdl2java-plugin/src/site/apt/java-xml-type-mappings.apt.vm URL: http://svn.apache.org/viewvc/axis/axis1/java/trunk/maven/maven-wsdl2java-plugin/src/site/apt/java-xml-type-mappings.apt.vm?rev=1302659&view=auto ============================================================================== --- axis/axis1/java/trunk/maven/maven-wsdl2java-plugin/src/site/apt/java-xml-type-mappings.apt.vm (added) +++ axis/axis1/java/trunk/maven/maven-wsdl2java-plugin/src/site/apt/java-xml-type-mappings.apt.vm Mon Mar 19 21:15:52 2012 @@ -0,0 +1,52 @@ +~~ 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. + + ------------ + Changing the Java class associated with an XML type + ------------ + + +Changing the Java class associated with an XML type + + maven-wsdl2java-plugin uses the default mappings between XML types and Java classes determined by the + configured <<<typeMappingVersion>>>. However, there may be situations where you might want + to represent a given XML type using a Java type other than the one determined by the default mapping. + E.g. you might want <<<xs:base64Binary>>> to be represented by <<<java.activation.DataHandler>>> + instead of the default <<<byte[]>>>. This can be achieved using the <<<javaXmlTypeMappings>>> parameter + as shown in the following sample: + +%{snippet|id=javaXmlTypeMappings|file=${project.basedir}/../../samples/mtomstub-sample/pom.xml} + + Note the unusual way to represent the QName of the XML type (which the plugin uses to work around a + restriction in Maven). + + This feature is similar to the <<<java-xml-type-mapping>>> element in the JAX-RPC mapping file defined by the + Enterprise Web Services 1.1 specification. + + In addition to specifying a <<<javaXmlTypeMapping>>>, you also need to make sure that a corresponding + type mapping is registered at runtime. This is typically done by adding an appropriate <<<typeMapping>>> + element in the relevant WSDD file. + +* Example: consuming an MTOM enabled Web service + + By default stubs generated using wsdl2java don't support MTOM, although Axis has the necessary + serializers/deserializers that recognize <<<xop:Include>>> elements and that use <<<java.activation.DataHandler>>> + to represent the binary data in Java. To enable them, map the <<<xs:base64Binary>>> type to + <<<java.activation.DataHandler>>> as shown above and set up a <<<client-config.wsdd>>> file with the + following type mapping: + +%{snippet|id=typeMapping|file=${project.basedir}/../../samples/mtomstub-sample/src/main/resources/client-config.wsdd} Modified: axis/axis1/java/trunk/maven/maven-wsdl2java-plugin/src/site/site.xml URL: http://svn.apache.org/viewvc/axis/axis1/java/trunk/maven/maven-wsdl2java-plugin/src/site/site.xml?rev=1302659&r1=1302658&r2=1302659&view=diff ============================================================================== --- axis/axis1/java/trunk/maven/maven-wsdl2java-plugin/src/site/site.xml (original) +++ axis/axis1/java/trunk/maven/maven-wsdl2java-plugin/src/site/site.xml Mon Mar 19 21:15:52 2012 @@ -23,5 +23,8 @@ <item name="Introduction" href="index.html"/> <item name="Goals" href="plugin-info.html"/> </menu> + <menu name="Examples"> + <item name="Changing the Java class associated with an XML type" href="java-xml-type-mappings.html"/> + </menu> </body> </project> Propchange: axis/axis1/java/trunk/samples/mtomstub-sample/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Mon Mar 19 21:15:52 2012 @@ -0,0 +1,4 @@ +.classpath +.project +target +.settings Added: axis/axis1/java/trunk/samples/mtomstub-sample/pom.xml URL: http://svn.apache.org/viewvc/axis/axis1/java/trunk/samples/mtomstub-sample/pom.xml?rev=1302659&view=auto ============================================================================== --- axis/axis1/java/trunk/samples/mtomstub-sample/pom.xml (added) +++ axis/axis1/java/trunk/samples/mtomstub-sample/pom.xml Mon Mar 19 21:15:52 2012 @@ -0,0 +1,129 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ 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. + --> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.axis</groupId> + <artifactId>samples</artifactId> + <version>1.4.1-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + <artifactId>mtomstub-sample</artifactId> + <name>MTOM Stub Sample</name> + <description> + Shows how to enable MTOM on the client side with stubs generated by wsdl2java. + </description> + <properties> + <cxf.version>2.4.4</cxf.version> + </properties> + <dependencies> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>axis</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-frontend-jaxws</artifactId> + <version>${cxf.version}</version> + </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-transports-http-jetty</artifactId> + <version>${cxf.version}</version> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + <dependencyManagement> + <dependencies> + <!-- Ensure that we have a version of wsdl4j that is recent enough for CXF --> + <dependency> + <groupId>wsdl4j</groupId> + <artifactId>wsdl4j</artifactId> + <version>1.6.2</version> + </dependency> + </dependencies> + </dependencyManagement> + <build> + <plugins> + <plugin> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <source>1.5</source> + <target>1.5</target> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-java2ws-plugin</artifactId> + <version>${cxf.version}</version> + <executions> + <execution> + <id>process-classes</id> + <phase>process-classes</phase> + <configuration> + <className>samples.mtomstub.service.DownloadFile</className> + <genWsdl>true</genWsdl> + </configuration> + <goals> + <goal>java2ws</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>${project.groupId}</groupId> + <artifactId>maven-wsdl2java-plugin</artifactId> + <version>${project.version}</version> + <configuration> + <output>${project.build.directory}/generated/src</output> + </configuration> + <executions> + <execution> + <goals> + <goal>wsdl2java-test</goal> + </goals> + <configuration> + <file>${project.build.directory}/generated/wsdl/DownloadFile.wsdl</file> + <mappings> + <mapping> + <namespace>http://service.mtomstub.samples/</namespace> + <package>samples.mtomstub.stub</package> + </mapping> + </mappings> +<!-- START SNIPPET: javaXmlTypeMappings --> + <javaXmlTypeMappings> + <javaXmlTypeMapping> + <xmlType>{http://www.w3.org/2001/XMLSchema}base64Binary</xmlType> + <javaType>javax.activation.DataHandler</javaType> + </javaXmlTypeMapping> + </javaXmlTypeMappings> +<!-- END SNIPPET: javaXmlTypeMappings --> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> Propchange: axis/axis1/java/trunk/samples/mtomstub-sample/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Added: axis/axis1/java/trunk/samples/mtomstub-sample/src/main/java/samples/mtomstub/service/DownloadFile.java URL: http://svn.apache.org/viewvc/axis/axis1/java/trunk/samples/mtomstub-sample/src/main/java/samples/mtomstub/service/DownloadFile.java?rev=1302659&view=auto ============================================================================== --- axis/axis1/java/trunk/samples/mtomstub-sample/src/main/java/samples/mtomstub/service/DownloadFile.java (added) +++ axis/axis1/java/trunk/samples/mtomstub-sample/src/main/java/samples/mtomstub/service/DownloadFile.java Mon Mar 19 21:15:52 2012 @@ -0,0 +1,10 @@ +package samples.mtomstub.service; + +import javax.jws.WebService; +import javax.xml.ws.soap.MTOM; + +@WebService +@MTOM +public interface DownloadFile { + ResponseDownloadFile getFile() throws Exception; +} Propchange: axis/axis1/java/trunk/samples/mtomstub-sample/src/main/java/samples/mtomstub/service/DownloadFile.java ------------------------------------------------------------------------------ svn:eol-style = native Added: axis/axis1/java/trunk/samples/mtomstub-sample/src/main/java/samples/mtomstub/service/DownloadFileImpl.java URL: http://svn.apache.org/viewvc/axis/axis1/java/trunk/samples/mtomstub-sample/src/main/java/samples/mtomstub/service/DownloadFileImpl.java?rev=1302659&view=auto ============================================================================== --- axis/axis1/java/trunk/samples/mtomstub-sample/src/main/java/samples/mtomstub/service/DownloadFileImpl.java (added) +++ axis/axis1/java/trunk/samples/mtomstub-sample/src/main/java/samples/mtomstub/service/DownloadFileImpl.java Mon Mar 19 21:15:52 2012 @@ -0,0 +1,17 @@ +package samples.mtomstub.service; + +import javax.activation.DataHandler; +import javax.jws.WebService; +import javax.mail.util.ByteArrayDataSource; + +@WebService(endpointInterface="samples.mtomstub.service.DownloadFile", serviceName = "DownloadFileWS") +public class DownloadFileImpl implements DownloadFile { + public ResponseDownloadFile getFile() throws Exception { + ResponseDownloadFile rdf = new ResponseDownloadFile(); + String contentType = "text/plain; charset='UTF-8'"; + rdf.setFileName("readme.txt"); + rdf.setFileType(contentType); + rdf.setFile(new DataHandler(new ByteArrayDataSource("This is the content".getBytes("UTF-8"), contentType))); + return rdf; + } +} Propchange: axis/axis1/java/trunk/samples/mtomstub-sample/src/main/java/samples/mtomstub/service/DownloadFileImpl.java ------------------------------------------------------------------------------ svn:eol-style = native Added: axis/axis1/java/trunk/samples/mtomstub-sample/src/main/java/samples/mtomstub/service/ResponseDownloadFile.java URL: http://svn.apache.org/viewvc/axis/axis1/java/trunk/samples/mtomstub-sample/src/main/java/samples/mtomstub/service/ResponseDownloadFile.java?rev=1302659&view=auto ============================================================================== --- axis/axis1/java/trunk/samples/mtomstub-sample/src/main/java/samples/mtomstub/service/ResponseDownloadFile.java (added) +++ axis/axis1/java/trunk/samples/mtomstub-sample/src/main/java/samples/mtomstub/service/ResponseDownloadFile.java Mon Mar 19 21:15:52 2012 @@ -0,0 +1,33 @@ +package samples.mtomstub.service; + +import javax.activation.DataHandler; + +public class ResponseDownloadFile { + private String fileName; + private String fileType; + private DataHandler file; + + public String getFileName() { + return fileName; + } + + public void setFileName(String fileName) { + this.fileName = fileName; + } + + public String getFileType() { + return fileType; + } + + public void setFileType(String fileType) { + this.fileType = fileType; + } + + public DataHandler getFile() { + return file; + } + + public void setFile(DataHandler file) { + this.file = file; + } +} Propchange: axis/axis1/java/trunk/samples/mtomstub-sample/src/main/java/samples/mtomstub/service/ResponseDownloadFile.java ------------------------------------------------------------------------------ svn:eol-style = native Added: axis/axis1/java/trunk/samples/mtomstub-sample/src/main/resources/client-config.wsdd URL: http://svn.apache.org/viewvc/axis/axis1/java/trunk/samples/mtomstub-sample/src/main/resources/client-config.wsdd?rev=1302659&view=auto ============================================================================== --- axis/axis1/java/trunk/samples/mtomstub-sample/src/main/resources/client-config.wsdd (added) +++ axis/axis1/java/trunk/samples/mtomstub-sample/src/main/resources/client-config.wsdd Mon Mar 19 21:15:52 2012 @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> +<deployment name="defaultClientConfig" + xmlns="http://xml.apache.org/axis/wsdd/" + xmlns:java="http://xml.apache.org/axis/wsdd/providers/java" + xmlns:xs="http://www.w3.org/2001/XMLSchema"> + <globalConfiguration> + <parameter name="disablePrettyXML" value="true"/> + <parameter name="enableNamespacePrefixOptimization" value="false"/> + </globalConfiguration> + <transport name="http" pivot="java:org.apache.axis.transport.http.HTTPSender"/> + <transport name="local" pivot="java:org.apache.axis.transport.local.LocalSender"/> + <transport name="java" pivot="java:org.apache.axis.transport.java.JavaSender"/> +<!-- START SNIPPET: typeMapping --> + <typeMapping languageSpecificType="java:javax.activation.DataHandler" qname="xs:base64Binary" + deserializer="org.apache.axis.encoding.ser.JAFDataHandlerDeserializerFactory" + serializer="org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory" + encodingStyle=""/> +<!-- END SNIPPET: typeMapping --> +</deployment> + Added: axis/axis1/java/trunk/samples/mtomstub-sample/src/test/java/samples/mtomstub/TestDownloadFile.java URL: http://svn.apache.org/viewvc/axis/axis1/java/trunk/samples/mtomstub-sample/src/test/java/samples/mtomstub/TestDownloadFile.java?rev=1302659&view=auto ============================================================================== --- axis/axis1/java/trunk/samples/mtomstub-sample/src/test/java/samples/mtomstub/TestDownloadFile.java (added) +++ axis/axis1/java/trunk/samples/mtomstub-sample/src/test/java/samples/mtomstub/TestDownloadFile.java Mon Mar 19 21:15:52 2012 @@ -0,0 +1,21 @@ +package samples.mtomstub; + +import java.net.URL; + +import javax.xml.ws.Endpoint; + +import junit.framework.TestCase; +import samples.mtomstub.service.DownloadFileImpl; +import samples.mtomstub.stub.DownloadFile; +import samples.mtomstub.stub.DownloadFileServiceLocator; + +public class TestDownloadFile extends TestCase { + public void test() throws Exception { + // TODO: allocate random port here + String url = "http://localhost:8080/DownloadFile"; + Endpoint endpoint = Endpoint.publish(url, new DownloadFileImpl()); + DownloadFile downloadFile = new DownloadFileServiceLocator().getDownloadFilePort(new URL(url)); + downloadFile.getFile().getFile().writeTo(System.out); + endpoint.stop(); + } +} Propchange: axis/axis1/java/trunk/samples/mtomstub-sample/src/test/java/samples/mtomstub/TestDownloadFile.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: axis/axis1/java/trunk/samples/pom.xml URL: http://svn.apache.org/viewvc/axis/axis1/java/trunk/samples/pom.xml?rev=1302659&r1=1302658&r2=1302659&view=diff ============================================================================== --- axis/axis1/java/trunk/samples/pom.xml (original) +++ axis/axis1/java/trunk/samples/pom.xml Mon Mar 19 21:15:52 2012 @@ -41,6 +41,7 @@ <module>jaxm-sample</module> <module>jaxrpc-sample</module> <module>message-sample</module> + <module>mtomstub-sample</module> <module>misc-sample</module> <module>proxy-sample</module> <module>stock-sample</module> Modified: axis/axis1/java/trunk/src/site/apt/changelogs/1_4_1.apt URL: http://svn.apache.org/viewvc/axis/axis1/java/trunk/src/site/apt/changelogs/1_4_1.apt?rev=1302659&r1=1302658&r2=1302659&view=diff ============================================================================== --- axis/axis1/java/trunk/src/site/apt/changelogs/1_4_1.apt (original) +++ axis/axis1/java/trunk/src/site/apt/changelogs/1_4_1.apt Mon Mar 19 21:15:52 2012 @@ -38,4 +38,9 @@ Changes from 1.4 final as a drop-in replacement for <<<HTTPSender>>>. However, it requires Java 1.5 because it relies on features of the <<<java.net.HttpURLConnection>>> API that were not available in earlier Java versions. + + * It is now possible to change the Java class associated with an XML type when generating a client stub. + Note that this is only supported by the maven-wsdl2java-plugin, but not by the corresponding Ant task + or command line tool. The feature can be used to consume MTOM enabled services. Check the + {{{../maven/maven-wsdl2java-plugin/java-xml-type-mappings.html}plugin documentation}} for more information.