Version 4

    Here is an example of usage of the JBossWS JAXWS Tools Maven plugin; in particular we'll be using the wsconsume tool, which generates sources for a given wsdl endpoint.


    You start by building a basic maven based app, using a pom.xml file as below:


    <?xml version="1.0"?>
    <project xmlns="" xmlns:xsi="" xsi:schemaLocation="">
       <name>JBossWS wsconsume maven plugin sample</name>
       <description>JBossWS wsconsume maven plugin sample</description>
          <!-- Explicitly declaring the source encoding eliminates the following message: -->
          <!-- [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! -->
          <!-- JBoss dependency versions -->
          <!-- other plugin versions -->
          <!-- maven-compiler-plugin -->
             <!-- Define the version of JBoss' Java EE 6 APIs we want to import. 
                Any dependencies from org.jboss.spec will have their version defined by this 
                BOM -->
             <!-- JBoss distributes a complete set of Java EE 6 APIs including
                a Bill of Materials (BOM). A BOM specifies the versions of a "stack" (or
                a collection) of artifacts. We use this here so that we always get the correct
                versions of artifacts. Here we use the jboss-javaee-6.0 stack (you can
                read this as the JBoss stack of the Java EE 6 APIs). You can actually
                use this stack with any version of JBoss AS that implements Java EE 6, not
                just JBoss AS 7! -->
          <!-- Set the name of the war, used as the context root when the app is deployed -->
             <!-- Compiler plugin enforces Java 1.6 compatibility and activates annotation processors -->


    The pom simply uses the maven compiler plugin and the jboss-as-maven-plugin that will later deploy our app to JBoss AS 7. Please note the JBoss JavaEE 6 spec artifacts. The JBoss Maven repository of course needs to be properly setup in your environment.

    Then you simply add the JBossWS dependency needed by the wsconsume tool (provided scope to avoid it being added to the deployable archive) as well as the jaxws-tools plugin for running wsconsume:





                  <id>My execution</id>


    The test.wsdl is the WSDL file we're consuming (the contract for the service you want to expose in this case, but it could also be the contract for a service you want to create a client for) and is added to src/main/resources.

    You then add a sample WS endpoint implementation that implements the interface that will be generated by wsconsume at build time:


    import javax.jws.WebService;
    @WebService(endpointInterface = "")
    public class EchoEndpointImpl implements Endpoint
       public String echoString(String s)
          return s;


    and you create a simple web.xml in src/main/webapp/WEB-INF to make your endpoint available in the application:


    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="3.0" xmlns=""
     xmlns:xsi="" xsi:schemaLocation="">


    That's all! Time to build and deploy the application, it's just a matter of a single mvn command (be sure to have a running AS 7.1 or greater):


    alessio@inuyasha /dati/wsconsume-sample $ mvn clean jboss-as:deploy
    [INFO] Scanning for projects...
    [INFO] ------------------------------------------------------------------------
    [INFO] Building JBossWS wsconsume maven plugin sample 1.0.0-SNAPSHOT
    [INFO] ------------------------------------------------------------------------
    [INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ wsconsume-plugin-sample ---
    [INFO] Deleting /dati/wsconsume-sample/target
    [INFO] >>> jboss-as-maven-plugin:7.3.Final:deploy (default-cli) @ wsconsume-plugin-sample >>>
    [INFO] --- maven-jaxws-tools-plugin:1.1.1.Final:wsconsume (My execution) @ wsconsume-plugin-sample ---
    log4j:WARN No appenders could be found for logger (org.apache.cxf.common.logging.LogUtils).
    log4j:WARN Please initialize the log4j system properly.
    log4j:WARN See for more info.
    Loading FrontEnd jaxws ...
    Loading DataBinding jaxb ...
    wsdl2java -exsh false -p -d /dati/wsconsume-sample/target/generated-sources/wsconsume -verbose -allowElementReferences file:/dati/wsconsume-sample/src/main/resources/test.wsdl
    wsdl2java - Apache CXF 2.6.4
    [INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ wsconsume-plugin-sample ---
    [INFO] Using 'UTF-8' encoding to copy filtered resources.
    [INFO] Copying 1 resource
    [INFO] --- maven-compiler-plugin:2.3.1:compile (default-compile) @ wsconsume-plugin-sample ---
    [INFO] Compiling 3 source files to /dati/wsconsume-sample/target/classes
    [INFO] --- maven-resources-plugin:2.4.3:testResources (default-testResources) @ wsconsume-plugin-sample ---
    [INFO] Using 'UTF-8' encoding to copy filtered resources.
    [INFO] Copying 0 resource
    [INFO] --- maven-compiler-plugin:2.3.1:testCompile (default-testCompile) @ wsconsume-plugin-sample ---
    [INFO] Nothing to compile - all classes are up to date
    [INFO] --- maven-surefire-plugin:2.7.2:test (default-test) @ wsconsume-plugin-sample ---
    [INFO] Surefire report directory: /dati/wsconsume-sample/target/surefire-reports
     T E S T S
    There are no tests to run.
    Results :
    Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
    [INFO] --- maven-war-plugin:2.1.1:war (default-war) @ wsconsume-plugin-sample ---
    [INFO] Packaging webapp
    [INFO] Assembling webapp [wsconsume-plugin-sample] in [/dati/wsconsume-sample/target/wsconsume-plugin-sample]
    [INFO] Processing war project
    [INFO] Copying webapp resources [/dati/wsconsume-sample/src/main/webapp]
    [INFO] Webapp assembled in [23 msecs]
    [INFO] Building war: /dati/wsconsume-sample/target/wsconsume-plugin-sample.war
    [INFO] WEB-INF/web.xml already added, skipping
    [INFO] <<< jboss-as-maven-plugin:7.3.Final:deploy (default-cli) @ wsconsume-plugin-sample <<<
    [INFO] --- jboss-as-maven-plugin:7.3.Final:deploy (default-cli) @ wsconsume-plugin-sample ---
    Feb 13, 2013 7:01:42 PM org.xnio.Xnio <clinit>
    INFO: XNIO Version 3.0.7.GA
    Feb 13, 2013 7:01:42 PM org.xnio.nio.NioXnio <clinit>
    INFO: XNIO NIO Implementation Version 3.0.7.GA
    Feb 13, 2013 7:01:42 PM org.jboss.remoting3.EndpointImpl <clinit>
    INFO: JBoss Remoting version 3.2.12.GA
    [INFO] ------------------------------------------------------------------------
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 7.284s
    [INFO] Finished at: Wed Feb 13 19:01:43 CET 2013
    [INFO] Final Memory: 27M/183M
    [INFO] ------------------------------------------------------------------------
    alessio@inuyasha /dati/wsconsume-sample $


    As you can see the wsconsume plugin is called as part of the build and the generated classes are compile and added into the deployment together with our endpoint implementation. If the wsdl was a more complex one, causing the generation of classes to carry request and response data, those whould have also be included automatically.


    You can check the endpoint is available by getting the wsdl at http://localhost:8080/wsconsume-plugin-sample/echo?wsdl


    If you want to have a try of the sample here, download the maven project .