WSO2Con 2013 CFP Banner

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: 526426
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

blandiman's picture

Executing Axis2 Service Archiver plugin

Hi all,

Once i have a WSDL file and i execute the Apache axis service archiver i am asked to select the service xml ...in both cases "generate automatically" and select when i click on next nothing happens, there is no following page but there is no error message...any clue??

xchen9's picture

Try the solution I have

Try the solution I have above your post.

xchen9's picture

A lot of unhandled event loop when using Axis2 Service Archiver

I am using axis2-1.3 plugins for eclipse 3.3/ IBM Rational Application Developer 7.0. I managed follow this tutorial successfully once to generate a web service from a java class, but not anymore. After I started Service Archiver wizard and clicked on 'Next', I see a org.apache.log4j.Logger error and a unhandled event loop exception in my 'Error log' vpiew. The log entry for the org.apache.log4j.Logger is list below. If I clicked on the 'Next' button again, I could go on to next few screens until I reached the screen where I could select 'automatically generate service.xml'. From that screen, I could go no where. Everytime I clicked on 'Next' button, I got the two errors mentioned above and the screen didn't go to the next screen as expected. Please help me with this problem. What I don't understand is that even though I haven't select a Java service class yet, the error log shows that the error is from my class (SSOWebService). Any idea? Thanks for your help!

java.lang.NoClassDefFoundError: org.apache.log4j.Logger
 at edu.unl.is.sso.SSOWebService.<clinit>(Unknown Source)
 at java.lang.J9VMInternals.initializeImpl(Native Method)
 at java.lang.J9VMInternals.initialize(Unknown Source)
 at java.lang.Class.forNameImpl(Native Method)
 at java.lang.Class.forName(Unknown Source)
 at org.apache.axis2.tool.service.eclipse.ui.ServiceXMLGenerationPage.updateTable(Unknown Source)
 at org.apache.axis2.tool.service.eclipse.ui.ServiceXMLGenerationPage.createControl(Unknown Source)
 at org.eclipse.jface.wizard.Wizard.createPageControls(Unknown Source)
 at org.eclipse.jface.wizard.WizardDialog.createPageControls(Unknown Source)
 at org.eclipse.jface.wizard.WizardDialog.setWizard(Unknown Source)
 at org.eclipse.jface.wizard.WizardDialog.updateForPage(Unknown Source)
 at org.eclipse.jface.wizard.WizardDialog.access$2(Unknown Source)
 at org.eclipse.jface.wizard.WizardDialog$4.run(Unknown Source)
 at org.eclipse.swt.custom.BusyIndicator.showWhile(Unknown Source)
 at org.eclipse.jface.wizard.WizardDialog.showPage(Unknown Source)
 at org.eclipse.jface.wizard.WizardDialog.nextPressed(Unknown Source)
 at org.eclipse.jface.wizard.WizardDialog.buttonPressed(Unknown Source)
 at org.eclipse.jface.dialogs.Dialog$3.widgetSelected(Unknown Source)
 at org.eclipse.swt.widgets.TypedListener.handleEvent(Unknown Source)
 at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
 at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
 at org.eclipse.swt.widgets.Display.runDeferredEvents(Unknown Source)
 at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source)
 at org.eclipse.jface.window.Window.runEventLoop(Unknown Source)
 at org.eclipse.jface.window.Window.open(Unknown Source)
 at org.eclipse.ui.actions.NewWizardAction.run(Unknown Source)
 at org.eclipse.ui.internal.handlers.WizardHandler.execute(Unknown Source)
 at org.eclipse.ui.internal.handlers.HandlerProxy.execute(Unknown Source)
 at org.eclipse.core.commands.Command.executeWithChecks(Unknown Source)
 at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(Unknown Source)
 at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(Unknown Source)
 at org.eclipse.ui.internal.keys.WorkbenchKeyboard.executeCommand(Unknown Source)
 at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(Unknown Source)
 at org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEvent(Unknown Source)
 at org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequenceBindings(Unknown Source)
 at org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$3(Unknown Source)
 at org.eclipse.ui.internal.keys.WorkbenchKeyboard$KeyDownFilter.handleEvent(Unknown Source)
 at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
 at org.eclipse.swt.widgets.Display.filterEvent(Unknown Source)
 at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
 at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
 at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
 at org.eclipse.swt.widgets.Widget.sendKeyEvent(Unknown Source)
 at org.eclipse.swt.widgets.Widget.sendKeyEvent(Unknown Source)
 at org.eclipse.swt.widgets.Widget.wmChar(Unknown Source)
 at org.eclipse.swt.widgets.Control.WM_CHAR(Unknown Source)
 at org.eclipse.swt.widgets.Control.windowProc(Unknown Source)
 at org.eclipse.swt.widgets.Display.windowProc(Unknown Source)
 at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
 at org.eclipse.swt.internal.win32.OS.DispatchMessage(Unknown Source)
 at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source)
 at org.eclipse.ui.internal.Workbench.runEventLoop(Unknown Source)
 at org.eclipse.ui.internal.Workbench.runUI(Unknown Source)
 at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Unknown Source)
 at org.eclipse.ui.PlatformUI.createAndRunWorkbench(Unknown Source)
 at org.eclipse.ui.internal.ide.IDEApplication.run(Unknown Source)
 at org.eclipse.core.internal.runtime.PlatformActivator$1.run(Unknown Source)
 at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(Unknown Source)
 at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(Unknown Source)
 at org.eclipse.core.runtime.adaptor.EclipseStarter.run(Unknown Source)
 at org.eclipse.core.runtime.adaptor.EclipseStarter.run(Unknown Source)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at org.eclipse.core.launcher.Main.invokeFramework(Unknown Source)
 at org.eclipse.core.launcher.Main.basicRun(Unknown Source)
 at org.eclipse.core.launcher.Main.run(Unknown Source)
 at org.eclipse.core.launcher.Main.main(Unknown Source)

