Tutorial: How to create Axis web service with IntelliJ IDEA? Part 2: Client side

In this post we will create client side for service from previous post. It is very easy task because there is Axis plugin for IntelliJ IDEA.

Step 1
Create project (“File”->”New”->”Project…”). Select from list “WebServices client”. As in previous post set Axis library path.

1

Click “Next”, set project name.

Then you will see the dialog window like in the picture below:

1-2

Only thing that we need to do here is to set “Web service wsdl url”. Our url is “http://localhost:8080/services/HelloWorld?wsdl”. You can check this url by internet browser:

1-3

If there is no this page, be sure that project from previous post is running.

Step 2
These directories and files have to be generated:

2

In HelloWorldClient class import HelloWorldServiceLocator class by pressing “Alt”+”Enter”. But we will not use Activator class. Instead rewrite class as in example:

public class HelloWorldClient {
 public static void main(String[] argv) {
  try {
   HelloWorldServiceLocator locator = new HelloWorldServiceLocator();
   HelloWorld_PortType service = locator.getHelloWorld();

   String response = service.sayHelloWorldFrom("Dos");
   System.out.println(response);
  } catch (javax.xml.rpc.ServiceException ex) {
   ex.printStackTrace();
  } catch (java.rmi.RemoteException ex) {
   ex.printStackTrace();
  }
 }
}

You can write anything you want instead of “Dos”.

Step 3

It is time to check our service-client connection. IntelliJ IDEA already prepared to run console application, so our task is to just press “Shift”+”F10”.

If you see in console this message, it means that client and service sent SOAP messages to each other successfully:

3

If you have found a spelling error, please, notify us by selecting that text and pressing Ctrl+Enter.

Profile photo of Doszhan Kalibek

Doszhan Kalibek

  • Teguard

    Any Idea why I could get an Error running Tomcat when trying to Launch the Client, saying Port 1099 is already in use.
    The Service Side is running, so thats not the problem.

    • Hi,
      You don’t need to run Tomcat when you are running client side. Client side is a simple java application. It seems you are trying to run two Tomcats on the same port.