Tuesday, July 14, 2015

Automating JAX-WS Client Generation

This post describes a solution to automate the development of proxy service clients. This needs a Maven Multi Module project as the parent project, ESB project and a Registry project. Additionally we need a simple maven project to generate the client sources. So the project structure would looks like follows.
MavenParentProject
├── ESBconfigProject
├── RegistryProject
├── proxy-service-clients
Here ESBconfigProject contains the proxy services and RegistryProject contains the wsdls referred by ESB project. The proxy-service-clients project is a simple maven project, which is used to generate the client source.
In MavenParentProject's pom file define the modules in following order

    RegistryProject
    ESBconfigProject
    proxy-service-clients

ESBconfigProject proxy-service-clients
In proxy-service-clients project's pom file define the jaxws-maven-plugin[1] as follows
 
  org.codehaus.mojo
  jaxws-maven-plugin
  1.12
   
    
    package
      
      wsimport 
     
     
   
    
    com.sample.stub 
    ../RegistryProject
    src/main/java 
    
  
Then do a maven build ('mvn clean install') on parent project and it will generate the source for clients in proxy-service-clients/src/main/java directory and compiled jar will be generated at proxy-service-clients's target directory.

No comments: