WSO2Con 2013 CFP Banner
WSO2Con 2013

Developing Web Services Using Apache Axis2 Eclipse Plugins - Part 1

Editors Note: This article has been subsumed and replaced by "Writing Axis2 Services with WSO2 Developer Studio" which offers a comprehensive replacement for the old Axis2 Eclipse plugs-ins. You can download the 100% open source WSO2 Developer Studio here.

Apache Axis2 Eclipse Plugins allow Web service developers to easily and speedily expose the available plain old Java applications as Web services. This tutorial by Lahiru Sandakithconsists of two parts, with two examples that walk you through developing and deploying a sample Web service using the Top-down (Contract First) and Bottom-up (Code First) approach using Axis2 Eclipse Plugins.

Date: Sun, 10th Jun, 2007
Level: Introductory
Reads: 525339
Discuss this article on Stack Overflow
Lahiru Sandakith
Software Engineer
WSO2 Inc.
sandakith's picture

The tutorial is written for Eclipse SDK v3.2 and Axis2 Eclipse Plugin v1.3.

Contents

Introduction

Apache Axis2 is the most popular and widely used core engine for Web services. It is a complete re-design and re-write of the widely used Apache Axis SOAP stack built on the lessons learned from Apache Axis. Apache Axis2 is more efficient, more modular, and more XML-oriented than the older version. It is carefully designed to support the easy addition of plugin "modules" that extend its functionality for features such as security and reliability. On the other hand, Eclipse is a project aiming to provide a universal tool set for development. It is an open source IDE that is mostly provided in Java, but the development language is independent and not limited in any way. It is the most widely used IDE for most computer languages, especially for JAVA.

Developing applications using any programming language is becoming easier with the availability of tooling. If tooling is available in areas like JAVA application development, it will facilitate faster and easier application development, and also increase the productivity of the developers. Most integrated development environments (IDEs) address the tooling and the features available around a particular area of development. Most IDEs available today go beyond supplying traditional tooling facilities, which address only certain areas in programming. They are becoming frameworks for developing applications.

This tutorial mainly focuses on the two above mentioned tools available for Web service developers. They are, Axis2 Eclipse Plugins, which are built around Eclipse-the Framework available for JAVA application development, and Axis2- the widely used core engine for Web services. These tools help the developers to easily expose their available plain old JAVA applications as Web services, using wizards.

This tutorial is split into two parts covering two basic Web services scenarios of Web service in the Bottom Up (Code First) and Top Down (Contract First) approaches with the Axis2 Eclipse Plugins.

PART 1 - Axis2 Eclipse Plugin demonstration of Bottom Up Approach of Web services Development.

PART 2 - Axis2 Eclipse Plugin demonstration of Top Down Approach of Web services Development.

Tutorial Scenario

Assume that you are a Java developer who wants to expose your available application as a Web service. This tutorial covers developing, deploying, and testing a temperature conversion application as a Web service in the Top Down (Contract First) and Bottom Up (Code First) approaches. In Web services terminology, Bottom Up (Code First) is used where the developer starts with the business logic, which is the code, and then develop and deploy the code as a Web service. The Top Down (Contract First) approach starts from the Web service descriptions, which is the WSDL, and then goes on to expose the Web service.

Only two Eclipse plugins are used in the process. The tutorial uses the Axis2 Web application deployed in your servlet container as the Web service deployment engine. Also, it is assumed that you know the basics of how to use Eclipse as your Java development environment, and therefore it does not cover areas such as creating a JAVA project in an Eclipse workspace and compiling and building a JAVA project in Eclipse.

Getting Started

These are the tools used in the tutorial.

1) Java Development Kit 1.4.2.x (Download)

2) Eclipse SDK 3.2.x (Download)

3) Apache Tomcat 4.1.x (Download)

4) Axis2 Web Application (Download)

5) Axis2 Eclipse Plugins (Download)

 

Now let us focus on the two plugins mentioned in the tutorial scenario.

1) Apache Axis2 Service Archive Generator Wizard – Eclipse Plugin

As a part of the Axis2 tool set, the service archive generator is an important tool that allows the generation of service archives (an "aar" file or a "jar" file) that can be deployed as a Web service to Axis2.

2) Apache Axis2 Code Generator Wizard - Eclipse Plugin

The Axis2 Code Generator Wizard is the other important tool that allows you to generate WSDL2Java and Java2WSDL code, which is the heart of developing and testing Web services.

To start developing Web services, you need to download, install the two plugins, and verify that the plugins are working properly. The installation of plugins into Eclipse is as simple as downloading the plugins from the Apache Axis2 download page and extracting them to the Eclipse plugins directory. You can download the two plugins from the Axis2 Tools Page. Refer to the installation instructions.

Other than the two plugins, we need the Axis2 runtime to deploy the developed Web services. We use the Axis2 Web Application which can be deployed in any popular servlet container. (You can download the Axis2 Web Application from the Axis2 Download page.) You have to just place it in the repository of the servlet container and run it. For example, if you are using Apache Tomcat, just copy the downloaded .war file, put it in the webapp folder, and start the servlet container.

 

