You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by rahulsharma <ra...@gmail.com> on 2017/06/09 05:34:19 UTC

wsdl2java - takes a WSDL document and generates fully annotated Java code from which to implement a service.

Hi everyone,

wsdl2java takes a WSDL document and generates fully annotated Java code from
which to implement a service. The WSDL document must have a valid portType
element, but it does not need to contain a binding element or a service
element. Using the optional arguments you can customize the generated code.
In addition, wsdl2java can generate an Ant based makefile to build your
application.

After using the optional arguments I customized the generated code. Along
with this It created a build.xml file as follows

<?xml version="1.0"?>


<project name="cxf wsdltojava" default="build" basedir=".">

    <property environment="env"/>
    <property name="home.dir" location="${basedir}"/>
    <property name="build.dir" location ="${basedir}/build"/>
    <property name="build.classes.dir" location ="${build.dir}/classes"/>
    <property name="build.src.dir" location ="${basedir}"/>

    
    <available property="tools.jar" value="$${env.JAVA_HOME}/lib/tools.jar"
               file="${env.JAVA_HOME}/lib/tools.jar"/>
    <path id="jdk.tools.classpath">
        <pathelement location="${tools.jar}"/>
    </path>

    <condition property="is.supported.java.version">
        <or>
          <equals arg1="${ant.java.version}" arg2="1.7"/>
          <equals arg1="${ant.java.version}" arg2="1.8"/>
          <equals arg1="${ant.java.version}" arg2="1.9"/>
        </or>
    </condition>

    <fail message="cxf requires Java version 1.7 or higher. You are
currently using Java version ${ant.java.version}."
          unless="is.supported.java.version"/>

    
    <condition property="cxf.home" value="${env.CXF_HOME}">
        <isset property="env.CXF_HOME"/>
    </condition>

    <fail message="Please set CXF_HOME environment variable."
unless="cxf.home"/>

    
    <condition property="cxf-manifest.jar.file"
value="${cxf.home}/build/lib/cxf-manifest.jar">
        <available file="cxf-manifest.jar" type="file"
filepath="${cxf.home}/build/lib"/>
    </condition>
    <property name="cxf-manifest.jar.file"
value="${cxf.home}/lib/cxf-manifest.jar"/>

    <fail message="The location ${cxf.home} does not seem to contain a cxf
installation; if you are importing this common build file from a location
other than the cxf samples directory then you need to set the cxf_HOME
environment variable.">
        <condition>
            <not>
                <isset property="cxf-manifest.jar.file" />
            </not>
        </condition>
    </fail>

    
    <condition property="thirdparty.tools.dir" value="${cxf.home}/tools">
        <available file="tools" type="dir" filepath="${cxf.home}"/>
    </condition>

    <condition property="thirdparty.tools.dir" value="${cxf.home}/lib">
        <available file="lib" type="dir" filepath="${cxf.home}"/>
    </condition>

    <property name="cxf.etc.dir" location="${cxf.home}/etc"/>

    <condition property="cxf.endorsed.dir" value="${cxf.home}/lib/endorsed">
        <available file="${cxf.home}/lib/endorsed" type="dir" property=""/>
    </condition>
    <condition property="cxf.endorsed.flag"
value="-Djava.endorsed.dirs=${cxf.endorsed.dir}">
        <available file="${cxf.home}/lib/endorsed" type="dir" property=""/>
    </condition>
    <property name="cxf.endorsed.dir" location="${cxf.home}"/>
    <property name="cxf.endorsed.flag" value="-Dnone=none"/>



    <path id="cxf.classpath">
        <pathelement location="${home.dir}" /> 
        <pathelement location="${build.classes.dir}"/>
        <pathelement location="${cxf-manifest.jar.file}"/>
        <fileset dir="${cxf.endorsed.dir}">
            <include name="*.jar"/>
        </fileset>
    </path>

    <target name="NotificationProducerClient" description="Run
org.tmforum.mtop.fmw.wsdl.notp.v1_0.NotificationProducer_NotificationProducerSoapJms_Client"
depends="compile">
        <property name="param" value=""/>
        <cxfrun
classname="org.tmforum.mtop.fmw.wsdl.notp.v1_0.NotificationProducer_NotificationProducerSoapJms_Client"
                  
