Thursday, April 18, 2013

Generating JAX-WS Portable Artifacts and Webservices Tutorials

wsimport tool (client):
The wsimport tool is used to parse an existing Web Services Description Language (WSDL) file and generate required files (JAX-WS portable artifacts) for web service client to access the published web services.
Example :
  • clientjar option for wsimport, which automatically downloads the wsdl and schema and packages all the generated client-side artifacts into a jar file.
    wsimport -clientjar wsclient.jar http://example.com/service/hello?WSDL
  • wsimport -keep wsdl_URL
  • wsimport -keep -verbose -wsdllocation /META-INF/wsdl/MyService.wsdl
  • wsimport -verbose -p ec.estat.edit -target 2.1 -Xnocompile editWS.wsdl
wsgen tool (server):
The wsgen tool is used to parse an existing web service implementation class and generates required files (JAX-WS portable artifacts) for web service deployment.
Example:
  • Generating service endfpoints artifacts (target\classes>) folder
    wsgen -verbose -keep -cp com.jini.HelloWorld
  • Generating wsdl
    wsgen -verbose -keep -cp . com.jini.HelloWorld -wsdl

Tutorials:
- JAX-WS Tutorial @ Mykyong
- Developerworks -Top 10 SOA and web services tutorials and articles
- Oracle - Creating and Using SOAP Message Handlers
- Pedict 8
- JAXWS using Maven
Online Webservice:
- Online service registry
- WebserviceX.NET

Artifacts and Client Generation using Maven:
    <build>
        <finalName>HelloService</finalName>
        <plugins>
            <plugin>
                <groupId>org.jvnet.jax-ws-commons</groupId>
                <artifactId>jaxws-maven-plugin</artifactId>
                <version>2.1</version>
                <executions>

                    <execution>
                        <id>generate-wsdl</id>
                        <phase>process-classes</phase>
                        <goals>
                            <goal>wsgen</goal>
                        </goals>
                        <configuration>
                            <sei>com.jini.service.Hello</sei>
                            <sourceDestDir>src/main/java</sourceDestDir>
                            <keep>true</keep>
                            <genWsdl>true</genWsdl>
                            <wsdlDirectory>src/resources</wsdlDirectory>
                            <verbose>true</verbose>
                        </configuration>
                    </execution>

                    <execution>
                        <id>generate-stubs</id>
                        <phase>process-classes</phase>
                        <goals>
                            <goal>wsimport</goal>
                        </goals>
                        <configuration>
                            <keep>true</keep>
                            <verbose>true</verbose>
                            <wsdlDirectory>target/jaxws/wsgen/wsdl</wsdlDirectory>
                            <wsdlFiles>
                                <wsdlFile>
                                    HelloService.wsdl
                                </wsdlFile>
                            </wsdlFiles>
<!--                         <wsdlLocation>http://localhost:8080/test</wsdlLocation> -->
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

No comments:

Post a Comment