PART 1 - The Bottom Up Approach in Web Services Development Using the Apache Axis2 Eclipse Plugin

  1. Start Eclipse SDK. First we need to create a JAVA project in Eclipse. (Follow the instruction on Eclipse SDK help.) You can give any name to the JAVA project, but for clarity, let us create a JAVA project called “TemperatureWebService”.

  2. In the Bottom Up Approach, we start with the service implementation and then build the deployable Web service component. We will be using the TemperatureConverter class definition as the logic for developing, deploying, and testing the Web service.

  3. Create a custom package ws.example appropriately and include the TemperatureConverter.java file in that package. Compile and build the project.

  4. package ws.example;
    
    /**
     * Temperature Converter Implementation Class
     */
    public class TemperatureConverter {
                    /**
                     * util method to convert celsius to fahrenheit
                     * @param cValue : double value of celsius
                     * @return calculated value of fahrenheit
                     */
                    public double c2fConvertion(double cValue) {
                                   return ((cValue * 9.0)/5.0 )+ 32.0;
                    }
    
                     /**
                     * util method to convert fahrenheit to celsius
                     * @param fValue : double value of fahrenheit
                     * @return calculated value of celsius
                     */
                    public double f2cConvertion(double fValue) {
                                   return ((fValue - 32.0) * 5.0) / 9.0;
                    }
    }

  5. After successfully building the project, we will create the service archive using the Axis2 Eclipse Service Archiver Plugin. On the File menu, click New and then click Other to access the Axis2 wizards. Else, you can press Ctrl+N.

  6. Note : At any given time, you can go back through the wizards, change the settings, and even start the wizards all over again to create a different Web service on another JAVA project available in your workspace.

  7. Select the Axis2 Service archiver and click Next. You will see the Axis2 service definition selection page.

  8. On this page, select the output location of the “TemperatureWebService” Java project that we previously developed. Here we point to the service implementation classes. If there is more than one class, you only have to point to the JAVA project build location. The wizard includes all the implementation files. To be on the safe side, if you are going to expose a complex project as a Web service, it's better to select the include .class files check box to omit unnecessary resource files that will increase the size of the deployable service archive that we are going to create.

  9. After selecting the correct output location, click Next.

  10. On this page, you can browse for the WSDL file. If you do not want to add a WSDL file to the service archive, select the Skip WSDL check box. Else you can select the Select WSDL check box, and specify the location of the WSDL file. We will skip the WSDL for the moment.

  11. Click Next.

  12. This page is to add the libraries. The library name (with the full path) can be specified by either typing it or browsing for it. Once the library name with the full path is entered, click Add to add the library to the list. The added libraries should be displayed in the Added libraries list. You can add as many external libraries as you wish.

    If any added library has to be removed, select it from the Added libraries list and click Remove.

  13. For this example, we do not need any external libraries added to the generated service. Therefore, click Next to proceed to the next step.

  14. This page is about the services.xml generation. If you have a custom services.xml file, you can select the services.xml file on this page by browsing for it or you can generate the service XML automatically. The browsing option is disabled when the Generate service xml automatically check box is selected.

  15. For this example, we use the automatically generated services.xml rather than a custom written one. Therefore, select the Generate service xml automatically check box, and then click Next.

  16. Note that this page will appear only if you selected to generate the services.xml automatically in the previous step. (If you selected a services.xml file, then you will be directed to the last page of the wizard.) After entering the correct service name and a valid fully qualified class name, load the existing methods of that class by clicking Load. If it is successfully loaded, you will see a table at the bottom of the page with the details of the loaded class. You can specify the methods to include in the services.xml by selecting the corresponding check boxes.

  17. Select the Search declared method only check box, to remove the inherited methods from the class. We do not need the inherited methods to be exposed and our only interest is in temperature conversion logic. Click Next to proceed to the last page of the wizard.

  18. On the last page of the wizard, specify the output file location and the output archive file name to complete the wizard. Note the location given in the example above. After specifying a name to identify the service that we will be deploying, we can directly guide the wizard to deploy this newly created Web service on any available Web service repository.

    Since we already have the Apache Axis2 Web application deployed on the servlet container, we can easily guide the wizard to deploy the service in the Axis2 Webapp (Axis2.war) inside Apache Tomcat. After deploying the Web application, the service repository will be available in the <TOMCAT_HOME>/webapp/axis2/WEB-INF/services folder.

  19. Click Finish to complete the steps in the wizard.

  20. Start the servlet container (in this case the Apache Tomcat), and navigate to http://localhost:8080/axis2 This will lead to the Axis2 Web application home page.

    To verify that our newly created service is available, navigate to the Services tab and view the available services. Your Temperature Converter service will be there.

Testing the Temperature Converter Service

Now that we have the service up and running, let's go ahead and test the created Temperature Converter service. This consists of two steps.

We have to generate the client code and invoke the Web service. For that we use the Axis2 Eclipse Codegen Plugin to create a WSDL from a Java source. For demonstration purposes of the Eclipse CodegAxis2 Eclipse Codegen Plugin we will do that in two steps. As the first step, we will create the WSDL, and then as the second step use that WSDL to generate code for the client.

Also note that you can skip the WSDL generation part since the deployed Web service is up and running. The WSDL will be generated when we click Temperature Converter under the available services in the Axis2 Web application. However, since the main aim of this tutorial is to introduce the Axis2 Eclipse Plugins, we are not going to use that option. We will use the Axis2 Eclipse Codegen Plugin to generate the WSDL for us.

Step 1 : Generate the WSDL from the Java source

  1. Start the Axis2 Eclipse Codegen Plugin by selecting it and clicking Next on the New wizard page.
  2. We are going to create the WSDL using the Axis2 Eclipse Codegen Plugin Java2wsdl option.

  3. On the first page, select the Generate a WSDL from a JAVA source and file option. Then, click Next.
  4. On this page, select the class to be exposed and the relevant .jar files /classes to be loaded as the classpath.

    Add the folder location of the class files of our project. After specifying the fully qualified class name click on the Add Folder button and add the location of the class files of your project. After the libraries have been set, click Test Class Loading to test whether the class is loadable.

  5. Test the class loading by clicking Test Class Loading
  6. Unless the class loading is successful, the Next button will not be enabled. As we did on the service archive generation, we have to enter the fully qualified class name as the service class. Then select the project output folder.

  7. Once the class loading is successful, click Next. The page below will appear.
  8. This page allows the parameters to be modified by setting the options for the generator. Note: If you customize these parameters (instead of the default), you will be generating a different Web service descriptor with different parameters than what we have generated by using the service archive wizard.

    NOTE : If you are using the 1.3 version of the Axis2 Eclipse Plugin you need to change the shema target namespace to http://example.ws to comply it with the Axis2 1.3 version. Please drop the trailing /xsd part of the shema target namespace. All other earlier version than 1.3 do not need this change.

  9. We will accept all the default values. Click Next.
  10. Here you can specify the output file location by typing or browsing for it using the Browse button. You have the option of browsing only Eclipse workspace projects by selecting the Add the source to a project on current eclipse workspace option. Else you have the option of saving the codegen results to the file system.
  11. Once the output file location and the output WSDL file name is added, click Finish to complete generation.
  12. A message appears informing you that all the operations were completed successfully. You have successfully completed the Java2WSDL code generation and created the WSDL of the Temperature Converter Service.

 

