Q:

Creating web service (not web service client) from WSDL file

I have a requirement, according to which i have to create an Axis2 Web service based on a wsdl file. I already got the wsdl file. I have been using wsdl2java earlier to create web service client but i don't know how to create web service using the given wsdl file. Can somebody please help me in giving the correct command or options to be used. 
Also, i need to publish it on WAS 6.1 and JBoss 5.1.0 GA, what all should be done for that. 

A:

I am able to get the answer. Updating here for other's reference. 
Starting with WSDL, Creating and Deploying a Service
We start with a WSDL, however if you do not have a WSDL and need to create a WSDL from a java class, please use the Java2WSDL tool to create the WSDL. As you might already know, a WSDL description of a service provides a precise definition of that web service. Axis2 can process the WSDL and generate java code that does most of the work for you. At the server side, we call them Skeletons, and at the client side, Stubs.
This method of writing a Web service with Axis2 involves four steps:

Generate the skeleton code.
Add business logic.
Create a *.aar archive (Axis Archive) for the Web service.
Deploy the Web service.

Step1: Generate Skeleton Code
To generate the skeleton and required classes, you can use the WSDL2Java tool provided in Axis2. This tool is located in the bin directory of the distribution and can be executed using the provided scripts (.bat or .sh). The tool's parameter list can be found in the Axis2 Reference Document.
The parameters for the wsdl2java tool in our example are as follows. Please note that, for this example, we are using xmlbeans as the data binding framework, and the generated code will be placed in a "samples" directory.
wsdl2java.sh -uri ../samples/wsdl/Axis2SampleDocLit.wsdl -ss -sd -d xmlbeans 
-o ../samples -p org.apache.axis2.userguide
This will generate the required classes in the "sample/src" directory, and the schema classes in the "samples/resources/schemaorg_apache_xmlbeans" directory. Note that these are not source files and should be available in the class path in order to compile the generated classes.
Step 2: Implement Business Logic
Now you should fill the business logic in the skeleton class. You can find the skeleton class -Axis2SampleDocLitServiceSkeleton.java- among the generated classes in the "samples/src/org/apache/axis2/userguide directory. Let's fill the echoString(..) method in the skeleton as shown below. Our sample WSDL-Axis2SampleDocLit.wsdl in "samples/wsdl" directory has three operations: echoString, echoStringArray, echoStruct. To see how the others will look when they are filled up, see Code Listing For Axis2SampleDocLitService Service
public org.apache.axis2.userguide.xsd.EchoStringReturnDocument 
    echoString(org.apache.axis2.userguide.xsd.EchoStringParamDocument param4) throws Exception {
    //Use the factory to create the output document.
    org.apache.axis2.userguide.xsd.EchoStringReturnDocument retDoc = 
           org.apache.axis2.userguide.xsd.EchoStringReturnDocument.Factory.newInstance();
    //send the string back.
    retDoc.setEchoStringReturn(param4.getEchoStringParam());
   return retDoc;

Step 3: Create Archive File
An Axis2 service must be bundled as a service archive. The next step is to package the classes in an .aar (axis2 archive) and deploy it in Axis2. There is an ant file generated with the code; it will generate the Axis2 service archive for you. However, if you do not want to use ant, you can create an archive with the following steps :
Compile the generated code.
Copy "resources/schemaorg_apache_xmlbeans" xmlbeans classes to your class folder.
Among the generated files, there will be a services.xml file, which is the deployment descriptor for Axis2 service.[learn more about it]. Copy the resources/service.xml to META-INF/services.xml
(To write your own service.xml file, see the sub section in Writing Web Services Using Axis2's Primary APIs )
Create the archive using content of the class folder. Change the directory to the class folder and run jar -cf service-name.aar to create the archive.
Step 4: Deploy Web Service
The service can be deployed by simply dropping the ".aar" file into the "services" directory in "/webapps/axis2/WEB-INF" of your servlet container. We recommend using Apache Tomcat as the servlet container. Please Note that the services directory is available only after axis2.war has been exploded by Tomcat. However, the easiest way to do it is to start Tomcat after axis2.war is copied to the webapps directory (if you have not already started it). Check the "Services" link on the Home page of Axis2 Web Application (http://localhost:8080/axis2) and see whether the Axis2SampleDocLitService is displayed under the deployed services.
We recommend using the exploded configuration to deploy Axis2 WAR in WebLogic and WebSphere application servers to support the hotupdate/hotdeployment features of Axis2. See Application Server Specific Configuration Guide for details.
Note: Axis2 provides an easy way to deploy Web Services using the "Upload Service" tool in the Axis2 Web Application's Administration module. (See the Web Administration Guide for more information)
See the following link for full article: http://axis.apache.org/axis2/java/core/docs/adv-userguide.html

