WS Client deployment with Eclipse WTP

In this tutorial we will see how Eclipse generate the Client stub.

  1. We start with the HelloWorld service created in the previous lab.
  2. File → New → Dynamic Web Project. Name it as HelloWorldClient. Select web service module version as 2.5. Select modify in configuration tab and add Axis2 web services.
  3. Click on the HelloWorldClient project, select File → New → Other → Web Service → Web Service Client.
  4. Click Next.
  5. Select Browse and enter the following wsdl URI http://localhost:8080/WS_HelloWorld/services/HelloWorld?wsdl.
  6. In the Configuration part, click on Web service runtime: Apache Axis and select Apache axis2.


  7. Click OK. Then Next → Finish.
  8. Inside the HelloWorldClient → Java Resource → src → tps.ws.deployment package, create a new Class named TestClient and select the option public static void main.
  9. WARNING: We need to move the generated stud and handler java files to the right fold in src and change to JAVA 8 version
  10. Copy and paste the following code:
    package tps.ws.deployment;
     
    import java.rmi.RemoteException;
    import tps.ws.deployment.HelloWorldStub.SayHello;
     
    public class TestClient {
     
    	/**
    	 * @param args
    	 * @throws RemoteException 
    	 */
    	public static void main(String[] args) throws RemoteException {
    		// TODO Auto-generated method stub
    		HelloWorldStub hwp = new HelloWorldStub();
    		SayHello s = new SayHello();
    		s.setInput("from client");
    		System.out.print(hwp.sayHello(s).get_return());
    	}
    }
  11. Right click on the TestClient class, select Run As → Java Application, if you get “Hello from client” in the console, you are successful.

Exercise

  1. Create and publish a service named “Square” to compute the square of an integer.
  2. Create a service named “Computation” call the “Square” service to compute the equation: a^2 + b^2.
teaching_assistant/web_services/webservice_client_generation_v9.txt · Last modified: 2023/09/06 09:59 by IT Courses (NNC)
Back to top
CC Attribution-Share Alike 4.0 International
chimeric.de = chi`s home Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0