Search code examples
javaeclipseapache-axis

Issue generating first web service client using eclipse and axis 2


I followed every step of this tutorial precisely (except for skipping step 4 because I only want to get this working in eclipse for now).

I was careful to use the exact versions of each piece of software (eclipse helios, axis 2 1.5.2 etc). I am running this on mac os x 10.7.5 and now on windows like in the tutorial.

Anyway, everything goes well until step 5 when I go to create the test client. I am able to get thru the wizard to create the client--but only if I point it to this URL:

localhost:8080/MyFirstWebService/services/FirstWebSertice?wsdl

instead of this one in the tutorial

http://localhost:8080/axis2/services/FirstWebService?wsdl

Afterwards, it does not generate two classes called FirstWebServiceStub.java and FirstWebServiceCallbackHandler.java --but instead generates a few classes shown in the picture below.

Is this a major discrepancy? Have I done something wrong? How should I translate this code from the tutorial to get it working with the classes that were generated?

package com.sencide;

import java.rmi.RemoteException;
import com.sencide.FirstWebServiceStub.AddTwoNumbers;
import com.sencide.FirstWebServiceStub.AddTwoNumbersResponse;

public class TestClient {

 public static void main(String[] args) throws RemoteException {

  FirstWebServiceStub stub = new FirstWebServiceStub();
  AddTwoNumbers atn = new AddTwoNumbers();
  atn.setFirstNumber(5);
  atn.setSecondNumber(7);
  AddTwoNumbersResponse res = stub.addTwoNumbers(atn);
  System.out.println(res.get_return());

 }
}

enter image description here


Solution

  • The URL http://localhost:8080/axis2/services/FirstWebService?wsdl would be handled by the service installed in step 4 of the tutorial. Since you skipped that step, the URL won't work.

    Under normal tomcat behavior, "/axis2" part of the URL references a particular web application (WAR file) deployed within tomcat. In this case, from tomcat's perspective the web application is axis2.war.

    The "services/FirstWebSertice" part of the URL references a particular Axis2 service (AAR file) running within the Axis2 environment.

    As @andreas-veithen noted, it looks like the boilerplate java classes in your project explorer image were generated by Axis rather than Axis2. Axis and Axis2 are really two different web service libraries; one is not just a later version of the other. It seems that you somehow used the wrong code generator to generate those classes.