|
|
The tutorial is written for Eclipse SDK v3.2 and Axis2 Eclipse Plugin v1.3.
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.
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.
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.
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.
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.
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”.
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.
Create a custom package ws.example appropriately and include the TemperatureConverter.java file in that package. Compile and build the project.
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;
}
}

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.
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.

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

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.
After selecting the correct output location, click Next.

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.
Click Next.

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.
For this example, we do not need any external libraries added to the generated service. Therefore, click Next to proceed to the next step.

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.
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.

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.
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.

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.
Click Finish to complete the steps in the wizard.

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.

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

We are going to create the WSDL using the Axis2 Eclipse Codegen Plugin Java2wsdl option.


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.

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.

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.


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:


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.

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.



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.
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).
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.
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/
Lahiru Sandakith P.G. WSO2, Inc. sandakith at wso2 dot com
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
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/
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
i also got the same error
Do you have an updated
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
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.
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/
Preview is good
Preview is good
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
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
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.
Help! Axis2 code generater wizard doesn't completed correctly
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.
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
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.
For help!
Technology News
Technology News
Apache Axis2 tools are really good and the plugins are easy to download.
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.
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
Error
Step 5 of testing the Temperature Converter Service I get this error:
java.lang.reflect.InvocationTargetException. Anyone seen this before?
Thanks,
Veena
Still getting error
I tried out what muhlis suggested below and I still get the error.
Thanks,
Veena
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)
The tool does not show up in eclipse
Now the tool does not show up in eclipse.
Still getting error
I tried out what muhlis suggested below and I still get the error.
Thanks,
Veena
Still getting error
I tried out what muhlis suggested below and I still get the error.
Thanks,
Veena
Still getting error
I tried out what muhlis suggested below and I still get the error.
Thanks,
Veena
Still getting error
I tried out what muhlis suggested below and I still get the error.
Thanks,
Veena
Still getting error
I tried out what muhlis suggested below and I still get the error.
Thanks,
Veena
Still getting error
I tried out what muhlis suggested below and I still get the error.
Thanks,
Veena
Still getting error
I tried out what muhlis suggested below and I still get the error.
Thanks,
Veena
Still getting error
I tried out what muhlis suggested below and I still get the error.
Thanks,
Veena
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
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.
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
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.
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".
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.
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
May I
Hello, I liked your article. It is really informative. The thing is that I am writing an
essay about server developing and I would like to cite you in my paper... can I do it?
Thanks,
Adam
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
Problem using service archiver plugin
eclipse.buildId=I20080617-2000
java.version=1.5.0
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
Command-line arguments: -os win32 -ws win32 -arch x86 -clean
Error
Thu Jan 01 21:47:02 GMT+05:30 2009
Problems occurred when invoking code from plug-in: "org.eclipse.jface".
java.lang.NoClassDefFoundError: org/apache/axiom/om/OMContainer
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:242)
at org.apache.axis2.tool.service.eclipse.ui.ServiceXMLGenerationPage.updateTable(ServiceXMLGenerationPage.java:241)
at org.apache.axis2.tool.service.eclipse.ui.ServiceXMLGenerationPage.createControl(ServiceXMLGenerationPage.java:160)
at org.eclipse.jface.wizard.Wizard.createPageControls(Wizard.java:170)
at org.eclipse.jface.wizard.WizardDialog.createPageControls(WizardDialog.java:669)
at org.eclipse.jface.wizard.WizardDialog.setWizard(WizardDialog.java:1083)
at org.eclipse.jface.wizard.WizardDialog.updateForPage(WizardDialog.java:1142)
at org.eclipse.jface.wizard.WizardDialog.access$2(WizardDialog.java:1139)
at org.eclipse.jface.wizard.WizardDialog$4.run(WizardDialog.java:1128)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at org.eclipse.jface.wizard.WizardDialog.showPage(WizardDialog.java:1126)
at org.eclipse.ui.internal.dialogs.NewWizardSelectionPage.advanceToNextPageOrFinish(NewWizardSelectionPage.java:71)
at org.eclipse.ui.internal.dialogs.NewWizardNewPage$1.doubleClick(NewWizardNewPage.java:355)
at org.eclipse.jface.viewers.StructuredViewer$1.run(StructuredViewer.java:799)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
at org.eclipse.core.runtime.Platform.run(Platform.java:880)
at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:48)
at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175)
at org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick(StructuredViewer.java:797)
at org.eclipse.jface.viewers.AbstractTreeViewer.handleDoubleSelect(AbstractTreeViewer.java:1419)
at org.eclipse.jface.viewers.StructuredViewer$4.widgetDefaultSelected(StructuredViewer.java:1173)
at org.eclipse.jface.util.OpenStrategy.fireDefaultSelectionEvent(OpenStrategy.java:237)
at org.eclipse.jface.util.OpenStrategy.access$0(OpenStrategy.java:234)
at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java:295)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3823)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3422)
at org.eclipse.jface.window.Window.runEventLoop(Window.java:825)
at org.eclipse.jface.window.Window.open(Window.java:801)
at org.eclipse.ui.internal.handlers.WizardHandler$New.executeHandler(WizardHandler.java:253)
at org.eclipse.ui.internal.handlers.WizardHandler.execute(WizardHandler.java:273)
at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:281)
at org.eclipse.core.commands.Command.executeWithChecks(Command.java:476)
at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508)
at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:169)
at org.eclipse.ui.internal.handlers.SlaveHandlerService.executeCommand(SlaveHandlerService.java:247)
at org.eclipse.ui.internal.actions.CommandAction.runWithEvent(CommandAction.java:157)
at org.eclipse.ui.internal.actions.CommandAction.run(CommandAction.java:171)
at org.eclipse.ui.actions.NewWizardDropDownAction.run(NewWizardDropDownAction.java:174)
at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:583)
at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:500)
at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:452)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3823)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3422)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2382)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2346)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2198)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:488)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:193)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:382)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:549)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
Derived classes
Hi Lahiru,
went through the tutorial with some difficulties
- missing jars in the code generator (solution from http://blogiterox.wordpress.com/author/erictamminga/)
- and missing axis2 jars when using "Add Axis2 codgen jars" option only (have to use "Add Axis2 libraries" as well)
But then every thing went smooth - thanks a lot!!!
Now I'm facing some new problems with my own project, see the attached wsdl file. This is a condensed version of a file I've got from a company, where the service runs already.
Here Classes are used as parameters. Intended is to include a mother class (Event) in the definition, but transport derived classes in the stream. This seams not to work, as the derived class (EvtCommInfo) is not included. Mother classes on the other side are included (SoapBase).
Is this a general problem of Axis2?
Or a problem of the of the code generator?
Do you have any proposals what to do?
Thanks in advance
br
heino
InvocationTargetException
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
org/apache/woden/resolver/URIResolver class not found
Hi,
First of all, a great job on the tutorial. Keep up the nice efforts.
I followed the tutorial, ran into the Invocation exception and found a way around it by following the comments carefully.
My problem is this. When I try to execute the client, I get an exception that reads...
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.example.TemperatureConverterStub.(TemperatureConverterStub.java:103)
at ws.example.TemperatureConverterStub.(TemperatureConverterStub.java:89)
at ws.example.TemperatureConverterStub.(TemperatureConverterStub.java:140)
at ws.example.TemperatureConverterServiceClient.main(TemperatureConverterServiceClient.java:8)
I tried to use findjar.com to find this class, to no avail. I am trying to resolve the issue. In the meanwhile, any help with this will be appreciated.
Thanks.
Regards,
Sanket Daru.
Resolved: org/apache/woden/resolver/URIResolver class not found
Hi,
Just resolved the issue. Here is what I did...
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.
Hope this helps someone. Once again, great job on the tutorial. It helped me a lot. :-)
Cheers!!!
Regards,
Sanket Daru.
log4j Warning
Thanks a lot for your solution, I face the same error and I get the right result after adding the woden-api-1.0MB.jar into the project's build path, and this jar is also contained in Axis-1.4.1/lib
But there is still a warning says:
log4j:WARN No appenders could be found for logger (org.apache.axis2.description.AxisService).
log4j:WARN Please initialize the log4j system properly.
Do you konw the reason for this warning?How to solve it?
Thanks,
Regards,
fenfen
log4j Waring--Solution
missing jar: log4j.properties.patch.jar
see
https://issues.apache.org/jira/browse/AXIS2-3093?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
I add this jar file to the build path, and the warning is disappeared
hooooo
fenfen
facing problem
hi,
Actually at the time of creating WSDL from java source file i am able to complete all the steps but at the time of clicking "finish" button it's saying
"java.lang.reflect InvocationTarget exception"
Plesae help me if u can solve it.
How to resolve java.lang.reflect.InvocationTargetException
Hello Sir,
This site was really helpful to me in getting started with webservices.
My Question is when i create wsdl from tha java class i get java.lang.reflect.InvocationTargetException
Please let me know the Resolution I am using axis1-4
Do i need to Import any specified Jars is so please let me know the Possiblity asap.
Thanks
Kiran