Output Projects and Files

Code that is generated once and not overwritten is under /src, code that is generated and overwritten each time is under /target/src. There are also .ref (reference) files for artifacts that would have been generated if the existing file was not there. They can be used for comparison/merging purposes, i.e. if a new method is added to the model and the stubbed implementation must also be added to the Impl class.

Projects are generated in the following order: mda, common, core, webservice, app (if ear), CXF. The process looks like:

  • Read model(s) and generate code from andromda
  • (mda) Run the generated webservice\buildWS.xml ant script, which validates and runs wsdl2java against each generated service wsdl targeting the CXF project, and copies ObjectFactory and faults back to the common project
  • Compiles common project
  • Compiles core project and runs local unit tests against the service implementation delegates
  • Compiles webservice project.
  • (webservice) Launches Jetty with the generated Spring configuration. Runs integration tests with in-place war project against java client. Stops Jetty.
  • Runs java2ws against the common/core generated code, targeting the CXF project. This verifies that the java service implementation code can be used to create compatible wsdl and will display the proper result when using ?wsdl URL
  • Copies spring/web configuration from webservice project. Compiles CXF project
  • (CXF) Launches Jetty with the generated Spring configuration. Runs integration tests with in-place war project against java client. Stops Jetty. This verifies that server and client code generated by CXF against the wsdl is valid

In the initial andromdapp generated project, the mda/build.xml ant script deletes all of the Implementation code. To turn this off, once the interfaces have been sufficiently modeled, edit mda/pom.xml to comment out the cleanImpl task in the antrun plugin clean execution:

            <plugin>
              <artifactId>maven-antrun-plugin</artifactId>
              <executions>
                <!-- Clean the implementation code and WSDL code also, during mvn clean -->
                <execution>
                  <id>clean</id>
                  <phase>clean</phase>
                  <configuration>
                    <target>
                        ...
                        <ant antfile="${project.basedir}/build.xml">
                            <target name="clean"/>
                        </ant>
                        <ant antfile="${project.basedir}/build.xml">
                            <target name="cleanWSDL"/>
                        </ant>
                        <!--ant antfile="${project.basedir}/build.xml">
                            <target name="cleanImpl"/>
                        </ant-->
                    </target>
                  </configuration>
                  <goals>
                    <goal>run</goal>
                  </goals>
                </execution>

MDA Project

mda (Controls the code generation process):

  • build.xml: ant build script to generate code through maven and generate wsdl and java code in the CXF project. Created by the andromdapp initial project generation. buildAll iterates through multiple models and calls build.xml tasks (Deprecated, no longer needed after multi-model code generation was fixed).
  • src/main/config/andromda.xml: the master configuration for code generation. Specifies model file(s), cartridges, and generation options
  • src/main/config/mappings: Configuration files to override default mappings from UML to Java, or UML to XML, configured in andromda.xml. By default we override XMLDate behavior.
  • src/main/uml: default location for model(s) used for code generation.
  • logs: log files are initially generated in the root directory, and copied to the logs directory at the start of the next run. Logging level is changed by uncommenting the log4j.xml reference in andromda.xml.
  • Runs the generated buildWS.xml ant script in the webservice project, which runs wsdl2java against the generated wsdl/xsd with output to the CXF project, and copies some files (such as ObjectFactory and *Fault) back to the common and core projects.

the ant output looks something like this:

[INFO] [antrun:run {execution: buildWS}]
wsgenall:
     [echo] running wsgen for each generated webservice class

