Listing 1
package timesheet;
import java.rmi.Remote;
import java.rmi.RemoteException;
public interface TimesheetIF extends Remote
{
public int getHours(int empId) throws RemoteException;
public int getRate(int empId) throws RemoteException;
Listing 2
package timesheet;
public class TimesheetImpl implements TimesheetIF
{
public int getHours(int empId){
if (empId == 1) return 30;
else if (empId == 2) return 40;
else if (empId == 3) return 50;
else return 60;
}
public int getRate(int empId){
if (empId == 1) return 50;
else if (empId == 2) return 60;
else if (empId == 3) return 70;
else return 80;
}
Listing 3 Configuration File Read by the wscompile Tool
<?xml version="1.0" encoding="UTF-8"?>
<configuration xmlns="http://java.sun.com/xml/ns/jax-rpc/ri/config">
<wsdl location="http://localhost:8080/timesheet-jaxrpc/timesheet?WSDL"
packageName="timesheet"/>
</configuration>
Listing 4 Configuration File Read by the wsdeply Tool
<?xml version="1.0" encoding="UTF-8"?>
<webServices xmlns="http://java.sun.com/xml/ns/jax-rpc/ri/dd" version="1.0"
targetNamespaceBase="http://com.test/wsdl" typeNamespaceBase="http://com.test/types"
urlPatternBase="/ws">
<endpoint name="MyTimesheet" displayName="Timesheet Service" description="A
Timesheet web service" interface="timesheet.TimesheetIF"
implementation="timesheet.TimesheetImpl"/>
<endpointMapping endpointName="MyTimesheet" urlPattern="/timesheet"/>
</webServices>
Listing 5: Payroll client using both timesheet and insurance services
...
Stub stub1 = createTimesheetProxy();
TimesheetIF timesheet = (TimesheetIF)stub1;
// create stub for insurance service
Stub stub2 = createInsuranceProxy();
InsuranceIF insurance = (InsuranceIF)stub2;
// claculate payroll
System.out.println("======[LogicalLayer:client]:
Payroll Information ============");
for (empId=1; empId<4; empId++)
{
System.out.println("Salary for emp # " + empId + " for this period is:$" +
((timesheet.getHours(empId) * timesheet.getRate(empId))
- (insurance.getHealthPremium(empId) +
insurance.getLifePremium(empId) +
insurance.getDisabilityPremium(empId))));
}
...