In this step, you will enhance the logic of the LoanApproval control to access the CreditScore web service. The existing logic of the LoanApproval control is:
If a loan exists for this SSN then turn down the application (return false to caller) otherwise accept the application (return true to the caller).
We are going to expand that logic to:
If the person with this ssn already has a loan then turn down their application (return false) otherwise check the credit score. If the credit score is < 700, turn down the application (return false). If the credit score is 700 or higher, accept the application (return true).
To access the external web service, we will create a new web service control ("service control") to access the CreditScore web service. We will then modify the LoanApproval control to use the new web service control.
To create a new control we will first generate a WSDL file from a web service and then generate a service control from the WSDL.
Right click on the editor window and choose Insert > Control. Choose the new CreditScoreServiceControl and click OK.
Code will appear that declares and instantiates the control
@Control private CreditScoreServiceControl creditScoreServiceControl;
public boolean getLoanApproval(int ssn, float amount) throws SQLException { init(); // if they are already borrowing, don't allow another loan if (loansDB.getLoanValue(ssn) > 0) return false; if(creditScoreServiceControl.getCreditScore(ssn) < 700) return false; // otherwise, allow the loan. loansDB.insertLoan(ssn, amount); return true; }
Save your changes with File > Save.