Introduction
In the previous article, we introduced the basic concepts and working principles of WBSF Dynamic invocation of business services. WBSF enables us to dynamically invoke business services based on service policies in SOA development. WBSF V6.02 provides an SCA programming model that makes development business services more flexible and convenient. Through a concrete example, this paper describes how to dynamically invoke business services through the WBSF V6.02 SCA programming model. We will formulate service policies based on context attributes, set up assertions based on service content in the Responselistener extension, and extend the context attributes in the update transaction through Contextextractor;
Business Scenarios and Modeling
Business Scenario:
Consider one of the following business scenarios for bank account balance queries: Users submit user names and account names to the account query system, the system first obtains the user Service level through the authorization service, then calls the Account Inquiry service, returns the account balance information to the customer. For the query through the portal channel, the authorized service adopts the HTTP Basic authentication method; For queries through the WebService channel, the authorized service uses the HTTPS client authentication method. For users of different service levels, query services with different processing capabilities will be used.
Business Modeling:
Business process:
Accountqueryprocess: Enter the username and user account. Call Authorizationservice first to obtain the user Service level, and then call the Accountqueryservice query account balance as a return.
Web Services:
Authorizationservice: Enter user name, return user Service level
Accountqueryservice: Enter as account name, return account balance
Preparing a Web Service
To create a accountquerymodule project in WID
Open WID, switch to business integration perspective, and create a new module as shown in Figure 1.
Figure 1 Creating a Accountquerymodule Project
Create Authorization Service:
Create a new Authorizaitonservice interface in Accountquerymodule, which includes the Getservicelevel method, as shown in Figure 2:
Figure 2 Creating the Authorizationservice interface
Open the Accountquerymodule Assembly Diagram and add the AUTHORIZATIONSERVICE_HTTPBA component, which simulates the authorization service using the HTTP Basic authentication method. Add the Authorizaitonservice interface to the component, as shown in Figure 3. Double-click the component to implement the type select Java. The main implementation code is shown in Example 1.
Example 1 AUTHORIZATIONSERVICE_HTTPBA Component implementation
public class AuthorizationService_HTTPBAImpl {
public String getServiceLevel(String userId) {
return "SILVER";
}
}
Figure 3 Adding the Authorizationservice interface to the component