param1="file:/C:/Users/tcsrsha/workspace/SIRIUS/SIRIUS_FORT/tmf854/2.0/DDP/Framework/IIS/wsdl/NotificationProducer/NotificationProducerJms.wsdl"/>
    </target>

    <target name="NotificationProducerServer" description="Run
org.tmforum.mtop.fmw.wsdl.notp.v1_0.NotificationProducer_NotificationProducerSoapJms_Server"
depends="compile">
        <cxfrun
classname="org.tmforum.mtop.fmw.wsdl.notp.v1_0.NotificationProducer_NotificationProducerSoapJms_Server"
                  
param1="file:/C:/Users/tcsrsha/workspace/SIRIUS/SIRIUS_FORT/tmf854/2.0/DDP/Framework/IIS/wsdl/NotificationProducer/NotificationProducerJms.wsdl"/>
    </target>



    <target name="compile">
        <mkdir dir="${build.classes.dir}"/>
        <javac srcdir="${build.src.dir}" destdir="${build.classes.dir}"
debug="true" fork="true">
            <compilerarg line="-J${cxf.endorsed.flag}"/>
            <classpath refid="cxf.classpath" />
        </javac>
    </target>

    <target name="checkstyle">
        <checkstyle config="${checkstyle.config.file}">
            <fileset dir="${basedir}/src" includes="**/*.java"/>
            <classpath>
                <path refid="cxf.classpath"/>
            </classpath>
        </checkstyle>
    </target>

    <target name="clean">
        <delete dir="${build.classes.dir}"/>
        <delete file="${java.timestamp.file}"/>
        <delete file="demo.log"/>
    </target>

    <target name="build"  depends="compile" description="build demo client
and server"/>

    <macrodef name="cxfrun">
        <attribute name="classname"/>
        <attribute name="param1" default=""/>
        <attribute name="param2" default=""/>
        <attribute name="param3" default=""/>
        <attribute name="param4" default=""/>
        <attribute name="param5" default=""/>
        <attribute name="jvmarg1" default="-Da=b"/>
        <attribute name="jvmarg2" default="-Da=b"/>
        <attribute name="jvmarg3" default="-Da=b"/>
        <attribute name="jvmarg4" default="-Da=b"/>
        <attribute name="jvmarg5" default="-Da=b"/>
        <sequential>
            <java classname="@{classname}" fork="yes">
                <classpath>
                    <path refid="cxf.classpath"/>
                </classpath>
                <arg value="@{param1}"/>
                <arg value="@{param2}"/>
                <arg value="@{param3}"/>
                <arg value="@{param4}"/>
                <arg value="@{param5}"/>
                <jvmarg value="${cxf.endorsed.flag}"/>
                <jvmarg value="@{jvmarg1}"/>
                <jvmarg value="@{jvmarg2}"/>
                <jvmarg value="@{jvmarg3}"/>
                <jvmarg value="@{jvmarg4}"/>
                <jvmarg value="@{jvmarg5}"/>
                <assertions>
                    <enable package="org.apache.cxf"/>
                </assertions>
                <sysproperty key="java.util.logging.config.file"
value="${cxf.etc.dir}/logging.properties"/>
                <sysproperty key="log4j.configuration"
value="file:///${cxf.etc.dir}/log4j.properties"/>
            </java>
        </sequential>
    </macrodef>
</project>


I have few doubts to be cleared,

1) Is this build.xml used to generate any new class files or in any manner
for my application to run(MTOSI using SOAPUi)
2) CXF_HOME environment variable -- with what value do I need to set this
parameter.?
3) cxf.classpath present in build.xml -- is showing the value ${cxf.home}
does not exist.
4) To use the new JAX-WS 2.2 and JAXB 2.2 features with Java 6, the
jaxws-api and jaxb-api jars need to be endorsed. Otherwise, the runtime and
compiler will pick up the 2.1 versions that are built into the JDK. Two
common ways to do this is to copy them to your jre/lib/endorsed folder or to
add -Djava.endorsed.dirs=... to the command line of your application to
point to a directory containing those jars

In this build.xml we are having this parameter as "Djava.endorsed.dirs"
Do we need to set with any value.

Please could anyone help me out in this regard.

Thanks and Regards,
Rahul



--
View this message in context: http://cxf.547215.n5.nabble.com/wsdl2java-takes-a-WSDL-document-and-generates-fully-annotated-Java-code-from-which-to-implement-a-se-tp5781093.html
Sent from the cxf-user mailing list archive at Nabble.com.