Step 2 : Generate code and invoke the service

In this step, we have to generate code, which represents the client side stubs, using the Axis2 Eclipse Codegen Plugin and test the deployed Temperature Converter Service by using the WSDL file generated in Step 1.

To create the client stub using the Axis2 Eclipse Codegen Plugin wsdl2java option:

  1. Start the Axis2 Eclipse Codegen Plugin by selecting it and clicking Next on the new wizard page.
  2. Create the client stub using the Axis2 Eclipse Codegen Plugin wsdl2java option by selecting the Generate Java source code from WSDL file option. Click Next.
  3. Select the previously generated WSDL location by browsing for it. Click Next.
  4. Once the WSDL file is selected, the next page will take you to the page from where the codegen options are to be selected. By far this is the most important page in this wizard. This page determines the characteristics of the code being generated.

    If this is the first time you invoked the wizard, you will see that the most common options are set by default. Advanced users will find it very easy to turn the knobs using these options. You can select Custom from the Select Codegen Options list and then change/edit the fields that you need. We are going to create stubs accepting the default values.

  5. Accept the default settings and click Next.
  6. On the final page of the wizard, you can specify the output file path by typing or browsing for it using the Browse button. You have the option of browsing only Eclipse workspace projects by selecting the Add the source to a project on current eclipse workspace option. Else you have the option to save the codegen results to the file system.

  7. Click Add the source to a project on current eclipse workspace and select the project that you have created earlier.
  8. Select the Add codegen jars to the codegen resulted project check box so that we can easily compile the code without worrying about adding Axis2 libraries to the JAVA project classpath.

  9. Click Finish. A message appears informing you that you have successfully completed the WSDL2Java code generation.
  10. The client stub files will be generated in the project.
  11. In order to compile the code we need to add the generated libraries to the project library path. You can add the .jar files in the lib directory by navigating the project properties of the Java project.

    After adding the required libraries, you will be able to clean build the project without any errors.

     

  12. Now we will write the Client, and use this client to invoke the Web service deployed earlier. Add the following TemperatureConverterServiceClient. java class to the project,
  13. package ws.example;
    
    public class TemperatureConverterServiceClient {
        public static void main(String[] args) {
            TemperatureConverterStub stub;
            try {
                double c_value = 32;
                stub = new TemperatureConverterStub
               ("http://localhost:8080/axis2/services/TemperatureConverter");
                TemperatureConverterStub.C2FConvertion c2f = new TemperatureConverterStub.C2FConvertion();
                c2f.setCValue(c_value); 
                TemperatureConverterStub.C2FConvertionResponse res = stub.c2FConvertion(c2f);  
                System.out.println("C Value : "+c_value+ "\tResult : " +res.get_return());
                TemperatureConverterStub.F2CConvertion f2c = new TemperatureConverterStub.F2CConvertion(); 
                f2c.setFValue(res.get_return());
    
                TemperatureConverterStub.F2CConvertionResponse res1 = stub.f2CConvertion(f2c);
                System.out.println("F Value : "+res.get_return()+ "\tResult : " +res1.get_return());
           } catch (Exception e) {
               e.printStackTrace();
           }
        }
    }

    NOTE : If you are using an early version of the Axis2 Eclipse Plugins than 1.3, you may have to change the client according to the stubs that have been generated. Previous verisons of Axis2 did generate multiple stubs for each port type of the wsdl and you may use the example client given below for those versions.

    package ws.example;
    
    import java.rmi.RemoteException;
    
    import org.apache.axis2.AxisFault;
    
    public class TemperatureConverterServiceClient {
    
      public static void main(String[] args) {
        TemperatureConverterTemperatureConverterSOAP11PortStub stub;
        try {
          double c_value = 32;
          stub = new TemperatureConverterTemperatureConverterSOAP11PortStub
    	 		("http://localhost:8080/axis2/services/TemperatureConverter");
          TemperatureConverterTemperatureConverterSOAP11PortStub.C2FConvertion c2f 
          	= new TemperatureConverterTemperatureConverterSOAP11PortStub.C2FConvertion();
          c2f.setCValue(c_value);
          TemperatureConverterTemperatureConverterSOAP11PortStub.C2FConvertionResponse res 
            = stub.c2FConvertion(c2f);
           System.out.println("C Value : "+c_value+ "\tResult : " +res.get_return());
           TemperatureConverterTemperatureConverterSOAP11PortStub.F2CConvertion f2c 
    	 = new TemperatureConverterTemperatureConverterSOAP11PortStub.F2CConvertion();
            f2c.setFValue(res.get_return());
    
            TemperatureConverterTemperatureConverterSOAP11PortStub.F2CConvertionResponse res1 
    	 = stub.f2CConvertion(f2c);
            System.out.println("F Value : "+res.get_return()+ "\tResult : " +res1.get_return());
            } catch (AxisFault e) {
            	e.printStackTrace();
            } catch (RemoteException e) {
                    e.printStackTrace();
            }
      }
    }

    After adding the TemperatureConverterServiceClient. java class to the project, compile, and build the project. After that you can run the client to test the service. If you have successfully carried out all the steps, the temperature converter service will be invoked and the results of the service will be displayed on the command line output.

    Note: The stub assumes that you run Tomcat on 8080 (if not, change the stub URL and re-run the client).

Sample Project Src Download

Conclusion

Web service creation, deployment, and testing is no more a time consuming task. With the Axis2 Eclipse Plugins you can create, deploy, and test your Web services using a wizard. The time to write, deploy, and test a Web service is reduced to a minimum with the introduction of these tools.

PART 2 - Top Down Approach

 

See also..

How to create a web service using WSAS tools in 3 steps