wsgenjava:
     [echo] running wsdlvalidator for AndroMDA generated wsdl for service CXF34Service
     [java] wsdlvalidator -verbose C:\Workspaces\cxf34\mda/../webservice/src/main/webapp/wsdl/CXF34Service.wsdl
     [java] wsdlvalidator - Apache CXF 2.3.3
     [java] 
     [java] Passed Validation : Valid WSDL 
     [echo] running wsdl2java for service CXF34Service
     [java] Loading FrontEnd jaxws ...
     [java] Loading DataBinding jaxb ...
     [java] wsdl2java -p http://services.cxf34.andromda.org/=org.andromda.cxf34.services -b C:\Workspaces\cxf34\mda/../webservice/src/main/webapp/wsdl/bindings/CXF34Service.xjb -d C:\Workspaces\cxf34\mda/../CXF/target/src/main/java -classdir C:\Workspaces\cxf34\mda/../CXF/src/main/webapp/WEB-INF/classes -all -verbose -autoNameResolution C:\Workspaces\cxf34\mda/../webservice/src/main/webapp/wsdl/CXF34Service.wsdl
     [java] wsdl2java - Apache CXF 2.3.3
     [java] 
     [copy] Copying 1 file to C:\Workspaces\cxf34\common\target\src\main\java\org\andromda\cxf34\services
     [copy] Copying C:\Workspaces\cxf34\CXF\target\src\main\java\org\andromda\cxf34\services\ObjectFactory.java to C:\Workspaces\cxf34\common\target\src\main\java\org\andromda\cxf34\services\ObjectFactory.java
     [copy] Copying 6 files to C:\Workspaces\cxf34\common\target\src\main\java
     [copy] Copying C:\Workspaces\cxf34\CXF\target\src\main\java\org\andromda\cxf34\exceptions\ObjectFactory.java to C:\Workspaces\cxf34\common\target\src\main\java\org\andromda\cxf34\exceptions\ObjectFactory.java
     [copy] Copying C:\Workspaces\cxf34\CXF\target\src\main\java\org\andromda\cxf34\valueobjects\ObjectFactory.java to C:\Workspaces\cxf34\common\target\src\main\java\org\andromda\cxf34\valueobjects\ObjectFactory.java

Common Project

common:

  • ValueObjects
  • Enumerations
  • Exceptions (including service WebFault classes)
  • Jaxb package-info class: maps package name to XML namespace
  • Jaxb ObjectFactory: required for XML marshall/unmarshalling
  • Jaxb Request and ResponseWrappers: used to implement JAX-WS wrapped mode
  • Jaxb Adapter (for CXF 2.0 only): used for customized bindings such as java.util.Date instead of XMLGregorianCalendar, otherwise the $XML class is referenced.

Core Project

core (generally holds services and domain objects):

  • Service SEI: The Service Endpoint Interface
  • Service SEIImpl: The class which implements the SEI
  • Service SEIImplTest: UnitTest for the SEIImpl: does not require deployment to web service container/runtime, should be used to test the service implementation (not the web service configuration/transport). Uses default data from <Method>Impl.CreateInput().
  • Service Delegate (under src): The class that the SEIImpl delegates to, for each method implementation. By default, it delegates again to the <Method>Impl class.
  • Service <Method>Impl (under src): Contains default implementations for CreateInput (input for unit test for the method), transformInput (iterates through method input objects to map to an underlying implementation), and TransformResponse (iterates through return type hierarchy to map implementation output to service return value).

Webservice Project

webservice (web application containing the service implementation):

  • JettyServer (under default package): Runs Jetty web server, which allows easily deploying and starting the web service endpoint, for testing.
  • <Service>_WSClient: Java service client which calls each web service with test data from <Method>Impl CreateInput.
  • <Service>WSTest: Uses SharedCore DataDrivenTestCase to allow Excel test input for service methods.
  • <Service>SEI_<Service>SEIEndpoint_Server and _Client: Generated by CXF wsdl2java in the CXF project and copied to the webservice project, in case you might want to use the default generated Server and Client implementations.
  • src/main/webapp/WEB-INF/web.xml: Web project configuration, initializes the CXF servlet and the Spring configuration
  • src/main/webapp/WEB-INF/ApplicationContext-CXF.xml: Spring configuration file which exposes the Service endpoints as web services. You can configure logging, schema validation, cusom handlers, etc here.
  • src/main/webapp/wsdl: Generated wsdl files.
  • src/main/webapp/wsdl/xsd: Generated xsd schema files.
  • src/main/webapp/wsdl/bindings: jaxb_bindings files used by CXF wsdl2java, to customize the Endpoint names, Date/Integer/Decimal handling created in the CXF project from the generated wsdl files.
  • src/main/webapp/wsdl/ref: .ref files which are regenerated each time. These would have overwritten the corresponding wsdl and xsd files, can be used to compare new to existing generated code.

CXF Project

CXF Client: Scratch area for the results of running wsdl2java against the generated wsdl/xsd files, and java2ws (java2wsdl for CXF 2.0) against the generated java code. Use this to see what would be generated by WS clients using only the wsdl, and to make sure the generated code in the CXF and Webservice projects is compatible. This code does not need to be source controlled.

  • src/main/webapp/WEB-INF/wsdl contains the wsdl files. No imported xsd files are generated because there is a bug in CXF (schemaLocation is missing).
  • target/src/main/java contains all Java code generated from the wsdl.

Next

Next we will look at how to implement the services and service tests Implementation