xchen9's picture

Please Help!

Can someone help me with this? It seems that the service archive plugin rememer something it shouldn't remember.

xchen9's picture

Problem solved!

I found the solution for my problem from the axis2 forum at apache site. It seems that eclipse cached plugin related stuff in .metadata/.plugin of your workspace. Once the axis2 plugin didn't find a class or other error, it was marked by eclipse or axis2 (i don't know who) and the error would be there thereafter (i think it is a axis2 plugin bug). Removing the axis2 plugin directory in ./metadata/.plugin solved my problem. Hopefully it helps others.

sandakith's picture

RE: Problem solved

Hi,

Its great to here that you found the solution to the problem. Actially the caching is inherent form the eclipse plugin architecture. Its always useful to have caching enabled in wizard plugins since it repeats most of the time by developpers always if the correct path followed. But very rarely we ran into issues with caching like your case and the solution for that is what you have done.

Always great to here that it works

Thanks

Lahiru Sandakith

name's picture

Help please!! ><"

I want to know, how i do about deploying web service. if consists case of two classes by Apache axis2 eclipse plugins?

sandakith's picture

RE : Help please!! ><"

Hi ,

Please enter the additional classpaths in the secoend stage of the java source path selection at the JAVA2WSDL wizard. You can either select the folder which contains the classes (starting point of the package decleration if there is any package) or elase points to any jars that contains the dependent set of classses. Have a look at this [1]

Thanks

Lahiru Sandakith.

 

[1]http://ws.apache.org/axis2/tools/1_3/eclipse/wsdl2java-plugin.html

emsc1's picture

I do not get the same output code than expected