How to create a web service client using WSAS tools in 3 steps

How to debug a web service using WSAS tools in 3 steps

How to edit a web service while testing it using WSAS tools in 3 steps

References

Apache Axis2 - http://ws.apache.org/axis2

Apache Axis2 Tools - http://ws.apache.org/axis2/tools/index.html

Eclipse.org - http://ws.apache.org/axis2/tools/index.html

Eclipse Plugins - http://www.eclipseplugincentral.com/

Author

Lahiru Sandakith P.G. WSO2, Inc. sandakith at wso2 dot com

tameem.ahmed.gmail.com's picture

Errors in stub using axis2-wsdl2code-maven-plugin

I a newbie just stepped in to the axis world and starting as a developer. I used the axis2-wsdl2code-maven-plugin to generate sources. But got errors on Stubs about 100+ of them. Would really appreciate if someone can can help me get rid of these errors. 7/18/12 1:05:20 PM PDT: [ERROR] *** is not abstract and does not override abstract method serialize(javax.xml.namespace.QName,org.apache.axiom.om.OMFactory,org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter,boolean) in org.apache.axis2.databinding.ADBBean 7/18/12 1:05:20 PM PDT: [ERROR] *** org.apache.axis2.databinding.ADBDataSource is abstract; cannot be instantiated 7/18/12 1:05:20 PM PDT: [ERROR] *** cannot find symbol symbol : method createOMElement(org.apache.axiom.om.OMDataSource,javax.xml.namespace.QName) location: interface org.apache.axiom.om.OMFactory 7/18/12 1:05:20 PM PDT: [ERROR] *** is not abstract and does not override abstract method serialize(javax.xml.namespace.QName,org.apache.axiom.om.OMFactory,org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter,boolean) in org.apache.axis2.databinding.ADBBean 7/18/12 1:05:20 PM PDT: [ERROR] *** org.apache.axis2.databinding.ADBDataSource is abstract; cannot be instantiated 7/18/12 1:05:20 PM PDT: [ERROR] *** cannot find symbol symbol : method createOMElement(org.apache.axiom.om.OMDataSource,javax.xml.namespace.QName) location: interface org.apache.axiom.om.OMFactory 7/18/12 1:05:20 PM PDT: [ERROR] *** is not abstract and does not override abstract method serialize(javax.xml.namespace.QName,org.apache.axiom.om.OMFactory,org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter,boolean) in org.apache.axis2.databinding.ADBBean 7/18/12 1:05:20 PM PDT: [ERROR] *** org.apache.axis2.databinding.ADBDataSource is abstract; cannot be instantiated 7/18/12 1:05:20 PM PDT: [ERROR] *** cannot find symbol symbol : method createOMElement(org.apache.axiom.om.OMDataSource,javax.xml.namespace.QName) location: interface org.apache.axiom.om.OMFactory Here is my plugin...    <plugin> <groupId>org.apache.axis2</groupId> <artifactId>axis2-wsdl2code-maven-plugin</artifactId> <version>1.6.2</version> <executions> <execution> <id>codegen</id> <phase>generate-sources</phase> <goals> <goal>wsdl2code</goal> </goals> <configuration> <wsdlFile>${basedir}/src/main/resources/wsdl/posapiserv.wsdl</wsdlFile> <outputDirectory>${project.build.directory}/generated-sources</outputDirectory> <packageName>com.touchstone.posapiserv</packageName> <flattenFiles>true</flattenFiles> </configuration> </execution> </executions> </plugin>
harshana.wso2.com's picture

Please Refer the new Article

Hi,

We have written an article on the newer version of these plugins here [1] which is shipped with WSO2 Developer Studio.

Please follow the new article and try our new Axis2 plugins there.

[1]. http://wso2.org/library/articles/2012/06/apache-axis2-integration-eclipse

Thanks and Regards,

Harshana

garima913.gmail.com's picture

Error : Class not foundws.example.TemperatureConverter

I keep getting the error after the Add libraries part, when i click on next and try loading the vile though the path is correct. Please help.
harshana.wso2.com's picture

Please Refer the new Article

Hi,

We have written an article on the newer version of these plugins here [1].

Please follow that article and try our new Axis2 plugins there.

[1]. http://wso2.org/library/articles/2012/06/apache-axis2-integration-eclipse

Thanks and Regards,

Harshana

posstaridli1591.yahoo.com's picture

Hi , I follow the same steps

Hi , I follow the same steps to avoid the InvocationTargetException by adding the two jars into Axis2_Codegen_Wizard_1.3.0\lib folder. And also added in to plugin.xml file.But still the same problem is coming when i am trying to generate the wsdl file . Can you please help me out on this.Because i am totally new to this axis2 and webservices. Thnaks in advance. Regards Debapriya @ orbitz promo codes
harshana.wso2.com's picture

Please Refer the new Article

Hi,

We have written an article on the newer version of these plugins here [1].

Please follow that article and try our new Axis2 plugins there.

[1]. http://wso2.org/library/articles/2012/06/apache-axis2-integration-eclipse

Thanks and Regards,

Harshana

jothisha.rediffmail.com's picture

error while deploying web service

IWAB0135E An unexpected error has occurred. 503 Service Unavailable pls. give me the solution.
uma_natarajan.hotmail.com's picture

Compilation error

Thanks for the nice article. Everything is working ok until step 8. The client stub got created, but i do get lot of compilation error. I did add all the jar files from axis2-1.5.5-bin.zip to projects lib folder. still having compilation error. what do you mean by "In order to compile the code we need to add the generated libraries to the project library path. You can add the .jar files in the lib directory by navigating the project properties of the Java project." The article missing the screeshot, so couldn't able to see what do you mean by this. Here are some of my errors: couldn't find org.apache.axis2.client.FaultMapKey org.apache.axis2.databinding.ADBDataSource Needed to convert F2CCConvertion, F2CCConversionResponse,C2FConversion, C2FConversionResponse java to abstract. Please let me know what I;m doing wrong. Thanks a lot in helping, Uma
lanmengrose.gmail.com's picture

