Author: buildbot
Date: Fri Apr 13 09:57:33 2018
New Revision: 1028345
Log:
Production update by buildbot for cxf
Modified:
websites/production/cxf/content/cache/docs.pageCache
websites/production/cxf/content/docs/defining-contract-first-webservices-with-wsdl-generation-from-java.html
websites/production/cxf/content/docs/features.html
websites/production/cxf/content/docs/maven-cxf-codegen-plugin-wsdl-to-java.html
Modified: websites/production/cxf/content/cache/docs.pageCache
==============================================================================
Binary files - no diff available.
Modified:
websites/production/cxf/content/docs/defining-contract-first-webservices-with-wsdl-generation-from-java.html
==============================================================================
---
websites/production/cxf/content/docs/defining-contract-first-webservices-with-wsdl-generation-from-java.html
(original)
+++
websites/production/cxf/content/docs/defining-contract-first-webservices-with-wsdl-generation-from-java.html
Fri Apr 13 09:57:33 2018
@@ -32,9 +32,9 @@
<link type="text/css" rel="stylesheet"
href="/resources/highlighter/styles/shThemeCXF.css">
<script src='/resources/highlighter/scripts/shCore.js'></script>
-<script src='/resources/highlighter/scripts/shBrushBash.js'></script>
-<script src='/resources/highlighter/scripts/shBrushXml.js'></script>
<script src='/resources/highlighter/scripts/shBrushJava.js'></script>
+<script src='/resources/highlighter/scripts/shBrushXml.js'></script>
+<script src='/resources/highlighter/scripts/shBrushBash.js'></script>
<script>
SyntaxHighlighter.defaults['toolbar'] = false;
SyntaxHighlighter.all();
@@ -118,26 +118,8 @@ Apache CXF -- Defining Contract first we
<td height="100%">
<!-- Content -->
<div class="wiki-content">
-<div id="ConfluenceContent"><p>In this post I will describe how to do contract
first in a very simple and efficient way. All people involved in webservice
design have the problem what tool to use to describe the webservice interface.
Of course there are wsdl editors but you can make many errors in using them and
they are normally not very intuitive.<br clear="none">
-<a shape="rect" class="external-link"
href="http://www.liquid-reality.de/display/liquid/2008/08/20/Defining+Contract+first+webservices+by+generating+wsdl+from+java"
rel="nofollow">The original post is from Christian Schneider´s blog and
can be found here</a></p>
-
-<h2
id="DefiningContractfirstwebserviceswithwsdlgenerationfromjava-Whatwewouldliketohave">What
we would like to have</h2>
-
-<p>Ideally I would imagine to have a domain specific language that makes
designing the webservice very easy and fail safe. Then there should be an IDE
that supports me in writing the DSL. Either with content assist or with a
graphical editor. In any case the IDE should check the DSL while it is entered
and help me to do the right thing. Some people favor using Model Driven Design
tools to do this job but it is quite hard finding good tools and configuring
them for the job.</p>
-
-<h2
id="DefiningContractfirstwebserviceswithwsdlgenerationfromjava-WhichtoolsdidIchooseandwhy">Which
tools did I choose and why</h2>
-
-<p>I wanted to go some way in the direction of a DSL for webservices but
without using a big MDD tool. So I thought about how to have most advantages of
a DSL with just Java and the normal Eclipse IDE. So I needed Java code that
looks almost like a DSL and a tool to generate the webservice out of it. For
the WSDl generation I used Apache CXF with JAXWS and JAXB annotations to
describe the webservice. While this setup is quite standard I focused on
keeping the syntax as simple as possible.</p>
-
-<h2
id="DefiningContractfirstwebserviceswithwsdlgenerationfromjava-SohowdoestheDSLlooklike">So
how does the DSL look like</h2>
-
-<p>To describe a data object I use a java class with just attributes. The
Namespace will come from the package name. To make JAXB understand this syntax
only one annotation is necessary. Of course some more annotations are necessary
if you want to use special fetaures.</p>
-
-<h3
id="DefiningContractfirstwebserviceswithwsdlgenerationfromjava-Customerdatatype">Customer
datatype</h3>
-
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
-package com.example.customerservice;
+<div id="ConfluenceContent"><p>In this post I will describe how to do contract
first in a very simple and efficient way. All people involved in webservice
design have the problem what tool to use to describe the webservice interface.
Of course there are wsdl editors but you can make many errors in using them and
they are normally not very intuitive.<br clear="none"> <a shape="rect"
class="external-link"
href="http://www.liquid-reality.de/display/liquid/2008/08/20/Defining+Contract+first+webservices+by+generating+wsdl+from+java"
rel="nofollow">The original post is from Christian Schneider´s blog and
can be found here</a></p><h2
id="DefiningContractfirstwebserviceswithwsdlgenerationfromjava-Whatwewouldliketohave">What
we would like to have</h2><p>Ideally I would imagine to have a domain specific
language that makes designing the webservice very easy and fail safe. Then
there should be an IDE that supports me in writing the DSL. Either with content
assist or with a graphical edito
r. In any case the IDE should check the DSL while it is entered and help me to
do the right thing. Some people favor using Model Driven Design tools to do
this job but it is quite hard finding good tools and configuring them for the
job.</p><h2
id="DefiningContractfirstwebserviceswithwsdlgenerationfromjava-WhichtoolsdidIchooseandwhy">Which
tools did I choose and why</h2><p>I wanted to go some way in the direction of
a DSL for webservices but without using a big MDD tool. So I thought about how
to have most advantages of a DSL with just Java and the normal Eclipse IDE. So
I needed Java code that looks almost like a DSL and a tool to generate the
webservice out of it. For the WSDL generation I used Apache CXF with JAXWS and
JAXB annotations to describe the webservice. While this setup is quite standard
I focused on keeping the syntax as simple as possible.</p><h2
id="DefiningContractfirstwebserviceswithwsdlgenerationfromjava-SohowdoestheDSLlooklike">So
how does the DSL look like</h2><
p>To describe a data object I use a java class with just attributes. The
Namespace will come from the package name. To make JAXB understand this syntax
only one annotation is necessary. Of course some more annotations are necessary
if you want to use special features.</p><h3
id="DefiningContractfirstwebserviceswithwsdlgenerationfromjava-Customerdatatype">Customer
datatype</h3><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">package com.example.customerservice;
@XmlAccessorType( XmlAccessType.FIELD )
public class Customer {
@@ -150,28 +132,15 @@ public class Customer {
CustomerType type;
}
</pre>
-</div></div>
-<p>The sample class Customer gives a nice overview which primitive datatypes
can be used. Additionally you can create arrays of primitive or class datatypes
in this way. The complete example also contains an enumeration definition to
show this is possible. I think this code is quite near the DSL I would imagine
to describe my services.</p>
-
-<h3
id="DefiningContractfirstwebserviceswithwsdlgenerationfromjava-EnumerationCustomerType">Enumeration
CustomerType</h3>
-
-<p>Shows how enumerations are handled:</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
-package com.example.customerservice;
+</div></div><p>The sample class Customer gives a nice overview which primitive
datatypes can be used. Additionally you can create arrays of primitive or class
datatypes in this way. The complete example also contains an enumeration
definition to show this is possible. I think this code is quite near the DSL I
would imagine to describe my services.</p><h3
id="DefiningContractfirstwebserviceswithwsdlgenerationfromjava-EnumerationCustomerType">Enumeration
CustomerType</h3><p>Shows how enumerations are handled:</p><div class="code
panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">package com.example.customerservice;
public enum CustomerType {
PRIVATE, BUSINESS
}
</pre>
-</div></div>
-
-<h3
id="DefiningContractfirstwebserviceswithwsdlgenerationfromjava-NoSuchCustomerException">NoSuchCustomerException</h3>
-
-<p> Defining Exceptions is a little tricky as the default behaviour is to
create Exception_Exception classes in the later generated Java code. So we have
to use the @WebFault annotation to give the Bean for the data a name that is
separate from the Exception name.</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
-package com.example.customerservice;
+</div></div><h3
id="DefiningContractfirstwebserviceswithwsdlgenerationfromjava-NoSuchCustomerException">NoSuchCustomerException</h3><p>Defining
Exceptions is a little tricky as the default behaviour is to create
Exception_Exception classes in the later generated Java code. So we have to use
the @WebFault annotation to give the Bean for the data a name that is separate
from the Exception name.</p><div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">package com.example.customerservice;
@WebFault(name="NoSuchCustomer")
@XmlAccessorType( XmlAccessType.FIELD )
@@ -183,33 +152,16 @@ public class NoSuchCustomerException ext
String customerName;
}
</pre>
-</div></div>
-
-<h3
id="DefiningContractfirstwebserviceswithwsdlgenerationfromjava-Servicedefinition">Service
definition</h3>
-
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
-package com.example.customerservice;
+</div></div><h3
id="DefiningContractfirstwebserviceswithwsdlgenerationfromjava-Servicedefinition">Service
definition</h3><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">package com.example.customerservice;
@WebService
public interface CustomerService {
public Customer[] getCustomersByName(@WebParam(name="name") String name)
throws NoSuchCustomerException;
}
</pre>
-</div></div>
-<p>As you can see only two annotations are necessary here. @WebService marks
the interface as a service and @Webparam is necessary as Java will else lose
the name of the parameter and the wsdl will contain arg0 instead of the desired
name. Using the @WebService annotation you can also customize the port name and
service name.</p>
-
-<h2
id="DefiningContractfirstwebserviceswithwsdlgenerationfromjava-Howisthewsdlgenerated">How
is the wsdl generated</h2>
-
-<p>To generate the wsdl the maven plugin cxf-java2ws-plugin is used. See the
pom.xml in the complete example for details.
-<br clear="none" class="atl-forced-newline"></p>
-
-<h2
id="DefiningContractfirstwebserviceswithwsdlgenerationfromjava-Let´stakealookattheresultingWSDL">Let´s
take a look at the resulting WSDL</h2>
-
-<p>You can <a shape="rect"
href="defining-contract-first-webservices-with-wsdl-generation-from-java.data/CustomerService.wsdl?version=2&modificationDate=1219326152000&api=v2"
data-linked-resource-id="59672633" data-linked-resource-version="2"
data-linked-resource-type="attachment"
data-linked-resource-default-alias="CustomerService.wsdl"
data-linked-resource-content-type="application/wsdl+xml"
data-linked-resource-container-id="93162"
data-linked-resource-container-version="15">download the wsdl this example
creates here</a>.</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
-<xs:complexType name="customer">
+</div></div><p>As you can see only two annotations are necessary here.
@WebService marks the interface as a service and @Webparam is necessary as Java
will else lose the name of the parameter and the wsdl will contain arg0 instead
of the desired name. Using the @WebService annotation you can also customize
the port name and service name.</p><h2
id="DefiningContractfirstwebserviceswithwsdlgenerationfromjava-Howisthewsdlgenerated">How
is the wsdl generated</h2><p>To generate the wsdl the maven plugin
cxf-java2ws-plugin is used. See the pom.xml in the complete example for
details.</p><h2
id="DefiningContractfirstwebserviceswithwsdlgenerationfromjava-Let´stakealookattheresultingWSDL">Let´s
take a look at the resulting WSDL</h2><p>You can <a shape="rect"
href="defining-contract-first-webservices-with-wsdl-generation-from-java.data/CustomerService.wsdl?version=2&modificationDate=1219326152000&api=v2"
data-linked-resource-id="59672633" data-linked-resource-version="2" dat
a-linked-resource-type="attachment"
data-linked-resource-default-alias="CustomerService.wsdl"
data-linked-resource-content-type="application/wsdl+xml"
data-linked-resource-container-id="93162"
data-linked-resource-container-version="16">download the wsdl this example
creates here</a>.</p><div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;"><xs:complexType name="customer">
<xs:sequence>
<xs:element minOccurs="0" name="name" type="xs:string"/>
<xs:element maxOccurs="unbounded" minOccurs="0" name="address"
nillable="true" type="xs:string"/>
@@ -221,33 +173,16 @@ public interface CustomerService {
</xs:sequence>
</xs:complexType>
</pre>
-</div></div>
-<p>The customer Class is a complex type in xsd. As you can see the Java types
have been described as their respective XSD primitive types.</p>
-
-<p>Each element has minOccurs="0" which marks it as optional. This is a good
thing as you can add new optional elements and keep compatible. If you do not
want this optionality you can use @XmlElement(required=true).</p>
-
-<p>The array of Strings for address is described as maxOccurs="unbounded" so
the element may be repeated in the later xml to form the array.</p>
-
-<h3
id="DefiningContractfirstwebserviceswithwsdlgenerationfromjava-EnumerationcustomerType">Enumeration
customerType</h3>
-
-<p>The enumeration customerType is described as a simple type with a
restriction:</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
-<xs:simpleType name="customerType">
+</div></div><p>The customer Class is a complex type in xsd. As you can see the
Java types have been described as their respective XSD primitive
types.</p><p>Each element has minOccurs="0" which marks it as optional. This is
a good thing as you can add new optional elements and keep compatible. If you
do not want this optionality you can use @XmlElement(required=true).</p><p>The
array of Strings for address is described as maxOccurs="unbounded" so the
element may be repeated in the later xml to form the array.</p><h3
id="DefiningContractfirstwebserviceswithwsdlgenerationfromjava-EnumerationcustomerType">Enumeration
customerType</h3><p>The enumeration customerType is described as a simple type
with a restriction:</p><div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;"><xs:simpleType name="customerType">
<xs:restriction base="xs:string">
<xs:enumeration value="PRIVATE"/>
<xs:enumeration value="BUSINESS"/>
</xs:restriction>
</xs:simpleType>
</pre>
-</div></div>
-
-<h3
id="DefiningContractfirstwebserviceswithwsdlgenerationfromjava-FaultNoSuchCustomerException">Fault
NoSuchCustomerException</h3>
-
-<p>The Exception we defined is generated as a complexType with the defined
details and a message for the fault. It is important here that the Element and
the Message have different names. We ensure this by using the @Webfault
Annotation above. Else the later Java Code generation will produce an ugly
Exception name NoSuchCustomerException_Exception.</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
-<xs:element name="NoSuchCustomer" type="tns:NoSuchCustomer"/>
+</div></div><h3
id="DefiningContractfirstwebserviceswithwsdlgenerationfromjava-FaultNoSuchCustomerException">Fault
NoSuchCustomerException</h3><p>The Exception we defined is generated as a
complexType with the defined details and a message for the fault. It is
important here that the Element and the Message have different names. We ensure
this by using the @WebFault Annotation above. Else the later Java Code
generation will produce an ugly Exception name
NoSuchCustomerException_Exception.</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;"><xs:element name="NoSuchCustomer"
type="tns:NoSuchCustomer"/>
<xs:complexType name="NoSuchCustomer">
<xs:sequence>
<xs:element name="customerName" nillable="true"
type="xs:string"/>
@@ -258,22 +193,7 @@ public interface CustomerService {
</wsdl:part>
</wsdl:message>
</pre>
-</div></div>
-<p>The wsdl defines a SOAP/HTTP binding by default but can also be used to
build services based on JMS as I will show in my next post.</p>
-
-<h2
id="DefiningContractfirstwebserviceswithwsdlgenerationfromjava-Summary">Summary</h2>
-
-<p>As you can see the generated WSDL looks quite clean and correctly expresses
the service interface we wanted to describe. In most cases where you are not
satisfied with what the conversion does you can correct the WSDL using JAX-WS
or JAXB annotations. But I recommend to use them sparsly to keep the DSL easy
to read.</p>
-
-<p>In the next post I will show ho to build service consumers and providers
using the WSDL we just built.</p>
-
-<p>You can <a shape="rect"
href="defining-contract-first-webservices-with-wsdl-generation-from-java.data/cxfjava2wsexample.zip?version=1&modificationDate=1219326111000&api=v2"
data-linked-resource-id="8674" data-linked-resource-version="1"
data-linked-resource-type="attachment"
data-linked-resource-default-alias="cxfjava2wsexample.zip" data-nice-type="Zip
Archive" data-linked-resource-content-type="application/x-zip"
data-linked-resource-container-id="93162"
data-linked-resource-container-version="15">download the complete example
here</a>.
-<br clear="none" class="atl-forced-newline"></p>
-
-<h2
id="DefiningContractfirstwebserviceswithwsdlgenerationfromjava-References">References</h2>
-
-<ul><li><a shape="rect" href="http://cxf.apache.org/">Apache
CXF</a></li><li><a shape="rect" class="external-link"
href="http://www.jcp.org/en/jsr/detail?id=224" rel="nofollow">JAX-WS
specification</a> </li><li><a shape="rect" class="external-link"
href="https://jaxb-architecture-document.dev.java.net/nonav/doc/?jaxb/package-summary.html"
rel="nofollow">JAXB Architecture</a></li><li><a shape="rect"
class="external-link" href="https://jaxb.dev.java.net/guide/"
rel="nofollow">JAXB user guide</a></li><li><a shape="rect"
class="external-link"
href="http://java.sun.com/webservices/docs/2.0/tutorial/doc/JAXBWorks.html#wp100322"
rel="nofollow">JAXB Tutorial</a>
-<br clear="none" class="atl-forced-newline"></li></ul></div>
+</div></div><p>The wsdl defines a SOAP/HTTP binding by default but can also be
used to build services based on JMS as I will show in my next post.</p><h2
id="DefiningContractfirstwebserviceswithwsdlgenerationfromjava-Summary">Summary</h2><p>As
you can see the generated WSDL looks quite clean and correctly expresses the
service interface we wanted to describe. In most cases where you are not
satisfied with what the conversion does you can correct the WSDL using JAX-WS
or JAXB annotations. But I recommend to use them sparsely to keep the DSL easy
to read.</p><p>In the next post I will show ho to build service consumers and
providers using the WSDL we just built.</p><p>You can <a shape="rect"
href="defining-contract-first-webservices-with-wsdl-generation-from-java.data/cxfjava2wsexample.zip?version=1&modificationDate=1219326111000&api=v2"
data-linked-resource-id="8674" data-linked-resource-version="1"
data-linked-resource-type="attachment" data-linked-resource-default-alias="cx
fjava2wsexample.zip" data-nice-type="Zip Archive"
data-linked-resource-content-type="application/x-zip"
data-linked-resource-container-id="93162"
data-linked-resource-container-version="16">download the complete example
here</a>.</p><h2
id="DefiningContractfirstwebserviceswithwsdlgenerationfromjava-References">References</h2><ul><li><a
shape="rect" href="http://cxf.apache.org/">Apache CXF</a></li><li><a
shape="rect" class="external-link"
href="http://www.jcp.org/en/jsr/detail?id=224" rel="nofollow">JAX-WS
specification</a> </li><li><a shape="rect" class="external-link"
href="https://jaxb-architecture-document.dev.java.net/nonav/doc/?jaxb/package-summary.html"
rel="nofollow">JAXB Architecture</a></li><li><a shape="rect"
class="external-link" href="https://jaxb.dev.java.net/guide/"
rel="nofollow">JAXB user guide</a></li><li><a shape="rect"
class="external-link"
href="http://java.sun.com/webservices/docs/2.0/tutorial/doc/JAXBWorks.html#wp100322"
rel="nofollow">JAXB Tutorial</a></l
i></ul></div>
</div>
<!-- Content -->
</td>
Modified: websites/production/cxf/content/docs/features.html
==============================================================================
--- websites/production/cxf/content/docs/features.html (original)
+++ websites/production/cxf/content/docs/features.html Fri Apr 13 09:57:33 2018
@@ -226,7 +226,15 @@ clientFactoryBean.setFeatures(Collection
ClientProxyFactoryBean clientFactoryBean = new ClientProxyFactoryBean();
clientFactoryBean.setFeatures(Collections.singletonList(policyFeature)); </pre>
-</div></div><h2 id="Features-AddingaFeaturethroughconfiguration">Adding a
Feature through configuration</h2><p>Here are some examples on using
configuration files to add features. You can find more information about the
CXF provides features at <a shape="rect"
href="featureslist.html">FeaturesList</a>.</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><p>It is also possible to add a feature when publishing an
Endpoint via Endpoint.publish. For example, the Logging feature can be added as
follows:</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeHeader panelHeader pdl" style="border-bottom-width:
1px;"><b>Endpoint.publish</b></div><div class="codeContent panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">import javax.xml.ws.Endpoint;
+import org.apache.cxf.ext.logging.LoggingFeature;
+...
+CustomerService implementor = new CustomerServiceImpl();
+Endpoint.publish("http://localhost:9090/CustomerServicePort",
+ implementor,
+ new LoggingFeature());</pre>
+</div></div><p> </p><h2
id="Features-AddingaFeaturethroughconfiguration">Adding a Feature through
configuration</h2><p>Here are some examples on using configuration files to add
features. You can find more information about the CXF provides features at <a
shape="rect" href="featureslist.html">FeaturesList</a>.</p><div class="code
panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;"><beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cxf="http://cxf.apache.org/core"
Modified:
websites/production/cxf/content/docs/maven-cxf-codegen-plugin-wsdl-to-java.html
==============================================================================
---
websites/production/cxf/content/docs/maven-cxf-codegen-plugin-wsdl-to-java.html
(original)
+++
websites/production/cxf/content/docs/maven-cxf-codegen-plugin-wsdl-to-java.html
Fri Apr 13 09:57:33 2018
@@ -140,19 +140,19 @@ Apache CXF -- Maven cxf-codegen-plugin (
</executions>
</plugin>
</pre>
-</div></div><p>In this example we're running the wsdl2java goal in the
generate-sources phase. By running <strong>mvn generate-sources</strong>, CXF
will generate artifacts in the <sourceRoot> directory that you specify.
Each <wsdlOption> element corresponds to a WSDL that you're generated
artifacts for. The WSDL location is specified via the <wsdl> option.
Following <a shape="rect" class="external-link"
href="http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html">Maven
standard directory layout</a>, if you're planning on packaging the WSDL in the
JAR you're creating you'll want the WSDL above in /src/main/resources/
(alternatively in a subfolder underneath it if desired to avoid placing
resources in the root of a JAR); else use the /src/main/config folder to keep
the WSDL out of the JAR.</p><p>The following example shows some customization
options. By default, the codegen plugin follows the Maven convention of
"target/gener
ated-sources/cxf" for the output folder for the generated classes. You can
override this value using <sourceRoot> as shown below, but note this is
usually not necessary, the default is fine for most people and can make it
easier for some IDE's to detect the generated source code. Other configuration
arguments can be included inside the <wsdlOption> element. These pass
arguments to the tooling and correspond to the options outlined on the <a
shape="rect" href="wsdl-to-java.html">WSDL to Java</a> page.</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
+</div></div><p>In this example we're running the wsdl2java goal in the
generate-sources phase. By running <strong>mvn generate-sources</strong>, CXF
will generate artifacts in the <sourceRoot> directory that you specify.
Each <wsdlOption> element corresponds to a WSDL that you're generating
artifacts for. The WSDL location is specified via the <wsdl> option.
Following <a shape="rect" class="external-link"
href="http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html">Maven
standard directory layout</a>, if you're planning on packaging the WSDL in the
JAR you're creating, you'll want the WSDL above in /src/main/resources/
(alternatively in a subfolder underneath it if desired to avoid placing
resources in the root of a JAR); else use the /src/main/config folder to keep
the WSDL out of the JAR.</p><p>The following example shows some customization
options. By default, the codegen plugin follows the Maven convention of
"target/gen
erated-sources/cxf" for the output folder for the generated classes. You can
override this value using <sourceRoot> as shown below, but note this is
usually not necessary, the default is fine for most people and can make it
easier for some IDE's to detect the generated source code. Other configuration
arguments can be included inside the <wsdlOption> element. These pass
arguments to the tooling and correspond to the options outlined on the <a
shape="rect" href="wsdl-to-java.html">WSDL to Java</a> page.</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
<pre class="brush: xml; gutter: false; theme: Default"
style="font-size:12px;">...
<configuration>
<sourceRoot>${project.build.directory}/generated-code/mywebservice</sourceRoot>
<wsdlOptions>
- <wsdlOption>
-
<wsdl>${basedir}/src/main/resources/wsdl/myService.wsdl</wsdl>
- <!-- you can set the options of wsdl2java command by using
the <extraargs> -->
- <extraargs>
- <extraarg>-impl</extraarg>
- <extraarg>-verbose</extraarg>
- </extraargs>
- </wsdlOption>
+ <wsdlOption>
+
<wsdl>${basedir}/src/main/resources/wsdl/myService.wsdl</wsdl>
+ <!-- you can set the options of wsdl2java command by using the
<extraargs> -->
+ <extraargs>
+ <extraarg>-impl</extraarg>
+ <extraarg>-verbose</extraarg>
+ </extraargs>
+ </wsdlOption>
</wsdlOptions>
</configuration>
...
@@ -192,7 +192,7 @@ Apache CXF -- Maven cxf-codegen-plugin (
</wsdlOptions>
</configuration>
</pre>
-</div></div><p>In this example we're specifying that we only want to generate
artifacts for the service named "MyWSDLService" in the WSDL.</p><p>To avoid
copy/paste in multiple <wsdlOption> you can also declare a
<defaultOption> element.</p><h3
id="Mavencxf-codegen-plugin(WSDLtoJava)-Example4:UsingdefaultOptiontoavoidrepetition">Example
4: Using defaultOption to avoid repetition</h3><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><p>In this example we're specifying that we only want to generate
artifacts for the service named "MyWSDLService" in the WSDL.</p><p>To avoid
copy/paste in multiple <wsdlOption> you can also declare a
<defaultOptions> element.</p><h3
id="Mavencxf-codegen-plugin(WSDLtoJava)-Example4:UsingdefaultOptiontoavoidrepetition">Example
4: Using defaultOption to avoid repetition</h3><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="brush: xml; gutter: false; theme: Default"
style="font-size:12px;"><configuration>
<defaultOptions>
<bindingFiles>
@@ -212,7 +212,7 @@ Apache CXF -- Maven cxf-codegen-plugin (
</wsdlOptions>
</configuration>
</pre>
-</div></div><p><defaultOption> and <wsdlOption> correspond to the
options outlined on the <a shape="rect" href="wsdl-to-java.html">WSDL to
Java</a> page, you may look at <a shape="rect" class="external-link"
href="https://github.com/apache/cxf/blob/master/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/Option.java"
rel="nofollow">https://github.com/apache/cxf/blob/master/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/Option.java</a>
for a more detailed description of those parameters.</p><p>At least, you can
declare a common wsdlRoot folder where you store your WSDL files and use
includes/excludes patterns to select the files to get used by the code
generator</p><h3
id="Mavencxf-codegen-plugin(WSDLtoJava)-Example5:UsingwsdlRootwithincludes/excludespatterns">Example
5: Using wsdlRoot with includes/excludes patterns</h3><div class="code panel
pdl" style="border-width: 1px;"><div class="codeContent pane
lContent pdl">
+</div></div><p><defaultOptions> and <wsdlOption> correspond to the
options outlined on the <a shape="rect" href="wsdl-to-java.html">WSDL to
Java</a> page, you may look at <a shape="rect" class="external-link"
href="https://github.com/apache/cxf/blob/master/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/Option.java"
rel="nofollow">https://github.com/apache/cxf/blob/master/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/Option.java</a>
for a more detailed description of those parameters.</p><p>At least, you can
declare a common wsdlRoot folder where you store your WSDL files and use
includes/excludes patterns to select the files to get used by the code
generator</p><h3
id="Mavencxf-codegen-plugin(WSDLtoJava)-Example5:UsingwsdlRootwithincludes/excludespatterns">Example
5: Using wsdlRoot with includes/excludes patterns</h3><div class="code panel
pdl" style="border-width: 1px;"><div class="codeContent pan
elContent pdl">
<pre class="brush: xml; gutter: false; theme: Default"
style="font-size:12px;"><configuration>
<defaultOptions>
<bindingFiles>
@@ -227,49 +227,49 @@ Apache CXF -- Maven cxf-codegen-plugin (
</configuration>
</pre>
</div></div><p>wsdlRoot default value is <code>src/main/resources/wsdl</code>
so you may omit this declaration.</p><h3
id="Mavencxf-codegen-plugin(WSDLtoJava)-Example6:Loadingawsdlfromthemavenrepository">Example
6: Loading a wsdl from the maven repository</h3><p>There is a
<wsdlArtifact> wsdlOption configuration which can be used to load a wsdl
file from the maven repository.</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: xml; gutter: false; theme: Default"
style="font-size:12px;"> <configuration>
- <wsdlOptions>
- <wsdlOption>
- <wsdlArtifact>
- <groupId>org.apache.pizza</groupId>
- <artifactId>PizzaService</artifactId>
- <version>1.0.0</version>
- </wsdlArtifact>
- </wsdlOption>
- </wsdlOptions>
- </configuration>
+<pre class="brush: xml; gutter: false; theme: Default"
style="font-size:12px;"><configuration>
+ <wsdlOptions>
+ <wsdlOption>
+ <wsdlArtifact>
+ <groupId>org.apache.pizza</groupId>
+ <artifactId>PizzaService</artifactId>
+ <version>1.0.0</version>
+ </wsdlArtifact>
+ </wsdlOption>
+ </wsdlOptions>
+</configuration>
</pre>
</div></div><p>This will load the wsdl
/org/apache/pizza/PizzaService-1.0.0.wsdl into your local maven repository and
generate java code from it.</p><h3
id="Mavencxf-codegen-plugin(WSDLtoJava)-Example7:Usingxjcextensions">Example 7:
Using xjc extensions</h3><p>Standard JAXB command-line customizations can be
added via <extraarg> elements, either one per line or comma separated. <a
shape="rect" href="../xjc-utils.html">CXF also offers some JAXB extensions for
the code generation</a>. They have to be added as dependencies and then
activated by using an extraarg with content -xjc-X<extension id></p><div
class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1"
rowspan="1" class="confluenceTh"><p>artifact id</p></th><th colspan="1"
rowspan="1" class="confluenceTh"><p>description</p></th><th colspan="1"
rowspan="1" class="confluenceTh"><p>extension id</p></th></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd"><p>cxf-xjc-boolean</p></td><td
colspan="1
" rowspan="1" class="confluenceTd"><p>Adds getters for booleans</p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>boolean</p></td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd"><p>cxf-xjc-bug671</p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>Workaroung for JAXB bug
671</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>bug671</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p>cxf-xjc-dv</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>Default value support</p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>dv</p></td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p>cxf-xjc-ts</p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>Adds toString to objects</p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>ts</p></td></tr><tr><td
colspan="1" rowspan="1"
class="confluenceTd"><p>cxf-xjc-wsdlextension</p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>WsdlExtension support<
/p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>wsdlextension</p></td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p>jaxb-fluent-api</p><p>(<img class="emoticon
emoticon-warning"
src="https://cwiki.apache.org/confluence/s/en_GB/5997/6f42626d00e36f53fe51440403446ca61552e2a2.1/_/images/icons/emoticons/warning.png"
data-emoticon-name="warning" alt="(warning)"> not part of CXF:</p><p>group id
is net.java.dev.jaxb2-commons)</p></td><td colspan="1" rowspan="1"
class="confluenceTd">Fluent API for setters</td><td colspan="1" rowspan="1"
class="confluenceTd">fluent-api</td></tr></tbody></table></div><p>An example
showing attachment of a JAXB binding file and the CXF toString() extension is
below:</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
<pre class="brush: xml; gutter: false; theme: Default"
style="font-size:12px;"><plugin>
-<groupId>org.apache.cxf</groupId>
-<artifactId>cxf-codegen-plugin</artifactId>
-<version>${cxf.version}</version>
-<executions>
- <execution>
- <id>generate-sources</id>
- <phase>generate-sources</phase>
- <configuration>
- <wsdlOptions>
- <wsdlOption>
-
<wsdl>${basedir}/src/main/resources/wsdl/myService.wsdl</wsdl>
- <extraargs>
- <extraarg>-xjc-Xts</extraarg>
- </extraargs>
- </wsdlOption>
- </wsdlOptions>
- </configuration>
- <goals>
- <goal>wsdl2java</goal>
- </goals>
- </execution>
-</executions>
-<dependencies>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-codegen-plugin</artifactId>
+ <version>${cxf.version}</version>
+ <executions>
+ <execution>
+ <id>generate-sources</id>
+ <phase>generate-sources</phase>
+ <configuration>
+ <wsdlOptions>
+ <wsdlOption>
+
<wsdl>${basedir}/src/main/resources/wsdl/myService.wsdl</wsdl>
+ <extraargs>
+ <extraarg>-xjc-Xts</extraarg>
+ </extraargs>
+ </wsdlOption>
+ </wsdlOptions>
+ </configuration>
+ <goals>
+ <goal>wsdl2java</goal>
+ </goals>
+ </execution>
+ </executions>
+ <dependencies>
<dependency>
- <groupId>org.apache.cxf.xjcplugins</groupId>
- <artifactId>cxf-xjc-ts</artifactId>
- <version>${cxf-xjc.version}</version>
- </dependency>
-</dependencies>
+ <groupId>org.apache.cxf.xjcplugins</groupId>
+ <artifactId>cxf-xjc-ts</artifactId>
+ <version>${cxf-xjc.version}</version>
+ </dependency>
+ </dependencies>
</plugin>
</pre>
</div></div><p>In addition you need to add the cxf-xjc-runtime as a dependency
to your project:</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">