Application Views


Application views provide an abstraction to underlying EIS functions. An application view provides an XML-based interface for interaction with a given EIS. All requests and responses to and from the EIS are expressed in XML. By providing such an abstraction, application views make it easy for an integration developer to define business processes without worrying about the details of the EIS.

There are two modes for interaction with an EIS. One mode is to perform a business operation by sending a request and receiving back information in the form of a responsefor example, requesting all the addresses for customers living in Boulder, Colorado, USA from a CRM system. This can be achieved by defining a service using an application view. This service provides addresses of customers for a given region. The specifics of the region (city, state, country) are included in the request to the service, and the addresses of the customers in the given region are included in the response from the service. The application view therefore acts as a broker and manages the mapping between the service and an EIS system function. Hence, services expose a simple XML-based request/response system with the underlying EIS.

The second mode is that of notification from the EIS. It is analogous to a database trigger. A database trigger can be set or configured on a table such that a certain operation happens when a row is deleted. Similarly, a client can register with an application view for what are called events . An event represents the messages to which an EIS reacts. After a client registers for an event, the application view takes care of sending a notification in the form of XML when that event takes place. This feature is very powerful and can be used in interacting asynchronously with an EIS.

Defining an Application View

An application view is tied to a given EIS. An application console is provided to define connection parameters, names , and security privileges for users of the application view. Consider one of the application views in the platform sample shipped with WebLogic Platform 7.0:

  1. Start the sample by executing %WL_HOME%/weblogic700/samples/platform/e2eDomain/starte2e.bat . This sample uses an application view called E2EAppView.sav .

  2. After the server is up, bring up the Application View console at

       
      http://<hostname>:7501/wlai  
  3. Log in as a System user , using the password security .

  4. Click on E2EAppView and then save. A summary screen lists the events and services configured in this application view, as shown in Figure 35.2.

    Figure 35.2. Application View console.

    graphics/35fig02.jpg

  5. Click on Test next to the checkInventory service.

  6. Test the service by entering pixlens as an SKU. Figure 35.3 shows the response in XML format that will be displayed in the inventory of this product item.

    Figure 35.3. Testing the checkInventory service in the E2EAppView.sav application view.

    graphics/35fig03.gif

This service is used to make synchronous requests to determine whether there is sufficient inventory when a user selects a product from the catalog and places it in the shopping cart.

Using Application Views in Workflows

BPM workflows can access any back-end EIS systems by calling the relevant application view configured using the Application View console. Through WebLogic Integration Studio, while designing workflows, you can use defined services and events of a given application view.

To examine this functionality, look at the end-to-end sample. Start the server by running the <WL_HOME>/weblogic700/samples/platform/e2eDomain/starte2e.bat script. Bring up Studio and connect to the running server. Open the design view for the template called E2E_OrderWorkflow . This workflow is triggered when the XML message containing a customers order is placed on the configured JMS queue. The information from this order is persisted in two tables ( WLI_ORDER and WLI_ORDER_LINE ) using the application integration framework. The E2E_OrderWorkflow , as shown in Figure 35.4, uses two services from the E2EAppView.sav application view: namely, insertOrder and insertOrderLine .

Figure 35.4. E2E_OrderWorkflow .

graphics/35fig04.jpg

Using Application Views Programmatically

Application views can be used programmatically after they are defined, and they can also be deployed programmatically. A rich API is available for using application views programmatically. Consider the code in Listing 35.1, which invokes the checkInventory service defined in the E2EAppView.sav application view (refer to Figure 35.3). This is also available at

 
[View full width]
 %WL_HOME%/weblogic700/samples/platform/e2eDomain/beaApps/e2eApp/src/examples/e2e/common graphics/ccc.gif /inventory/ref/CheckInventoryAction.java 
Listing 35.1 CheckInventoryAction
 ApplicationView appView = new ApplicationView(ctx_, "E2EAppView.sav"); IDocumentDefinition rd = appView.getRequestDocumentDefinition("checkInventory"); IDocument request = rd.createDefaultDocument(); request.setStringInFirst("SKU", sku_); IDocument response = appView.invokeService("checkInventory", request); appView.close() numStr = response.getStringFrom("/Rows/Row/QTY_IN_STOCK"); 

First, an instance of the application view is created using a name that has already been deployed. Then a request document, com.bea.document.Idocument , is obtained using the application views service definition stored at deployment time. This request document can be updated for populating the request attributes ( SKU in this case). Now the service can be invoked and the response obtained. The response is also an IDocument, which is mutable and provides methods for retrieving, adding, modifying, and removing data elements. Listing 35.2 shows how to create an IDocument, and the output is shown in Listing 35.3.

Listing 35.2 Creating an IDocument
 IDocument person = DocumentFactory.createDocument(); person.addElement("", "Person"); person.addAttribute("/Person", "name", "Shirin Devgan"); Element firstChild = person.addElement("/Person", "creditcard"); person.setContextNode(firstChild); person.addAttribute("", "number", "xxxxxxxxxxxx5555"); person.addAttribute("", "type", "visa"); person.addAttribute("", "expiry", "2003-02-22"); person.addAttribute("", "limit", "5000"); person.resetContextNode(); Element secondChild = person.addElement("/Person", " creditcard "); person.setContextNode(secondChild); person.addAttribute("", "number", "xxxxxxxxxxxx3433"); person.addAttribute("", "type", "diners"); person.addAttribute("", "expiry", "2005-11-23"); person.addAttribute("", "limit", "10500"); person.resetContextNode(); 
Listing 35.3 XML Output
 <?xml version="1.0"?> <Person name="Shirin Devgan"> <creditcard expiry="2003-02-22" limit="5000" number="xxxxxxxxxxxx5555" type="visa"/> <creditcard expiry="2005-11-23" limit="10500" number="xxxxxxxxxxxx3433" type="diners"/> </Person> 

All IDocuments can be queried and updated using XPath strings. Listing 35.4 shows some examples for querying an IDocument.

Listing 35.4 Examples for Querying an IDocument
 //retrieve the value of name attribute person.getStringFrom("/Person/@name"); //get the number of creditcard elements person.getIntegerFrom("count(/Person/creditcard)"); //get value of the first creditcard's number person.getStringFrom("/Person/creditcard[1]/@number"); //get the value of the second creditcard's expiry date person.getStringFrom("/Person/creditcard[1]/@expiry"); 

To run the example shown in Listings 35.2 and 35.3, do the following:

  1. Copy chapter35\examples1 to your local drive.

  2. Use cd to change directory to examples1 .

  3. While in the example2 directory, run the setWLSenv.cmd script from <WL_HOME>\weblogic700\server\bin .

  4. Run ant . This will first compile and then run the sample. (Run ant -projecthelp to list all the targets.)

Deploying Application Views

The Application View console can be used to deploy and undeploy an application view. The metadata corresponding to all user-defined application views are placed in a runtime metadata respository. After the application view is deployed, the console can be used to test the services and events.



BEA WebLogic Platform 7
BEA WebLogic Platform 7
ISBN: 0789727129
EAN: 2147483647
Year: 2003
Pages: 360

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net