Thank you for posting this

Thank you for posting this article. I also plugged the show on Face book, with mixed results from my friends. All I ask of people, whether they are familiar with homeopathy or not, is to watch my wedding dresses.http://www.bridalgownsstore.com/Wholesale-mermaid-wedding-dresses_c119
c.amty1234.gmail.com's picture

java.lang.reflect.InvocationTargetException- install 1.3 version

Hello All, I encountered this exception while using the Axis2 Code generator wizard. I think there is some issue with the latest plugin i.e. 1.4 After installing 1.3 versions of the plugins(Both the code generator and service archive) , it worked fine. Also i am using axis2-1.4.1 if it helps. Lahiru , thanks for post it is very simple and give us a good start. Amit
moliver.corenttech.com's picture

Same InvocationTargetException on 1.5.4 versions

I am getting exactly the same problem with the CodeGen last step. Two others in my shop have seen the same problem. They suggested I switch to CXF as they don't have any problem with that? Doesn't anyone in the community test things before they release? I am a member of the Apache Software Foundation and a committer on other projects and am shocked that this same problem has been reported since 2008.
ronquillocortez.gmail.com's picture

Thanks to the advent of

Thanks to the advent of internet technology, the Communication Revolution that we are in the midst of has really gained ground. Dedicated web services have now made it possible to ply the World Wide Web at a click and from just about any remote corner of the world. It is in this pursuit that Live Pages, Mumbai, India has designed its application programming interfaces. http://azcarpetandtilecleaning.com/
babu.mtechcs.gmail.com's picture

getting error while genrating wsdl from java class

I am getting following error while click on finish button at last button of Axis2 codegen wizard.... An error occurred while completing process -java.lang.reflect.InvocationTargetException
henna.beckett.yahoo.com's picture

i also got the same error

i also got the same error while i was working on it but i kept on doing it, i dont think that anything is done right in the first time, in the thrid time, it was done the way i wanted.. try it out
samkirk28.hotmail.com's picture

Do you have an updated

Do you have an updated version of this for 2010? I would like to know. It would really help me a lot with my essay paper.
martincraviotto.gmail.com's picture

InvocationTargetException with the Apache Axis2 Eclipse plugin

Bueno vamos por parte, me volvi loco buscando como solucionar este pequeño inconveniente que al parecer lo deberiamos tener todos pero evidentente muchos lo tienen solucionado de forma "automagica" con lo cual aca la va la solucion a todos los que tuvimos este problema. Antes que nada quiero aclarar, que seria EXCELENTE que cada unos de nosotros se concientizara y cuando encuentre la solucion al problema lo muestre, lo publique lo comparta. Entre todos podemos ayudarnos y asi el tiempo lo usamos para la generacion de nuevas cosas y no de cosas repetidas que otros ya lo tienen solucionado. Bien la solucion es la siguiente. Deberian abrir el plugin.xml que se encuentra en: /plugin.xml ahi hay que abrirlo y ver de todas las librerias existentes qeu no esten buscarlas y agregarlas en /lib. Ademas de las no existentes que figuran ahi se deben agregar las siguientes: stax-api-1.0.1.jar backport-util-concurrent-3.1.jar y obviamente agregar estas entradas en plugin.xml Asi mismo notar que no existe ninguna libreria tal cual esta detallada como y para lo cual la misma fue reemplazada por estas dos librerias: Ademas modificar en el mismo archivo plugin.xml la propiedad version="1.3.0" por este valor : version="1.4.0" y modificar el nombre de la carpeta que contiene todo el Generador indicando que se trata de la version 1.4.0 para que no hayas dudas. Una vez hecho esto copiar toda la carpeta Axis2_Codegen_Wizard_1.4.0 al menos como la tengo yo nombrada a la carpeta plugin de eclipse. Una vez hecho esto borrar de nuestro Workspace\.metadata\.plugins la vieja carpeta de Codegen existente. Con esto realizado, abrir nuevamente eclipse y veran como todo funciona a la perfeccion. Espero que les sea util, lamento no haberlo descritpo en English, pero preferi hacerlo en Español como se debe hacer y algun voluntarioso traductor lo puede llevar a English. Cualquier inconveniente no duden en escribirme. martincraviotto@gmail.com
pabloiec.gmail.com's picture

InvocationTargetException with the Apache Axis2 Eclipse plugin c

Hi All, Here my answer and translation to martincraviotto@gmail.com, because his post has completely make my plug-in work. Thanks mate and I add my small comments. The point is that this plug-in seems to miss some jars the should be in the lib directory. So in my folder of Eclipse Plugins where I had unzipped the plug-in contents: ..../eclipse-SDK-3.6-linux-gtk/plugins/Axis2_Codegen_Wizard_1.3.0 Open plugin.xml Ensure that each jar mentioned under the libraries sections is existing in the lib folder. In my case I needed to google and download from Internet (findjar) the following ones that I did not see and were referred in plugin.xml: jibx-run-1.1.5.jar , jibx-bind-1.1.5.jar , stax-api-1.0.1.jar , backport-util-concurrent-3.1.jar . I did not find in Internet woden-1.0M8 but I did find woden-api-1.0M8.jar and woden-impl-dom-1.0M8.jar so I also downloaded them, put them in the lib folder as the others, comment out the entry for woden-1.0M8 and add two new ones for the two libraries I found. Change also the version number at the beginning of plugin.xml, property version="1.3.0" for version="1.4.0" Save the file and close it. Now rename the folder of the plug in to ..../eclipse-SDK-3.6-linux-gtk/plugins/Axis2_Codegen_Wizard_1.4.0 Before launching Eclipse again, delete the contents of the folder Workspace\.metadata\.plugins\Axis2_Codegen_Wizard .... So not any caching of the old plug-in could be involved. Now launch Eclipse again and the plug in should work according to instructions, but it also took my few hours until I found the post from martincraviotto@gmail.com. Cheers, Pablo.
gokussj41990.gmail.com's picture

Tool Bug

