JAX-RPC 1.6 Web Service Client

Author: Jaroslav Pospisil
Version: 1.7
Estimated time: 3 hours
Last update: 22.10.2008
Introduction:

This test specification should test Web service client creation in J2SE and J2EE project. The specification covers developing of simple web service client in NetBeans 6.5 .


Comment:

This test specification is based on End - to - end scenarios, written by Lukas Jungmann.




Table of Contents






Before you start:


If you use Java or Full version of Netbeans installer, you should have Glassfish v2 already installed (it's default option). Otherwise you have to install Glassfish v2 manually.You can download Glassfish v2 here Finally add server in Runtime tab.
From Netbeans 6.0 is JAX-RPC support available only from update center,so before you start testing,go to Tools|Plugins|Available plugins, select JAX-RPC Web Services and click Install.Click Next,accept license agreement and click Finish.

Test suite 1: Web Service Client in J2SE project

Purpose: Functionality of J2SE WS Client.
Setup: Open File|New Project|Java Web|Web Application and write WSWebApp into Project Name field. Set JavaEE Version to J2EE1.4. Uncheck Set Source Level to 1.4. Click Finish
Create new Web Service of name MyWS. Open File|Web Services|Web Service and write MyWS into Web Service Name field and test into Package field.
In editor window will open Web Service implementation class.Go to Projects|WSWebApp|Web Services|MyWSService, right-click on it,and select Add Operation.Left everything default and clickOK
Right-click on WSWebApp in Projects tab and select Undeploy and Deployfrom context menu. Web service is now deployed and available. Create new Java Application - go to File|New Project|General|Java Application.
Specify Hello as Project Name.
Click Finish.

#Test caseDescription
1Create web service client
1. Go to File|New File|Web services|Web Service Client|Next.
2. Specify WSDL - there are three ways how to do it and we must check all.
Click on Browse button and select MyWS.
Invoke WS Client wizard again and now select WSDL URL choice. Enter http://www.waterware.com/projects/samples/RouteMaster/wsdl/ into textfield.
In third case download this wsdl file and use it for choice Local File.
3. Optional: if you're behind proxy check its settings via Proxy settings... button.
4. Change Client style to JAX-RPC.
5. Enter package name rpcclient.
6. Click Finish.
RESULT: In Projects tab|Hello is Web Service References node added.Open it and there should be MyWSService node.
2Refresh Client
1. Go to Projects tab|Hello|Web Service References|MyWSService.
2. Right-click on web service and then select Refresh Client
3. In next window enter http://localhost:8080/WSWebApp/MyWSService?wsdl and clickOK
RESULT: WSDL of web service in client will be updated .
3Call web service operation in Main class
1. Go to editor Main.java and click before // TODO code application logic here.
2. Right-click to invoke context menu and select Web Service Client Resources and Call Web Service Operation. 3. In next window select operation (click through nodes) and click OK.
RESULT: Added code:
try { // This code block invokes the MyWSSEIPort:operation operation on web service
rpcclient.MyWS myWS = new rpcclient.MyWS_Impl();
rpcclient.MyWSSEI myWSSEIPort = myWS.getMyWSSEIPort();
myWSSEIPort.operation(/* TODO enter operation arguments*/);
} catch(javax.xml.rpc.ServiceException ex) {
java.util.logging.Logger.getLogger(rpcclient.MyWS.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch(java.rmi.RemoteException ex) {
java.util.logging.Logger.getLogger(rpcclient.MyWS.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch(Exception ex) {
java.util.logging.Logger.getLogger(rpcclient.MyWS.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
4Call web service operation in java class
1. Create new Java class test.java, go to editor and add this code:
public void testmethod() {
}
2. Click behind public void testmethod() {.
2. Right-click to invoke context menu and select Web Service Client Resources and Call Web Service Operation. 3. In next window select operation (click through nodes) and click OK.
RESULT: Added code:
try { // This code block invokes the MyWSSEIPort:operation operation on web service
rpcclient.MyWS myWS = new rpcclient.MyWS_Impl();
rpcclient.MyWSSEI myWSSEIPort = myWS.getMyWSSEIPort();
myWSSEIPort.operation(/* TODO enter operation arguments*/);
} catch(javax.xml.rpc.ServiceException ex) {
java.util.logging.Logger.getLogger(rpcclient.MyWS.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch(java.rmi.RemoteException ex) {
java.util.logging.Logger.getLogger(rpcclient.MyWS.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch(Exception ex) {
java.util.logging.Logger.getLogger(rpcclient.MyWS.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
5Test operation
1. Go to Projects tab and open Projects tab|Hello|Web Service References|MyWSService|MyWSServiceSEIPort|operation
2. Right click and select Test Operation.
3. Click on Submit.
RESULT: Under Results should appear line containing String type and empty Value.
6Delete web service client
1. Projects tab|Hello|Web Service References|MyWSService node.
2. Right-click on web service and then select "Delete" and "Yes" in next window.
RESULT: Web service (and Web Service references node,if the service was last one) should disappear from Projects tab .
Teardown:




Test suite 2: Web Service Client in J2EE module

Purpose: Functionality of J2EE WS Client.
Setup: Open File|New Project|Java Web|Web Application and write WSWebApp into Project Name field. Set JavaEE Version to J2EE1.4. Uncheck Set Source Level to 1.4. Click Finish
Create new Web Service of name MyWS. Open File|Web Services|Web Service and write MyWS into Web Service Name field and test into Package field.
In editor window will open Web Service implementation class.Go to Projects|WSWebApp|Web Services|MyWSService, right-click on it,and select Add Operation.
Right-click on WSWebApp in Projects tab and select Undeploy and Deployfrom context menu. Web service is now deployed and available. Create new Web Application - go to File|New Project|Web|Web Application.
Specify WSClientWebApp as Project Name.
Click Finish.
Repeat the same, only this time leave J2EE version set to default JavaEE5 value.
Create new Application Client- go to File|New Project|Enterprise|Application Client.
Specify WSClientAppC as Project Name.
Click Finish. Web service client could be created in all these three J2EE modules, so test next test cases for each of them.

#Test caseDescription
1Create web service client
1. Go to File|New File|Web services|Web Service Client|Next.
2. Specify WSDL - there are three ways how to do it and we must check all.
Click on Browse button and select MyWS.
Invoke WS Client wizard again and now select WSDL URL choice. Enter http://www.waterware.com/projects/samples/RouteMaster/wsdl/ into textfield.
In third case download this wsdl file and use it for choice Local File.
3. Optional: if you're behind proxy check its settings via Proxy settings... button.
4. Change Client style to JAX-RPC.
5. Specify package for the client, eg. rpcclient.
6. Click Finish.
RESULT: In Projects tab|Hello open Web Service References node.Click on it and there should be reference to MyWS web service. .
2Refresh Client
1. Go to Projects tab|Hello|Web Service References|MyWSService.
2. Right-click on web service and then select Refresh Client
3. In next window enter http://localhost:8080/WSWebApp/MyWSService?wsdl and clickOK
RESULT: WSDL of web service in client will be updated .
3Call web service operation in Appclient's Main class
1. Go to editor Main.java and click before // TODO code application logic here.
2. Right-click to invoke context menu and select Web Service Client Resources and Call Web Service Operation. 3. In next window select operation (click through nodes) and click OK.
RESULT: Added code:
try { // This code block invokes the MyWSSEIPort:operation operation on web service rpcclient.MyWS myWS = new rpcclient.MyWS_Impl(); rpcclient.MyWSSEI myWSSEIPort = myWS.getMyWSSEIPort(); myWSSEIPort.operation(/* TODO enter operation arguments*/); } catch(javax.xml.rpc.ServiceException ex) { java.util.logging.Logger.getLogger(rpcclient.MyWS.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch(java.rmi.RemoteException ex) { java.util.logging.Logger.getLogger(rpcclient.MyWS.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch(Exception ex) { java.util.logging.Logger.getLogger(rpcclient.MyWS.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); }
4Call web service operation in Appclient's java class
1. Create new Java class test.java, go to editor and add this code:
public void testmethod() {
}
2. Click behind public void testmethod() {.
2. Right-click to invoke context menu and select Web Service Client Resources and Call Web Service Operation. 3. In next window select operation (click through nodes) and click OK.
RESULT: Added code:
try { // This code block invokes the MyWSSEIPort:operation operation on web service
rpcclient.MyWS myWS = new rpcclient.MyWS_Impl();
rpcclient.MyWSSEI myWSSEIPort = myWS.getMyWSSEIPort();
myWSSEIPort.operation(/* TODO enter operation arguments*/);
} catch(javax.xml.rpc.ServiceException ex) {
java.util.logging.Logger.getLogger(rpcclient.MyWS.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch(java.rmi.RemoteException ex) {
java.util.logging.Logger.getLogger(rpcclient.MyWS.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch(Exception ex) {
java.util.logging.Logger.getLogger(rpcclient.MyWS.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
5Call web service operation in servlet
1. Create new servlet testServlet.java in WSWebApp, go to editor and delete this code:
/* TODO output your page here
*/
2. Click behind out.println("

Project Features

About this Project

QA was started in November 2009, is owned by Jiří Kovalský, and has 97 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20160708.bf2ac18). © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close