Hi there,   I tried to make this tutorial work but when I generate the stubs, I have only 4 classes and not 6 : - TemperatureConverter - TemperatureConverterStub - TemperatureConverterServiceClient - TemperatureConverterCallbackHandler   I do not get TemperatureConverterTemperatureConverter* that you seem to get during the generation of the classes from the wsdl file...   And finally, the TemperatureConverterServiceClient gets errors as there are no TemperatureConverterTemperatureConverter* classes.   What am I doing wrong ? Is there something to do with the WSDL before launching the genration of the code ?   Thanks
sandakith's picture

RE : I do not get the same output code than expected

Hi, This happened because of the versions Axis1.3 and Axis1.2 with the code generation for the plugins. Seems like you are using the Axis2-1.3 versions of the plugins and the tutorial was made at the time of Axis2-1.2. I ll update the tutorial client as suit for the Axis2-1.3 as the latest downloads are directed to it. In the mean time you can replace the client code stub that on the tutotial (TemperatureConverterStub*)with what you have (TemperatureConverterStub) and the behaviour should be the same. Thanks again for the info, I ll do the nessesary updates. Lahiru Sandakith.
satishkukunuru's picture

plz help on the TemperatureConverter tutorial

 

Can any one plz help on this tutorial given in the site, i.e "Temperatue Converter"

 

In the 1st part it  went on well, I created wsdl file and generated service archiever.

But in the 2nd part, from wsdl 2 java conversion, i am not getting all java files as mentioned in the tutorial.

It is generated only two files.

As mentioned in the tutorial, I wrote TemperatureConverterServiceClient class,
but it showing full errors...since TemperatureConverterSOAP11bindingStub class
is not yet all generated from wsdl file.
 
plz help me.
emsc1's picture

RE : I do not get the same output code than expected

Many thanks Lahiru !   Indeed, playing with the axis2 plugins for eclipse previous version, it worked perfectly !   Thanks again ! 
amirk's picture

Cannot generate a stub from the generated WSDL file

Hi. I'm working on my own service. I followed the steps in the tutorial, and managed to deploy my service in Axis2. I followed your instructions and managed to create a WSDL file from my class, but when creating java code from the WSDL file, I got the following message in the wizard:   "Specified WSDL is invalid!, Please select a validated *.wsdl/*.xml file on previous page." Regards, Amir
sandakith's picture

RE: Cannot generate a stub from the generated WSDL file

Hi Amir, What is the extention the the generated file is given, also is there any formatiing or editing the wsdl after the generation. If the path is correct I cant imagine any other reason for the Indicated error message. If you can post your own service class method signatures, we can look more into it. Thanks Lahiru Sandakith
renuroy's picture

Not able to deploy the Temperature Converter service

I can't able to deploy the Temperature converter service.can't able to access http://localhost:8080/axis2 .
sandakith's picture

RE : Not able to deploy the Temperature Converter service

Hi renuroy, Please supply us with the trace that you get on the eclipse/tomcat or some steps to reproduce the problem that you encounter. Link http://localhost:8080/axis2 as mentioned is the hinted link for the started axis2 webapp, it will depend on your default servlet container default port. Please check for the tomcat logs whether the axis2 webapp correctly deployed on the container. Thanks Lahiru Sandakith.
lfds's picture

Coding a client for existing web services

hi, i followed this tutorial and was able to generate and deploy a lot of webservices and also access them with clients However all attempts to access any webservice(that have not been created by me) like ones on webmethods.net dont work. i get the following error Exception in thread "main" org.apache.axis2.AxisFault: Connection reset at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:221) at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:452)... full error message is here http://www.experts-exchange.com/Software/Server_Software/Web_Servers/Q_22670269.html this i tried on a webservice http://www.dataaccess.com/webservicesserver/numberconversion.wso?WSDL I am able to access the web services if i generate and use the client coding style mentioned in WTP1.0/Axis1.3 without errors... Why is the client style that you have used here only work with web services that has been created too in the above mentioned way and not with any existing web services ALSO when i try and generate a stubs for a webservices using Axis2 CODGEN WDSL2JAVA sometimes for some web services i get error encoded style not supported.. An error occurred while completing process -java.lang.InterruptedException: Encoded use is not supported is there a workaround for this or i wont be able to use axis2 codegen wsdl2java on such services thanks..
purushottam's picture