The tool codegen in eclipse require JDK min 6 version and also eclipse need to be open in some proper way see here it a good tutorial http://websaxis2tut.blogspot.com/
souvik12002.gmail.com's picture

Preview is good

Preview is good
sriramsv81.gmail.com's picture

AxisFault: The service cannot be found for the endpoint referenc

Hi, I am getting the service cannot be found for the EPR error when I compile the TemperatureConverterClient. for the AxisFault. I was trying to execute the example given in this page. Let me know if you any solution. Thanks Sriram
ferdonmx.hotmail.com's picture

Get IP from the client

Hi, im from mexico and this really help me, but i would like to know i way to get the ip from the client every time that invokes our web service. For example the same service that is here posted. It will really help.. Please
michelle.rays.yahoo.com's picture

apache axis2 is cool

apache axis2 is a great tool. i would be preparing a review after i finish my sample essay and education essays.
jaber.emploi.hotmail.com's picture

Help! Axis2 code generater wizard doesn't completed correctly

Hi Lahiru, First of all, thank you for the tuorial that was very clear and simple. But unfortunatly I have faced one problem in the last step of Axis2 code Generater Wizard. So when I click under the Finish Button to complete the generation this error message appears :"An error occured while completing process -java.lang.reflect.InvocationTargetException". I will be very thankful if you help resolving this problem as soon as possible. Jabarov.
martincraviotto.gmail.com's picture

The same Problem - El mismo problema

Hola, les cuento que estoy por realizar mi trabajo final de la carrera, y el cual incluia en parte el trabajo con webservice para poder conectar desde un mobil usando webservice. el tema es que cuando llego al punto final me encuetro con el mismo problema. "An error occured while completing process -java.lang.reflect.InvocationTargetException Por favor como deberia resolverlo.
krishna.sakinala.wipro.com's picture

answer

I could not see answer for the above query. Query: Hi Lahiru, First of all, thank you for the tuorial that was very clear and simple. But unfortunatly I have faced one problem in the last step of Axis2 code Generater Wizard. So when I click under the Finish Button to complete the generation this error message appears :"An error occured while completing process -java.lang.reflect.InvocationTargetException". I will be very thankful if you help resolving this problem as soon as possible. Can you please help me how to resolve this issue
sunilkswain.gmail.com's picture

Not getting the solution

I am also getting the same error "An error occured while completing process -java.lang.reflect.InvocationTargetException".Let me know the solution please.
jaber.emploi.hotmail.com's picture

For help!

Hi Lahiru, First of all, thank you for the tuorial that was very clear and simple. But unfortunatly I have faced one problem in the last step of Axis2 code Generater Wizard. So when I click under the Finish Button to complete the generation this error message appears :"An error occured while completing process -java.lang.reflect.InvocationTargetException". I will be very thankful if you help resolving this problem as soon as possible. Jabarov.
tom.schavo.gmail.com's picture

Technology News

Technology News Apache Axis2 tools are really good and the plugins are easy to download.
dami_gupta.yahoo.com's picture

Help writing Java2WSDL generator

HI, I have been following steps above to write a webservice, and am at the point where I am generating the WSDL from the java file. I am creating TemperatureConverter.wsdl. The Axis2 Codegen Wizard executes fine and I get the message box 'All operations completed successfully'. I can view the wsdl file externally on Wordpad. However, when I try to view it in eclipse, I get an error as "An error has occurred... Could not initialize class org.eclipse.wst.wsdl.WSDLPackage$Literals" Then I went to the error log, and found - java.lang.NoClassDefFoundError: Could not initialize class org.eclipse.wst.wsdl.WSDLPackage$Literals at org.eclipse.wst.wsdl.internal.impl.DefinitionImpl.eStaticClass(DefinitionImpl.java:295) at org.eclipse.emf.ecore.impl.EObjectImpl.eClass(EObjectImpl.java:224) at org.eclipse.emf.ecore.impl.ENotificationImpl.getFeature(ENotificationImpl.java:223) at org.eclipse.wst.wsdl.internal.impl.WSDLElementImpl.eNotify(WSDLElementImpl.java:379) at org.eclipse.wst.wsdl.internal.impl.DefinitionImpl.eNotify(DefinitionImpl.java:515) at org.eclipse.wst.wsdl.internal.impl.DefinitionImpl.setLocation(DefinitionImpl.java:341) at org.eclipse.wst.wsdl.internal.impl.DefinitionImpl.setDocumentBaseURI(DefinitionImpl.java:1135) at org.eclipse.wst.wsdl.ui.internal.text.WSDLModelAdapter.createDefinition(WSDLModelAdapter.java:109) at org.eclipse.wst.wsdl.ui.internal.InternalWSDLMultiPageEditor.createAndSetModel(InternalWSDLMultiPageEditor.java:151) at org.eclipse.wst.wsdl.ui.internal.InternalWSDLMultiPageEditor.buildModel(InternalWSDLMultiPageEditor.java:118) at org.eclipse.wst.wsdl.ui.internal.asd.ASDMultiPageEditor.buildAndSetModel(ASDMultiPageEditor.java:173) at org.eclipse.wst.wsdl.ui.internal.asd.ASDMultiPageEditor.createPages(ASDMultiPageEditor.java:149) at org.eclipse.wst.wsdl.ui.internal.InternalWSDLMultiPageEditor.createPages(InternalWSDLMultiPageEditor.java:406) at org.eclipse.ui.part.MultiPageEditorPart.createPartControl(MultiPageEditorPart.java:357) at org.eclipse.ui.internal.EditorReference.createPartHelper(EditorReference.java:662) at org.eclipse.ui.internal.EditorReference.createPart(EditorReference.java:462) at org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:595) at org.eclipse.ui.internal.EditorReference.getEditor(EditorReference.java:286) at org.eclipse.ui.internal.EditorManager.findEditor(EditorManager.java:403) at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched(WorkbenchPage.java:2799) at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(WorkbenchPage.java:2762) at org.eclipse.ui.internal.WorkbenchPage.access$11(WorkbenchPage.java:2754) at org.eclipse.ui.internal.WorkbenchPage$10.run(WorkbenchPage.java:2705) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70) at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2701) at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2685) at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2676) at org.eclipse.ui.ide.IDE.openEditor(IDE.java:651) at org.eclipse.ui.ide.IDE.openEditor(IDE.java:610) Any idea what this is? Thanks in advance.
nlasandaruwan.gmail.com's picture

