In this task you will add an Enterprise Java Bean control to the Investigate Java control. This control provides accesses to an EJB (already deployed on the server as part of the Workshop samples domain) that calculates an approval rating on credit applicants. The tasks in this step are:
The ValidateCredit EJB you will be accessing is designed to take the credit score and return a response about the applicant's credit worthiness. To access the ValidateCredit bean, you will add an EJB control.
Note: In order for you to add an EJB control to a web service project, the compiled home and remote interfaces for the EJB must be in the project also. The JAR file containing the home and remote interfaces is already within the Libraries folder of the application.
WebLogic Workshop adds an EJB control to your design, as shown below. The control shows that the EJB exposes two methods: create and validate. The validate method is the one you will use (all EJBs expose a create method that is used by WebLogic Server; you will not need to call this).
Now you need to connect the score received through the creditScore JMS control to the validateCredit EJB control. You will do this by updating the JMS control's callback handler. The code you add will send the credit score to the EJB for validation.
public void creditScoreJMS_receiveTextMessage(java.lang.String payload) { try { /* * Extract the the credit score from the JMS response string * and store it in m_currentApplicant. */ ScoreResponseDocument scoreInfo = ScoreResponseDocument.Factory.parse(payload); m_currentApplicant.creditScore = scoreInfo.getScoreResponse().getCalculatedScore();/* * Send the complete report back to the client. */ // callback.onCreditReportDone(m_currentApplicant);} catch(XmlException e) { m_currentApplicant.message = "There was a problem retrieving the credit score. Please call (555) 555-5555."; /* * Send the the error message back to the client. */ callback.onCreditReportDone(m_currentApplicant); } try { /* * Pass the credit score to the EJB's validate method. Store the value returned * with other applicant data. */ m_currentApplicant.approvalLevel = validateCreditEJB.validate(m_currentApplicant.creditScore); /* * Send the complete report back to the client. */ callback.onCreditReportDone(m_currentApplicant); } catch(java.rmi.RemoteException e) { m_currentApplicant.message = "There was a problem retrieving the approval level. Please call (555) 555-5555."; /* * Send an error message back to the client. */ callback.onCreditReportDone(m_currentApplicant); } }
Note: Use one of the following (9 digit) taxID's to test your Java control throughout the tutorial:
Notice the new element in the applicant profile <approvalLevel>Applicant is a low risk.</approvalLevel>. This element was provided by the EJB credit validating application.
Click one of the following arrows to navigate through the tutorial: