Version 3

    This tutorial shows you how to create a webservice starting with a WSDL file. This web service developing approach is also known as top-down method and implies using the JBossWS implementation of the JAXWS command line tools to generate service endpoint interface class and JAXB databinding type classes. Users are only required to implement the business logic, package classes to war file and deploy in JBoss Application Server.

    Generate classes

    wsconsume tool (under ${JBOSS_HOME}/bin) is used to consume the wsdl contract and produce annotated Java classes.  There are many options can be used to configure this tool to customize the generated output result.   Check this link for these options details.

    Command line example used to generate jaxws classes (the -k option is to keep the source files):

    $ wsconsume -k EchoService.wsdl


    This table explains the generated files:



    Service Endpoint Interface

    Echo_Type.javaWrapper bean for request message
    EchoResponse.javaWrapper bean for response message
    ObjectFactory.javaJAXB XML Registry
    package-info.javaHolder for JAXB package annotations
    EchoService.javaUsed only by JAX-WS clients


    Implement the service endpoint interface

    The service endpoint implemention is required to implement the interface and do the real work. In this example, it needs a class to really echo the input back to sender :


    package echo; 
    @javax.jws.WebService(endpointInterface=”echo.Echo”, wsdlLocation="/WEB-INF/wsdl/EchoService.wsdl")
    public class EchoImpl implements Echo
      public String echo(String arg0)
       return arg0;


    Please note, the wsdlLocation value in the @Websevice annotation should be the real relative path in the packaged war file.


    Write the deployment descriptor and package

    A web.xml descriptor tells the JBossWS implementation the service endpoint implementation class:


    <web-app ...>


    User needs to package all the classes, web.xml and EchoService.wsdl in a war file to deploy in JBoss.  In this example we package all the things in a war named ws-from-wsdl.war file:



    After finishing all these steps, user can deploy this war file to start the webservice created from this wsdl file. Write a simple web serice client or simply access http://localhost:8080/ws-from-wsdl?wsdl to check if this endpoint is created and works properly.