Create Simple Web Service JAX-WS – Client Part – RAD IBM – Websphere 7.0 + java 6

Create Simple Web Service JAX-WS – Client Part – RAD IBM – Websphere 7.0 + java 6

1.) After you done doing my example on JAX-WS Server Part 1, you can create new Dynamic web project “jaxwsClientFirst” – for client part.

1.1.) Create package, com.fndong.client, then right click New > others > Web Service > Web Service Client

9ws1.png

1.2.) Create package, com.fndong.client, then right click New > others > Web Service > Web Service Client.

10ws1.png

Click on Browse Button of Service Definition and select the WSDL file of jaxwsServerFirst , Press Ok. Then set the target Location “com.fndong.client” > Next > Finish.

1.3.) Then it will generated java class automatically :

11ws1.png

1.4.) Open class SalaryImplService.java , inside the codes, change the URL to  :

url = com.fndong.client.SalaryImplService.class.getResource(“/WEB-INF/wsdl/SalaryImplService.wsdl”);

to

url = com.fndong.client.SalaryImplService.class.getResource(“http://localhost:9080/jaxwsServerFirst/SalaryImplService/SalaryImplService.wsdl”);

1.5.) This client jax-ws used WebSphere thin client jar for WebService Client. Right Click on jaxwsClientFirst  >BuildPath > Configure Build Path,Under Libraries Tab ->

12ws1.png

Click on WebSphere Application Server v7.0. Click On Remove, and Press OK.

1.6.) Then add thin client jar , Right Click again on jaxwsClientFirst  >BuildPath > Configure Build Path,Under Libraries Tab ->  Add External JARs > add three jars below.

  • com.ibm.jaxws.thinclient_7.0.0.jar
  • com.ibm.ws.admin.client_7.0.0.jar
  • com.ibm.ws.webservices.thinclient_7.0.0.jar

– click OK Button.

1.7.) Create a client program that invokes the server jaxwsServerFirst, by Creating new Client java class in the package com.fndong.client – “CalculateClient.java“.

 package com.fndong.client;

/**
 * @author fndong
 *
 */
public class CalculateClient {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
         SalaryImplService service = new  SalaryImplService();
         SalaryService salaryService = service.getSalaryImplPort();
         double var1 = 2000;
         double var2 = 5000;
         double mysalary = salaryService.calculateSalaryAllowance(var1, var2);
         System.out.println("my salary : " + mysalary);       
    }

}

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s