blob: b228983d26b3cd0df66606daf0ee4d8c531313c0 [file] [log] [blame]
<!DOCTYPE html>
<!--
| Generated by Apache Maven Doxia at 2015-07-03
| Rendered using Apache Maven Fluido Skin 1.3.0
-->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="Date-Revision-yyyymmdd" content="20150703" />
<meta http-equiv="Content-Language" content="en" />
<title>wsdl2java-maven-plugin &#x2013; Changing the Java class associated with an XML type</title>
<link rel="stylesheet" href="./css/apache-maven-fluido-1.3.0.min.css" />
<link rel="stylesheet" href="./css/site.css" />
<link rel="stylesheet" href="./css/print.css" media="print" />
<script type="text/javascript" src="./js/apache-maven-fluido-1.3.0.min.js"></script>
</head>
<body class="topBarDisabled">
<div class="container-fluid">
<div id="banner">
<div class="pull-left">
<div id="bannerLeft">
<h2>wsdl2java-maven-plugin</h2>
</div>
</div>
<div class="pull-right"> <a href="../.." id="bannerRight">
<img src="../../images/axis-small.png" alt="Apache Axis"/>
</a>
</div>
<div class="clear"><hr/></div>
</div>
<div id="breadcrumbs">
<ul class="breadcrumb">
<li class="">
<a href="http://www.apache.org/" class="externalLink" title="Apache">
Apache</a>
</li>
<li class="divider ">/</li>
<li class="">
<a href="../../../../" title="Axis">
Axis</a>
</li>
<li class="divider ">/</li>
<li class="">
<a href="../../../" title="Axis 1.x">
Axis 1.x</a>
</li>
<li class="divider ">/</li>
<li class="">
<a href="../../" title="Java">
Java</a>
</li>
<li class="divider ">/</li>
<li class="">
<a href="../" title="Maven plugins">
Maven plugins</a>
</li>
<li class="divider ">/</li>
<li class="">
<a href="./" title="wsdl2java-maven-plugin">
wsdl2java-maven-plugin</a>
</li>
<li class="divider ">/</li>
<li class="">Changing the Java class associated with an XML type</li>
<li id="publishDate" class="pull-right">Last Published: 2015-07-03</li> <li class="divider pull-right">|</li>
<li id="projectVersion" class="pull-right">Version: 1.4.1-SNAPSHOT</li>
</ul>
</div>
<div class="row-fluid">
<div id="leftColumn" class="span3">
<div class="well sidebar-nav">
<ul class="nav nav-list">
<li class="nav-header">Overview</li>
<li>
<a href="index.html" title="Introduction">
<i class="none"></i>
Introduction</a>
</li>
<li>
<a href="plugin-info.html" title="Goals">
<i class="none"></i>
Goals</a>
</li>
<li class="nav-header">Examples</li>
<li class="active">
<a href="#"><i class="none"></i>Changing the Java class associated with an XML type</a>
</li>
<li class="nav-header">Apache</li>
<li>
<a href="http://www.apache.org/licenses/LICENSE-2.0.html" class="externalLink" title="License">
<i class="none"></i>
License</a>
</li>
<li>
<a href="http://www.apache.org/foundation/sponsorship.html" class="externalLink" title="Sponsorship">
<i class="none"></i>
Sponsorship</a>
</li>
<li>
<a href="http://www.apache.org/foundation/thanks.html" class="externalLink" title="Thanks">
<i class="none"></i>
Thanks</a>
</li>
<li>
<a href="http://www.apache.org/security/" class="externalLink" title="Security">
<i class="none"></i>
Security</a>
</li>
</ul>
<form id="search-form" action="http://www.google.com/search" method="get" >
<input value="ws.apache.org/axis/java" name="sitesearch" type="hidden"/>
<input class="search-query" name="q" id="query" type="text" />
</form>
<script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=search-form"></script>
<hr class="divider" />
<div id="poweredBy">
<div class="clear"></div>
<div class="clear"></div>
<div class="clear"></div>
<a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy">
<img class="builtBy" alt="Built by Maven" src="./images/logos/maven-feather.png" />
</a>
</div>
</div>
</div>
<div id="bodyColumn" class="span9" >
<!-- 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. --><div class="section">
<h2><a name="Changing_the_Java_class_associated_with_an_XML_type"></a>Changing the Java class associated with an XML type</h2>
<p>wsdl2java-maven-plugin uses the default mappings between XML types and Java classes determined by the configured <tt>typeMappingVersion</tt>. 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 <tt>xs:base64Binary</tt> to be represented by <tt>java.activation.DataHandler</tt> instead of the default <tt>byte[]</tt>. This can be achieved using the <tt>javaXmlTypeMappings</tt> parameter as shown in the following sample:</p>
<div class="source">
<pre>&lt;javaXmlTypeMappings&gt;
&lt;javaXmlTypeMapping&gt;
&lt;xmlType&gt;{http://www.w3.org/2001/XMLSchema}base64Binary&lt;/xmlType&gt;
&lt;javaType&gt;javax.activation.DataHandler&lt;/javaType&gt;
&lt;/javaXmlTypeMapping&gt;
&lt;/javaXmlTypeMappings&gt;
</pre></div>
<p>Note the unusual way to represent the QName of the XML type (which the plugin uses to work around a restriction in Maven).</p>
<p>This feature is similar to the <tt>java-xml-type-mapping</tt> element in the JAX-RPC mapping file defined by the Enterprise Web Services 1.1 specification.</p>
<p>In addition to specifying a <tt>javaXmlTypeMapping</tt>, you also need to make sure that a corresponding type mapping is registered at runtime. This is typically done by adding an appropriate <tt>typeMapping</tt> element in the relevant WSDD file.</p>
<div class="section">
<h3><a name="Example:_consuming_an_MTOM_enabled_Web_service"></a>Example: consuming an MTOM enabled Web service</h3>
<p>By default stubs generated using wsdl2java don't support MTOM, although Axis has the necessary serializers/deserializers that recognize <tt>xop:Include</tt> elements and that use <tt>java.activation.DataHandler</tt> to represent the binary data in Java. To enable them, map the <tt>xs:base64Binary</tt> type to <tt>java.activation.DataHandler</tt> as shown above and set up a <tt>client-config.wsdd</tt> file with the following type mapping:</p>
<div class="source">
<pre>&lt;typeMapping languageSpecificType=&quot;java:javax.activation.DataHandler&quot; qname=&quot;xs:base64Binary&quot;
deserializer=&quot;org.apache.axis.encoding.ser.JAFDataHandlerDeserializerFactory&quot;
serializer=&quot;org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory&quot;
encodingStyle=&quot;&quot;/&gt;
</pre></div></div></div>
</div>
</div>
</div>
<hr/>
<footer>
<div class="container-fluid">
<div class="row span12">Copyright &copy; 2000-2015
<a href="http://www.apache.org/">The Apache Software Foundation</a>.
All Rights Reserved.
</div>
</div>
</footer>
</body>
</html>