org.apache.axis2.AxisFault: connection reset;

When i call my webservice i am getting org.apache.axis2.AxisFault: Connection reset; exception Any thought on this. The webservice is is deployed in Axis2 engine. The client is a batch program which reads messages from a queue and post it to the webservice. Tipically 200K messages will be processed and posted to webservise, out of around 20 K will throw Connecction reset; exception. http client is commons-httpclient-3.0.jar Axis 2's ServiceClient is used to call WS. Please help me to resolve this issue.   java.net.SocketException: Connection reset; nested exception is:      org.apache.axis2.AxisFault: Connection reset; nested exception is:      java.net.SocketException:
sandakith's picture

RE : Coding a client for existing web services

hi lfds, Its really nice that you were able to follow the tutorial. About the http://www.experts-exchange.com/Software/Server_Software/Web_Servers/Q_22670269.html This is simply because the connection can not be establish the with the server. Please tell us if you really need to further debug the error. About the java.lang.InterruptedException: Encoded use is not supported Axis2 by design do not support RPC encoded style of wsdls - http://ws.apache.org/axis2/1_2/Axis2-rpc-support.html You can try with the services available here - http://www.webservicex.net/WCF/default.aspx CurrencyConverter http://www.webservicex.net/WCF/ServiceDetails.aspx?SID=18 Thanks Lahiru Sandakith
lfds's picture

RE : Coding a client for existing web services

Hello Sir. Thanks for replying but the problem still persists........ I tried with the service that you mentioned >>You can try with the services available here - http://www.webservicex.net/WCF/default.aspx >>CurrencyConverter http://www.webservicex.net/WCF/ServiceDetails.aspx?SID=18 and used the following client public class Client { public static void main(String[] args) { CurrencyConvertorStub stub; try{ stub = new CurrencyConvertorStub("http://www.webservicex.net/CurrencyConvertor.asmx"); CurrencyConvertorStub.ConversionRate conversionRate = new CurrencyConvertorStub.ConversionRate(); conversionRate.setFromCurrency(CurrencyConvertorStub.Currency.USD); conversionRate.setToCurrency(CurrencyConvertorStub.Currency.INR); CurrencyConvertorStub.ConversionRateResponse res = stub.ConversionRate(conversionRate); System.out.println(res.getConversionRateResult()); }catch(AxisFault e){e.printStackTrace();} catch(Exception e){e.printStackTrace(); } } } upon running i got the same error org.apache.axis2.AxisFault: Connection reset at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:221) at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:452) at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:330) at org.apache.axis2.description.OutInAxisOperationClient.execute(OutInAxisOperation.java:294) at net.webservicex.www.CurrencyConvertorStub.ConversionRate(CurrencyConvertorStub.java:151) at net.webservicex.www.Client.main(Client.java:15) Caused by: org.apache.axis2.AxisFault: Connection reset at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:314) at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:201) ... 5 more Caused by: org.apache.axis2.AxisFault: Connection reset at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:179) at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:73) at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:305) ... 6 more Caused by: java.net.SocketException: Connection reset at java.net.SocketInputStream.read(SocketInputStream.java:168) at java.io.BufferedInputStream.fill(BufferedInputStream.java:218) at java.io.BufferedInputStream.read(BufferedInputStream.java:235) at org.apache.commons.httpclient.HttpParser.readRawLine(HttpParser.java:77) at org.apache.commons.httpclient.HttpParser.readLine(HttpParser.java:105) at org.apache.commons.httpclient.HttpConnection.readLine(HttpConnection.java:1115) at org.apache.commons.httpclient.HttpMethodBase.readStatusLine(HttpMethodBase.java:1832) at org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.java:1590) at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:995) at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:397) at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:170) at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:396) at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:346) at org.apache.axis2.transport.http.AbstractHTTPSender.executeMethod(AbstractHTTPSender.java:558) at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:176) ... 8 more You mentioned that >>This is simply because the connection can not be establish the with the server. Please tell us if you really need to further debug the error. Any idea why it was not be able to establish connection with the server. Im not running any firewall etc and the web service is running perfectly because i got the output when i used ECLIPSE WTP plugin to generate the client stubs. Why is it that Axis2 eclipse plugin is not able to connect ??? I think WTP makes use of Axis1 v1.3 . so is it a matter of Axis1 vs Axis2 ? This issue has being bothering me since over a month now so ANY HELP WOULD BE GREATLY APPRECIATED. Thanks
sandakith's picture

