What you can do when failing to call the Java web service
Posted by Appeon Support on 06 March 2014 04:52 PM
Phenomenon: Run into the error when calling the Java web service.
Solution: Since Appeon only supports the AXIS2-based Java web service, we would recommend you to use it to work around this kind of error. Here are the details about how to call the AXIS2-based Java web service:
1. System Requirements
2. Installing Axis2 As a Standalone Server
Unpack the Axis2 standard binary distribution into a convenient location and add or modify below system environment variable:
A Set an environment variable AXIS2_HOME to the path name of the extracted directory of axis2(Eg: f:\axis2).
B Set an environment variable JAVA_HOME to the path name of JDK directory (Eg: C:\Program Files\Java\jdk1.7.0).
C Set an environment variable CLASSPATH to ‘.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;’
D Modify system environment variable ‘Path’ to add string ‘%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin;’
Then you can start AJXIS server by running %Axis2%\axis2-1.6.2\bin\axis2server.bat
3. Installiing Axis2 service archive wizard eclipse plug-in
Unpack the file and copy the extracted jar file to the plugins folder of your eclipse.
4. Developing axis2 web service
(1) Run the eclipse and select “File”->”New”->”Other…”.
In the pop-up window, select “Web”->”Dynamic Web Project” to create a new Web project.
(2) Click “next” to next step
(3) In “Project Name”, enter a proper name, then click “Next”. In the next window, click “finish” to complete creating project.
(4) In the Web Project, create java classes and related methods according to your requirements. For example, creating a class named “HellWorld” and its method “sayHello(String name)”. The code is shown as below.
5. Packaging the web service
After you finished coding, you need to use “service archive wizard eclipse plug-in” to package the code to an axis2 web service.
(1) select “File”->”New”->”Other…”.
(2) In the pop-up window, select “Axis2 Wizards”->”Axis2 service Archiver”
(3) Click “next” button to the next step. In the “Class File Location” , select the directory where the java class file is produced.(Please note that it is the class file but not java file)
(4) Click “next” button to next window. In the next window, select “skip WSDL” and click “next” button. In “Add any external libraries” window, if you don’t have any libraries need to be added, you can skip this step. In the “Select the Service XML file to be included in the Service archive”, please select “Generate the service xml automatically” and then click “next” button.
(5) In the “Generate the Service XML file” window, please select a proper class and methods and then click “next” button. As show below.
(6) In the “Set the output location and the output file name” window, set the web serice file location and file name, and then click “Finish” button to complete packaging web service file.
6. Deploying Web Service
Copy the packaged file (Eg:MyWebService.aar) to “services” directory located in “repository” directory of Axis2 root folder. It will be deployed automatically. You can verify whether it is deployed successfully by accessing the URL “http://IP:Port/axis2/services/” . The default port of axis2 is 8080.