Help writing Java2WSDL generator

Hi, I am using Axis2_Codegen_Wizard_1.3.0 with latest eclipse galileo, JDK 1.6 and Tomcat 6 ? Is it valid ? Or is there any new plugin for new softwares mention above ? Thanks Sandaruwan
v.kris21@gmail.com's picture

Error

Step 5 of testing the Temperature Converter Service I get this error: java.lang.reflect.InvocationTargetException. Anyone seen this before? Thanks, Veena
v.kris21@gmail.com's picture

Still getting error

I tried out what muhlis suggested below and I still get the error. Thanks, Veena
ymtoh.yahoo.com's picture

Syntax error on token "getInstance"

Hi, i got this error when i tried to run the code where i got no idea.. anyone can help? org.apache.axis2.AxisFault: Unresolved compilation problems: Syntax error on token "getInstance", Identifier expected after this token Syntax error on token ".", ; expected at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:512) at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:370) at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:416) at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:228) at org.apache.axis2.client.OperationClient.execute(OperationClient.java:163) at org.tempuri.Ws_CheckFraudStub.CheckFraud(Ws_CheckFraudStub.java:460) at TestAxisWebserviceClient.main(TestAxisWebserviceClient.java:54)
v.kris21@gmail.com's picture

The tool does not show up in eclipse

Now the tool does not show up in eclipse.
v.kris21@gmail.com's picture

Still getting error

I tried out what muhlis suggested below and I still get the error. Thanks, Veena
v.kris21@gmail.com's picture

Still getting error

I tried out what muhlis suggested below and I still get the error. Thanks, Veena
v.kris21@gmail.com's picture

Still getting error

I tried out what muhlis suggested below and I still get the error. Thanks, Veena
v.kris21@gmail.com's picture

Still getting error

I tried out what muhlis suggested below and I still get the error. Thanks, Veena
v.kris21@gmail.com's picture

Still getting error

I tried out what muhlis suggested below and I still get the error. Thanks, Veena
v.kris21@gmail.com's picture

Still getting error

I tried out what muhlis suggested below and I still get the error. Thanks, Veena
v.kris21@gmail.com's picture

Still getting error

I tried out what muhlis suggested below and I still get the error. Thanks, Veena
v.kris21@gmail.com's picture

Still getting error

I tried out what muhlis suggested below and I still get the error. Thanks, Veena
v.kris21@gmail.com's picture

Error message:Part 1 step 11

Hi, I am running with the Axis tools 1.4, Axis 2.1.5. When I follow the steps in Part 1 I get an error in step 11. The requested resource is not available. Actually when I start tomcat I see the following errors in the log: org.apache.axis2.transport.http.AxisAdminServlet java.lang.ClassNotFoundException: org.apache.axis2.transport.http.AxisAdminServlet Any help will be greatly appreciated. Thanks, Veena
ws02.20.mcrocker.spamgourmet.com's picture

Resolved: Eclipse Axis2 plugin does not support Axis2 1.5.x

According to the AXIS2-4375 Jira entry, the Axis2 plugin does not support Axis2 1.5.x, which has some class(path) changes that the plugin doesn't expect. As a result, when you run the WebService, it tries to bind to a class that it cannot find.

The solution is to simply use Axis2 1.4.1 instead. Unfortunately, it's not easy to just downgrade your project. You pretty much have to start from scratch, but use Axis2 1.4.1 instead.

If you really want to use Axis2 1.5.x, it might be possible to edit the deployment descriptor manually to fix the path, but I wouldn't hold my breath waiting for that to work.

Also, if you're using 1.4.1, then the URL for the service is http://localhost:8080/Axis2WSTest/axis2-web/index.jsp instead of what the article specifies. The context root URL will just give you a 404 Not Found page.

anuj123's picture

Top-down appraoch using attachment(wsdl with xsd:base64Binary)

Hi, I was trying to use Axis2 Service Archiver using the top down approach. I have the wsdl and I have created the client stubs and server stubs. Next I have implemented the skeleton class on the server. Now I want to use Axis2 Service Archiver to deploy the service on my server. But when I put the name of the skeleton class in the load class option it shows that it is unable to find the class. I am pointing to the correct bin directory where the classes are located. I tried making a simple test class in the same package as my skeleton, the archiver is able to load this class but when i implement a method that uses the skeleton class then again it is not able to load it. I even added axis2-adb-1.4.jar as the external library but no use. Could any one help me finding out why the archiver tools is not able to load a class generated from wsdl having attachments? Note: if I select the wsld location and the services.xml file while using the archiver option then it works fine, but I want to deploy it without using the wsdl and services file. Thanks Anuj
se's picture

java.lang.NoClassDefFoundError: org/apache/woden/resolver/URIRes

Hi Lahiru, Its an excellent article which you have given. I tried this example, I am able to come upto to execute the client code, but here I am getting the following error. Can you help me out on this. log4j:WARN No appenders could be found for logger (org.apache.axis2.description.AxisService). log4j:WARN Please initialize the log4j system properly. Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/woden/resolver/URIResolver at org.apache.axis2.deployment.ModuleDeployer.deploy(ModuleDeployer.java:60) at org.apache.axis2.deployment.repository.util.DeploymentFileData.deploy(DeploymentFileData.java:136) at org.apache.axis2.deployment.DeploymentEngine.doDeploy(DeploymentEngine.java:597) at org.apache.axis2.deployment.RepositoryListener.loadClassPathModules(RepositoryListener.java:195) at org.apache.axis2.deployment.RepositoryListener.init2(RepositoryListener.java:70) at org.apache.axis2.deployment.RepositoryListener.(RepositoryListener.java:63) at org.apache.axis2.deployment.DeploymentEngine.loadFromClassPath(DeploymentEngine.java:164) at org.apache.axis2.deployment.FileSystemConfigurator.getAxisConfiguration(FileSystemConfigurator.java:135) at org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContext(ConfigurationContextFactory.java:68) at org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContextFromFileSystem(ConfigurationContextFactory.java:184) at org.apache.axis2.client.ServiceClient.configureServiceClient(ServiceClient.java:150) at org.apache.axis2.client.ServiceClient.(ServiceClient.java:143) at ws.samp.TmpConv1Stub.(TmpConv1Stub.java:103) at ws.samp.TmpConv1Stub.(TmpConv1Stub.java:89) at ws.samp.TmpConv1Stub.(TmpConv1Stub.java:140) at ws.samp.TmpConv1SrvClient.main(TmpConv1SrvClient.java:12) Thanks. -se.
whizkid's picture

