My last post say how to deploy the web service,
So this post will be on create a client to make use of the web service's add method. Here, client will be a Java class in a Java SE application.

1.Choose File > New Project (Ctrl-Shift-N). Select Java Application from the Java category. Name the project MyWSClient_Application.(default settings then Click Finish)

image[8]

image

2.Right-click the CalculatorWS_Client_Application node and choose New > Web Service Client.(default and click Finish)

image

image

3.The Projects window displays you can find node for the add method that you created last time.

image

4.Now open Main.java and then drag the add node above into the ‘// TODO code application logic here’ line. You now see the following:

 

    public static void main(String[] args) {
       
try { // Call Web Service Operation
   org.me.calculator.CalculatorWSService service = new org.me.calculator.CalculatorWSService();
   org.me.calculator.CalculatorWS port = service.getCalculatorWSPort();

    //change value of int
    int a = 10;
    int b = 3;
   // TODO process result here
   int result = port.add(a, b);
   System.out.println("Result = "+result);
} catch (Exception ex) {
   // TODO handle custom exceptions here
}
// TODO code application logic here
   

run and see

Result = 13

you just consume the web service that you created in last post.

1

View comments

I am
I am
Archives
Total Pageviews
Total Pageviews
2 0 5 7 7 0 6
Categories
Categories
Loading