RE : Coding a client for existing web services

Hi lfds, its should be a difference in the commons-httpclient, Please check with the latest version. Thank s Lahiru
lfds's picture

RE : Coding a client for existing web services

Hi. Thank you so very much for all your time sir.. I was using the commons-httpclient available with the Axis2-1.2 dist i.e.commons-httpclient-3.0.1 That was also the same one that i had used in your tutorial. In either case i downloaded both the 3.0.1 stable release and 3.1-rc1 release (from http://jakarta.apache.org/) and tried with both and the result was the same above error .... Any more suggestions/solutions would be grealty appreciated Thanks
sandakith's picture

RE : Coding a client for existing web services

Hi lfds, Seems that there is a problem with codegen when we go through a proxy. Are you behind a proxy server? Well look in to more of this and follow up the issue to fix it asap. thanks Lahiru
lfds's picture

hello sir. any update on

hello sir. any update on this front ? Thanks
lfds's picture

RE : Coding a client for existing web services

thanks. so much. do keep me informed.
regis legoff's picture

Bottom-up approach : unable to load class

Dear Mr. Sandakith, being interested in developping web services, I've followed your first tutorial scenario to the letter. I've Eclipse 3.2, I've downloaded the two eclipse plugins and put them (Axis2_Codegen_Wizard_1.2.0 and Axis2_Service_Archiver_1.0.0) into the eclipse plugins directory. I can process the Axis2 service archiver wizard until the step where I have to enter service name and class name. At this step, after having typed TemperatureConverter and ws.example.TemperatureConverter, I have the following error : Error : Class not foundws.example.TemperatureConverter (with no space character between found and ws). Do you have a clue of what could happen ? I've exactly the same project name, package name, class name than in your scenario. Thanks in advance. Regards, Regis Legoff
regis legoff's picture

Solved: Bottom-up approach : unable to load class

Hi, I found my mistake, that was a wrong value for the class file location at the first step of the service archiver wizard. Sorry for the inconvenience. Regis Legoff
sandakith's picture

RE : Solved: Bottom-up approach : unable to load class

Hi Regis, No Problem, Nice to here that you went through. Lahiru Sandakith
davidwalker611's picture

Bottom-up approach: unable to load class

I am getting exactly the same problem as Regis, namely, when I get to the page in the Service Archiver where I am supposed to give the service name and class name I see the following error at the top of the form: Error : Class not foundws.example.TemperatureConverter As far as I can see I have done everything exactly the same as in the bottom-up example. Please can you suggest what might be the problem. Thanks David
ttucholski's picture

Not able to load class - RESOLVED

I am not able to load my class TemperatureConverter.  I have double checked my class path. Are there any other suggestions? RESOLVED
pete hargreaves's picture

Axis2 Code Gen Wizard - InvocationTargetException

Followed the tutorial and all working OK until, I press the Finish button of the Code Gen Wizard to generate the WSDL file - I get the Error dialoge "java.lang.reflect.InvocationTargetException". Exciting stuff - any ideas please? Pete Hargreaves
sandy's picture

Invocation target exception

I exactly get the same error that you have mentioned here when i use Codegen . And my set up is similar to yours that is jdk 1.5 , eclipse 3.3.2 ,  axis2-1.3 , codegen1.3 I was able to run Service archiver but unable to run codegen :( Can you please help me in fixing this ? :(
rkosten's picture

Invocation target exception

I'm also seeing this same error - and my set up is exactly the same as sandy's.  Like sandy, I'm able to run the service archiver plugin without issue. Have you found a solution?
iterox's picture

Solution to InvocationtargetException

Hi all who have or still are suffering from the InvocationTargetException, I've posted a blog here in which I describe the path that leads to the solution for the problem. In short it comes to this: you need to add two jar-files to the lib directory of the Axis2 Code Generator Plug-in: stax-api-1.0.1.jar and backport-util-concurrent-3.1.jar (this one also needs to be added to plugin.xml). This solution is also mentioned here. Hope this helps.
sunilcshekar.yahoo.com's picture

InvocationTargetException

Hi I tried adding these 2 jar files under Axis2 Code Generator plug-in's lib folder and added an entry in its plug-in.xml file for the "backport-util-concurrent-3.1.jar". However when I tried to generate the wsdl file again, I still get the InvocationTargetException. I use the following Tomcat : 6.0 Eclipse : 3.4.1 Axis2.war Java 1.6.0_16 Am I missing something here. For some reason I am not able to make it to work. Thanks Sunil
kasturi.srinivas.gmail.com's picture

Thanq very much iterox

InvocationtargetException problem resolved!!!!
sandakith's picture

RE : Axis2 Code Gen Wizard - InvocationTargetException

Hi Pete, Is there any other stack trace from the error , also can you port the wsdl for us to have a look. All the scenarios are tested with the given versions. Thanks Lahiru Sandakith.
chutkevivek@gmail.com's picture

Re: Axis2 Code Gen Wizard - InvocationTargetException

Mr. Sandakith, Where you able to find a solution for  Axis2 Code Gen Wizard - InvocationTargetException . Appreciate if you could you pass on the solution to me. I use the same environment as posted in the earlier threads. Apprecite your few mins for replying to this issue   Thanks Vivek Chutke
pete hargreaves's picture

RE : Axis2 Code Gen Wizard - InvocationTargetException

Hi Lahiru, Sorry for the brief first posting - thought it might be an obvious one. I've just reworked your 1st tutorial from the beginning very precisely and get the same problem. The Service Archive Wizard generated successfully but attempting to generate the WSDL from the Java source at step 7., when I pressed the Finish button on the Axis2 Code Gen Wizard, I get an Error dialoge which reads: "An error occurred while completing process - java.lang.reflect.InvocationTargetException" Is there a log or somewhere I can find the rest of the stack trace for you? A services.wsdl file is created in my TemperatureWebService project directory, but the file is empty. I'm using: Kubuntu 7.04 (Feisty) Eclipse SDK Version: 3.2.2 Build id: M20070212-1330 (Ubuntu version: 3.2.2-0ubuntu3) Project uses: JRE System Library [java-1.4.2-gcj-4.1-1.4.2.0] JDK Compiler compliance level: 1.4 Axis2 - 1.2 Axis plugins - 1.2 tomcat-4.1.12-LE-jdk14 Any ideas? Thanks. Pete H.
pete hargreaves's picture

RE : Axis2 Code Gen Wizard - InvocationTargetException

Hi Lahiru, I'm still stuck on this one - any ideas please. Pete H.
pete hargreaves's picture

RE : Axis2 Code Gen Wizard - InvocationTargetException

Hi Lahiru,I can't figure out why you're not replying - is there something obvious that I should have spotted - am I not complying with etiquette in some way - or has my post just been overlooked? I look forward to your reply.Thank you, Peter.
sandakith's picture

RE : Axis2 Code Gen Wizard - InvocationTargetException

Hi Peter, Sorry for the delay, Actually I missed the notification of the last email seems it was started again as a new thread.First of all we are not recomending the gcj for any of the Axis2 related projects, because all of them means to be tesed with the Suns JDK and also I have seen reports on Eclipse malfunctioning on the gcj also. Your environment : JRE System Library [java-1.4.2-gcj-4.1-1.4.2.0] JDK Compiler compliance level: 1.4 And also the log is located at <Eclipse_Workspace>/.metadata/.log and if you started the eclipse via command line the log will be dumped if there is if its higher than info/debug rank i.e. error. Please post back to us in any concern, Thanks Lahiru Sandakith   
pete hargreaves's picture

InvocationTargetException

Hi, Now using sun java 1.4 and have found the following message in the log: "Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: Invalid class loader hierarchy. You have more than one version of 'org.apache.commons.logging.Log' visible, which is not allowed. " I notice that both CodeGen and ServiceArchiver plugins include the commons-logging-1.1.jar which could account for the message. One consequence of this duplication is the breaking of my eclipse help system (not previously mentioned). This is apparently a known problem with Ubuntu Linux's Eclipse. With just the CodeGen plugin installed and its logging.jar removed my help system works fine again. The InvocationTargetException remains. Any comments/ideas. Peter.
sandakith's picture

RE: InvocationTargetException

Hi Peter, Please check you system for a global classpath set, As I know the issue is that because of logging impl difference in the system and eclipse plugin environments, Just the first thought, but we never encountered this when using the plugin. Thanks Lahiru Sandakith
sandy's picture

RE: InvocationTargetException

Hi Lahiru, Please help us with the invocation target exception . Was Peter able to fix it ?   Regards, Sandy  
harisdmac's picture

InvocationTargetException

Hi, I managed to resolve the InvocationTargetException problem by replacing the current version of Axis code generator eclipse plugin with a previous one (current is 1.4 and I used 1.2.2 instead). You will have to downgrade your axis2 version to 1.2 in case you are using a later one (e.g. 1.4) as well. Otherwise you will have problems compiling the generated stubs for the client. Make sure that after changing to 1.2 version of axis2 you also change the .jar files at the apache/lib directory and at the project's lib directory also. Hope it helps, Charalampos
dcelery's picture

InvocationTargetException - same problem

Hi, i have installed Eclipse Europa 3.3.0(Axis). I have installed Axis2 1.4 plug-in and then Axis2 1.2 plug-in, but errors persist. HTTP Server: Lotus Domino 7/WSDL 1.1/SOAP 1.1/Axis With Axis, all work fine. But, i can't create client stubs with Axis2!!! Somebody help? Thanks Diego
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
ravindrareddy's picture

RE: InvocationTargetException

Hi Lahiru, Even I am facing the same problem. Please help us reagrding the "invocation target exception". Regards, Ravindra Reddy G.
lfds's picture

PLEASE HELP

hi that was a great tutorial but i'm stuck on the last step of the bottom up approach am getting an error while compiling TemperatureConverterServiceClient.java error is as follows Exception in thread "main" java.lang.Error: Unresolved compilation problems: The method c2FConversion(TemperatureConverterTemperatureConverterSOAP11PortStub.C2FConversion) is undefined for the type TemperatureConverterTemperatureConverterSOAP11PortStub The method f2CConversion(TemperatureConverterTemperatureConverterSOAP11PortStub.F2CConversion) is undefined for the type TemperatureConverterTemperatureConverterSOAP11PortStub at ws.example.TemperatureConverterServiceClient.main(TemperatureConverterServiceClient.java:15) im also posting a screenshot of the dir structure of my project. http://i15.tinypic.com/661kpeh.jpg or [IMG]http://i15.tinypic.com/661kpeh.jpg[/IMG] Note ive used spelling "Conversion" instead of "Convertion". but thats everywhere so i doubt that would be the error Please help asap.. its driving me crazy thanks