org/apache/woden/resolver/URIResolver

If you found your solution then good otherwise i thought this might help.... step 1 . Copy 2 files: "backport-util-concurrent-3.1.jar" and "geronimo-stax-api_1.0_spec-1.0.1.jar" from /lib folder to the \plugins\Axis2_Codegen_Wizard_1.3.0\lib folder. step 2. Edit the plugins.xml file in the \plugins\Axis2_Codegen_Wizard_1.3.0 folder as follows: ... ... step 3. then delete the Axis2_codegen_wizard folder in ...[workspace]\.metadata\.plugins start eclipse step 4. Searched for the missing class URIResolver which led me to Apache Woden project at http://ws.apache.org/woden/ I used their M8 nightly build located at http://ws.apache.org/woden/dev/1.0/builds.html From the zip file, I used woden-api-1.0M8.jar, placed it under the lib folder of my project and added it to my project's build path in Eclipse. step 5. Replace all occurences in the stub of http://example.ws/ with http://example.ws/xsd ======================================================================================== You need to do only "STEP 4" AND "STEP 5".
coloradodude's picture

Summary using Axis Wizards 1.3.0 in Eclipse

  Web Service Development and Deployment using Eclipse plug-ins from Axis   Axis CodeGen Wizard 1.3.0 ·   Generating the WSDL o       File-New-Other (or ctrl-n) §         Axis2 Code Generator ·        Generate a WSDL from a Java source file ·        Type the fully qualified path name o       Click add folder §         Pick the appropriate bin folder such that the class can be loaded using the fully qualified name. §         Press Test Class Loading.. ·        Accept the default Java to WSDL Options ·        Specify the output location and file name. File name should match class name with .wsdl suffix. ·   Generating Java source code from a WSDL file o       File-New-Other (or ctrl-n) §         Axis2 Code Generator ·        Generate Java source code from a WSDL file ·        Pick the wsdl file using the browse button[1]. ·        Accept the default options. ·        Output o       Browse and select a project in the current Eclipse workspace o       Browse to the appropriate project o       Add the Axis2 codegen jars to the codegen resulted project o       Refresh the package explorer view in Eclipse. There will be a CallbackHandler and Stub[2] class present which were generated by the wizard. o       Modify project build path to reference appropriate jar files. §         Right-click on the project. Select build path-configure build path ·        Libraries tab o       Add Jars §         Pick your project – Lib – then select all of the jar files. o       Add External Jars[3] §         Navigate to Woden-dom<version>.lib §         Select all of the jar files in the folder ·        woden-api-<version> ·        woden-impl-dom-<version> ·        xercesImpl ·        xml-apis ·        XmlSchema-<version>     Axis Service Archiver 1.3.0 ·   Class development rules o       Do not use default package o       Methods §         Must be public §         Cannot be overloaded §         Should not use the void return type (ideally they will return String). ·   Invoking the Archiver o       File-New-Other (or ctrl-n) §         Axis2 Wizards-Axis2 Service Archiver ·        Accept most of the defaults unless you know what you are doing. ·        Name the service and input the fully qualified class name. ·        You will normally want to have the “Search declared methods only” checkbox selected to avoid having inherited methods listed. ·        Press load to see public methods. ·        Name the file and specify the location as …\Tomcat\webaps\axis2\WEB-IN\services ·   Within the Tomcat manager o       Reload the service. o       Click on the /axis2 application §         Click on Services §         Verify that the new service is present with the appropriate available operations. Sample Web Service Client (Test) Application package hello;   import hello.WorldStub.HelloThereWho;   publicclass HelloClient {       publicstaticvoid main(String[] args)       {             try             { // Initialize the stub with the appropriate URL endpoint.                   WorldStub stub = new hello.WorldStub("http://localhost:8080/axis2/services/Hello"); // An example of how to get the results from a method that doesn't require arguments                   System.out.println(stub.helloThere().get_return()); // An example of how to get the results from a method that requires arguments. // Notice that a new CLASS has to be instantiated, and the setter executed to set the argument // value. Then, the stub is called passing a reference to that class.                   HelloThereWho HTW = new HelloThereWho();                   HTW.setWho("Colorado Dude");                   System.out.println(stub.helloThereWho(HTW).get_return());             } catch (Exception e)             {                   e.printStackTrace();             }       } }   [1] Be sure to always use the browse button, even if the file name already specified is correct. Otherwise the following screen won’t have the correct behavior. [2] The stub class will likely need to be modified to append /xsd to the namespace references. [3] The code will compile fine without this step. Any client that you develop will require these jars or else a runtime error will occur.
minhajkk's picture

getting error while genrating wsdl from java class.

I am getting following erorr while click on finish button at last button.... An error occurred while completing process -java.lang.reflect.InvocationTargetException
bobypt's picture

Developing and debugging web services using axis, eclipse

I too struggled and wasted some time with Axis2 Codegen Wizard and Axis2 Service Archiver pluggins. Later I figured out much simpler and easier was to develop and debug webservices using eclipse. I have added it here. Check it out. Your suggestions and comments are welcome. Developing and debugging web services using axis, eclipse and Tomcat Regards, Boby Thomas