Oct 18, 2012

Getting Started - XQuery Dev inside OSB Eclipse

       We can use XQuery/XSL in OSB to do the message transformation. But XQuery is preferred over the XSL because of the  performance advantage. In this post I will show how to develop an xquery using the osb workshop eclipse.

XQuery - Introduction
       XQuery is a light weight language which has got an xml like syntax. XQuery has 3 important parts as below
  1. Namespace declaration
  2. Set of function with their implementations
  3. Declaration of variables
  4. Mentioning the function with which the execution begins.
          For further understanding of the XQuery you can refer
http://www.w3schools.com/xquery/xquery_intro.asp


Sample XQuery

Listing-1    xquery version "1.0" encoding "Cp1252";
Listing-2    (:: pragma  parameter="$anyType1" type="xs:anyType" ::)
Listing-3    (:: pragma  type="xs:anyType" ::)
Listing-4    declare namespace xf = "http://tempuri.org/OSB%20Project%203/sample/";
Listing-5    declare namespace ns1 = "http://tempuri.org/OSB%20Project%203/sample/inputaddress";
Listing-6    declare namespace ns2 = "http://tempuri.org/OSB%20Project%203/sample/outputaddress";
Listing-7
Listing-8    declare function xf:sample($requestDoc as element(*))
Listing-9                    as element(*)
Listing-10    {
Listing-11                
Listing-12                 
Listing-13                  {
Listing-14                  $requestDoc/ns1:FirstName/text()
Listing-15                  }
Listing-16                 

Listing-17                 
Listing-18                  {
Listing-19                  $requestDoc/ns1:PhoneNumber/text()
Listing-20                  }
Listing-21                 

Listing-22                

Listing-23    };
Listing-24
Listing-25    declare variable $requestDoc as element(*) external;
Listing-26
Listing-27    xf:sample($requestDoc)

Explanation
Listing 1 - declaration of xquery
Listing 2 to 3 - comments
Listing 4 to 6 - Namespace declarations
Listing 8 to 9
     This is the code snippet for the function 'sample' which takes 'requestDoc' which is of type element(*),             that is the xml. It returns the type element(*) which is also an xml.

Listing 10 - shows the start of the xquery function
Listing 23 - shows the end of the xquery function
Listing 11 to 22 - the body of the function 'sample'
 Here we are doing the transformation.  What ever we write it in these lines will be the final output of the 
 xquery tranformation
Listing 14 or 19 - Here we are assigning the data obtained from request xml to the output response xml.

Listing 25 - declaring the request variable 'requestDoc' as 'external' as type 'element(*)'. So when we test this xquery from the OSB flow, we will bind the request xml with 'requestDoc' variable and we can transform the request xml to the response xml. 

Listing 27 - This is the last line of the xquery where the execution of the xquery begins. Suppose if we have multiple functions, what ever function is given in the last line of xquery will be the entry point of execution.

Development of XQuery in OSB Workshop - Eclipse
          Open the eclipse and create a project . Right click on the project and create a new xquery


Give some name



Now give the request binding variables.
Here I have added only one variable.
Give the 'Parameter Name' as 'requestDoc'  and click on 'Add' so that we can add the request binding variable.



Similarly mention the response also



Now we have created the xquery. It will be now opened in the osb eclipse editor. The editor has 3 parts.
  1. Design
  2. Source
  3. Test
We can use 'Design' part if we have the source and destination schemas.


Now click on 'Source' and you can see the xquery source code.



Now modify the xquery as below

xquery version "1.0" encoding "Cp1252";
(:: pragma  parameter="$anyType1" type="xs:anyType" ::)
(:: pragma  type="xs:anyType" ::)
declare namespace xf = "http://tempuri.org/OSB%20Project%203/sample/";
declare namespace ns1 = "http://tempuri.org/OSB%20Project%203/sample/inputaddress";
declare namespace ns2 = "http://tempuri.org/OSB%20Project%203/sample/outputaddress";
declare function xf:sample($requestDoc as element(*))
    as element(*)
     {
       
         
          {
          $requestDoc/ns1:FirstName/text()
          }
         

         
          {
          $requestDoc/ns1:PhoneNumber/text()
          }
         
       
};
declare variable $requestDoc as element(*) external;
xf:sample($requestDoc)


Sample request xml for Testing


 Sarat

9985663814

Testing the application


Now Click on the 'Test' tab inside the xquery editor for testing





Now we have successfully created an xquery and tested it. 



 Testing the XQuery inside OSB Message Flow

      Create a new sample osb project. If you are a beginner you can refer the below post

 In the request flow drag one 'replace' node 

     Click on 'XPath' and enter the value as '*'

     In Variable : body
     Now click on 'Expresssion' and click on 'XQuery Resource' and browse to the sample xquery
     and enter $body/* into the 'requestDoc'.


Now you  can deploy the application and test it.



Conclusion
   This topic is intended to give an introduction to Xquery development and using the same inside the osb message flow. You can better explore more.

Oracle Service Bus (OSB) Performance Tuning tips

          Once you are comfortable with developing and deploying applications in OSB, the next thing that comes for you will be how fast you can run your applications and what are the standard procedures that need to be followed up in order to achieve that. 


          Based on my experience, I have come up with few points which will help you fine tune your applications and get good response times. The fine tuning of any application should start from the design phase. The design can be high level design, deployment design, low level design and finally the standard way of implementing these things.

High level design
  One should follow the most suitable and efficient design pattern in-order to achieve good result. Considering different solutions for the same problem will be handy.

Deployment design & Server Configuration
  OSB applications runs on Weblogic Server, a J2EE application server. So you should be very careful while selecting the JVM parameters like heap memory, gc algorithm, nursery size and other Java options. 
  Deep level analysis need to be done in order to understand whether the application that you are building is CPU intensive or memory intensive.

Low level design
  This is nothing but the proper work flow pattern design. You should analyse which work flow pattern will be more efficient in terms of number of threads it creates, the memory utilization and CPU utilization. Also how much of static data need to be handled and how it should be cached and so on.

Best practices for developing highly efficient OSB applications.

1. Cache the static data that need to be configured in your application. You need to consider the below points
    a. how much of data need to be cached
    b. Which caching api to use.
    
         There are two popular caching api's available - Java Caching System (JCS) and Oracle Coherence caching which Oracle recommends.

 Java Caching System (JCS)

       This is a simple caching scheme where the static data will be cached per server. This can be easily integrated to OSB application and the complexity is very less. But this is not suitable for caching very large amount of data. The caching mechanism may fail under heavy load and the cached data over 50 rows from a table.

Oracle Coherence Caching
       This is the Oracle recommended caching mechanism. We need to configure the coherence cluster in the Weblogic server level in order to use this. This is very robust and stable cache mechanism which can handle heavy load and large amount of data. The cached data will be available through out the cluster. There are different methods available for clearing the Coherence cache.

2. Disable all tracing
    For high end performance , you need to disable all kinds of tracing. This can be easily done in sbconsole.
  sbconsole -> smart search
  If you are using coherence caching, make sure that you enable caching for the business   service used for that.

3. Datasources
   If you are using datasouce for select or query operations, then use non-XA driver. 

4.  XQuery tuning

  a. Avoid using '//' anywhere in the xquery
  b. use indexes for faster xquery parsing.
  c. Use FLOWR expressions instead of 'if' conditions for checking the existence of any tag.
  d. If you want to use any intermediate xpath continuously , then assign that to a variable         
      and use it rather than querying it multiple times.
  e. Using indexes for xqueries, if you are not sure that it will return multiple rows
  f. If you use multiple 'let' statements, group it under one 'let'
  g. Avoid declaring the namespaces above xquery, it will lead to different namespace
     prefixes during runtime. Instead put it inline with xquery xml tags.
  h. Avoid using of '*' to the maximum extend
  i. Split large sized dbquery xmls to multiple parts so that xquery parsing will be easy.
        Design the dbentries in such a way that you would be easily able to split with  
        respect to some parameters.
  j. Reduce the number of parameters passing to the XQuery. Instead you can pass a single
      xml which will have all the parameters mapped


Xquery Performance testing guidelines

1. Test with huge payloads
2. Testing with values inside payload in different order (better reverse the order in the payload and test) 

Oct 13, 2012

Integrating siebel Adapter with BPEL Process manager

Oracle AS Adapter for Siebel provides bi-directional connectivity to Siebel EAI. It uses the Siebel COM and Java Data Bean API to synchronously invoke Siebel transactions - Siebel Business Objects and Business Services. It uses Siebel’s robust EAI framework to asynchronously receive events from Siebel in the form of Siebel Integration Objects. It supports more than one way of receiving events from the Siebel application namely Files, HTTP and MQSeries and ensures guaranteed delivery of Siebel events. It translates Siebel native data to standard XML format and back. 

Deployment of Adapter

During installation, Oracle Application Adapter for Siebel is deployed as a J2CA 1.0 resource adapter within the WLS container. The adapter must be deployed in the same WLS container as Oracle BPEL Process Manager.

Configuring a New Application Server Connection

To configure a new Application Server connection in Oracle JDeveloper:
  1. Open Oracle JDeveloper on your system.
  2. From the menu bar, click View and select Application Server Navigator.
    Oracle JDeveloper View menu
    Description of the illustration config_appserver1.gif

    The Application Server tab is displayed.
    Application Server tab
    Description of the illustration config_appserver2.gif
  3. Right-click Application Servers, and then select New Application Server.
    The Create Application Server Connection Wizard - Usage page is displayed.
    Create Application Server Connection Wizard
    Description of the illustration config_appserver3.gif
  4. Accept the default selection (Standalone Server) and click Next.
    The Name and Type page is displayed.
    Name and Type pane
    Description of the illustration config_appserver4.gif
  5. Specify a new name for the Application Server connection and click Next.
    The Authentication page is displayed.
    Authentication pane
    Description of the illustration config_appserver5.gif
  6. Specify a valid user name (for example, weblogic) and a password (for example, welcome1) for your new connection.
  7. Click Next.
    The Configuration page is displayed.
    Configuration pane
    Description of the illustration config_appserver6.gif
  8. Specify the Oracle WebLogic host name (for example, localhost), which is the machine IP where the process needs to deploy and Oracle WebLogic domain (for example, base_domain).
  9. Click Next.
    The Test page is displayed.
    Test pane
    Description of the illustration config_appserver7.gif
  10. Click Test Connection.
  11. Ensure that the test status is successful.
  12. Click Next.
    The Finish page is displayed.
    Finish pane
    Description of the illustration config_appserver8.gif
  13. Click Finish.
    The new Application Server connection is listed in the left pane (Application Server tab), as shown in the following image.
    Application Server tab
    Description of the illustration config_appserver9.gif


Designing an Outbound BPEL Process for Service Integration

The following tools are required to complete your adapter design-time configuration:
  • Oracle Adapter Application Explorer (Application Explorer)
  • Oracle JDeveloper BPEL Designer (JDeveloper) or Eclipse

Siebel Service Integration

This section describes how to perform service integration with Siebel. The following topcis are included:
  • Creating a Request-Response J2CA Service in Application Explorer
  • Creating an Integration Object Node


Creating a Request-Response J2CA Service in Application Explorer
To generate WSDL in Application Explorer:
  1. Start Application Explorer and connect to a defined Siebel target or create a new target.
    See Connecting to a Defined Target for more information.
  2. Expand the Siebel target to which you are connected.
  3. Expand Business ObjectAccount, and then Account.
    Application Explorer context menu
    Description of the illustration wsdl_generate1.gif
  4. Right-click queryWithView, and then select Create Outbound JCA Service (Request/Response).
    The Export WSDL dialog is displayed.
    Export WSDL dialog box
    Description of the illustration wsdl_generate2.gif
  5. Specify an export location on your file system or accept the default path.
    The .wsdl file extension is added automatically. By default, the names of WSDL files generated for request-response services end with _invoke.
  6. Click OK.
You can now create an empty composite for SOA, which is the first step that is required to define a BPEL outbound process in Oracle JDeveloper.


Creating a New SOA Application for the Outbound BPEL Process

Perform the following steps to create a new SOA application for the outbound BPEL process:
  1. Open Oracle JDeveloper on your system.
  2. In the Application Navigator tab, click New Application.
    Application Navigator tab
    Description of the illustration bpel_out_comp1.gif

    The Create SOA Application wizard is displayed.
    Create SOA Application wizard
    Description of the illustration bpel_out_comp2.gif
  3. From the Application Template list, click SOA Application.
  4. Enter name for the new SOA application (for example, Siebel_Outbound_BPEL) and click Next.
    The Name your project page is displayed.
    Name your project pane
    Description of the illustration bpel_out_comp3.gif
  5. Enter a project name (for example, QueryWithView_Invoke) and click Next.
    The Configure SOA settings page is displayed.
    Configure SOA settings pane
    Description of the illustration bpel_out_comp4.gif
  6. From the Composite Template list, select Empty Composite and click Finish.
    The new SOA application (Siebel_Outbound_BPEL) and associated project (QueryWithView_Invoke) are added to the Application Navigator tab in the left pane.
    Application Navigator tab
    Description of the illustration bpel_out_comp5.gif


Defining a BPEL Outbound Process

This section describes how to define a BPEL outbound process, which consists of the following stages:
  1. Configuring a Third Party Adapter Service Component
  2. Configuring an Outbound BPEL Process Component


Configuring a Third Party Adapter Service Component
Perform the following steps to create a third party adapter service component:
  1. Drag and drop the Third Party Adapter component from the Component Palette tab (Service Adapters section) to the External References design pane.
    External References design pane
    Description of the illustration bpel_out_adapt1.gif

    The Create Third Party Adapter Service dialog is displayed.
    Create Third Party Adapter Service dialog box
    Description of the illustration bpel_out_adapt2.gif
  2. Enter a name for the new third party adapter service.
  3. Ensure that Reference is selected from the Type list (default).
  4. Click the Find existing WSDLs icon, which is located to the right of the WSDL URL field.
    The SOA Resource Browser dialog is displayed.
    SOA Resource Browser dialog box
    Description of the illustration bpel_out_adapt3.gif
  5. Browse and select an outbound WSDL file from the following directory:
    C:\oracle\Middleware\Oracle_SOA1\soa\thirdparty\ApplicationAdapters\wsdls
    
  6. Click OK.
    The Localize Files dialog is displayed.
    Localize Files dialog box
    Description of the illustration bpel_out_adapt4.gif
  7. Click OK.
    The outbound WSDL file and associated request and response XML schema files (.xsd) are imported to the project folder that has been created.
    You are returned to the Create Third Party Adapter Service dialog.
    Create Third Party Adapter Service dialog box
    Description of the illustration bpel_out_adapt5.gif
  8. Click the Find JCA Files icon, which is located to the right of the JCA File field.
    The SOA Resource Browser dialog is displayed.
    SOA Resource Browser dialog box
    Description of the illustration bpel_out_adapt6.gif
  9. Browse and select the JCA properties file from the following directory:
    C:\oracle\Middleware\Oracle_SOA1\soa\thirdparty\ApplicationAdapters\wsdls
    
  10. Click OK.
    The following message is displayed.
    Copy File message
    Description of the illustration bpel_out_adapt7.gif
  11. Click Yes.
    A copy of the JCA properties file is made in the project folder.
    You are returned to the Create Third Party Adapter Service dialog.
    Create Third Party Adapter Service dialog box
    Description of the illustration bpel_out_adapt8.gif
  12. Click OK.
    The third party adapter service component (GetDetail) is created in the External References pane, as shown in the following image.
    External References pane
    Description of the illustration bpel_out_adapt9.gif

    You are now ready to configure an outbound BPEL process component.


Configuring an Outbound BPEL Process Component
Perform the following steps to configure an outbound BPEL process component:
  1. Drag and drop the BPEL Process component from the Component Palette tab (Service Components section) to the Components design pane.
    Components design pane
    Description of the illustration bpel_out_proc1.gif

    The Create BPEL Process dialog is displayed.
    Create BPEL Process dialog box
    Description of the illustration bpel_out_proc2.gif
  2. In the Name field, enter a name to identify the new outbound BPEL process component (for example, querywithview_out).
  3. From the Template list, select Synchronous BPEL Process.
  4. Click the Browse Input Elements icon, which is located to the right of the Input field to select the associated XML request schema file.
    The Type Chooser dialog is displayed.
    Type Chooser dialog box
    Description of the illustration bpel_out_proc3.gif
  5. Expand Project Schema FilesqueryWithView_invoke_request.xsd, and then select Siebel.
  6. Click OK.
    You are returned to the Create BPEL Process dialog.
    Create BPEL Process dialog box
    Description of the illustration bpel_out_proc4.gif
  7. Click the Browse Output Elements icon, which is located to the right of the Output field to select the associated XML response schema file.
    The Type Chooser dialog is displayed.
    Type Chooser dialog box
    Description of the illustration bpel_out_proc5.gif
  8. Expand Project Schema FilesqueryWithView_invoke_response.xsd, and then select SiebelResponse.
  9. Click OK.
    You are returned to the Create BPEL Process dialog.
    Create BPEL Process dialog box
    Description of the illustration bpel_out_proc6.gif
  10. Click OK.
  11. Create a connection between the outbound BPEL process component (querywithview_out) and the third party adapter service component (QueryWithView).
    Oracle JDeveloper workspace area
    Description of the illustration bpel_out_proc7.gif
  12. Double-click the outbound BPEL process component (querywithview_out) in the Components pane.
    The following is displayed.
    Oracle JDeveloper workspace area
    Description of the illustration bpel_out_proc8.gif
  13. Drag and drop the Invoke activity component to the Components pane and place it between the receiveInput activity component and the replyOutput activity component.
    Oracle JDeveloper workspace area
    Description of the illustration bpel_out_proc9.gif
  14. Create a connection between the new Invoke activity component (Invoke_1) and the third party adapter service component (QueryWithView).
    Oracle JDeveloper workspace area
    Description of the illustration bpel_out_proc10.gif

    The Edit Invoke dialog is displayed.
    Edit Invoke dialog box
    Description of the illustration bpel_out_proc11.gif
  15. Click the Automatically Create Input Variable icon, which is located to the right of the Input field to configure a new input variable.
    The Create Variable dialog is displayed.
    Create Variable dialog box
    Description of the illustration bpel_out_proc12.gif
  16. Accept the default values that are provided for the new input variable and click OK.
    You are returned to the Edit Invoke dialog.
    Edit Invoke dialog box
    Description of the illustration bpel_out_proc13.gif
  17. Click the Automatically Create Output Variable icon, which is located to the right of the Output field to configure a new output variable.
    The Create Variable dialog is displayed.
    Create Variable dialog box
    Description of the illustration bpel_out_proc14.gif
  18. Accept the default values that are provided for the new output variable and click OK.
    You are returned to the Edit Invoke dialog.
    Edit Invoke dialog box
    Description of the illustration bpel_out_proc15.gif
  19. Click Apply and then OK.
    The Invoke activity component (Invoke_1) is updated accordingly.
    Oracle JDeveloper workspace area
    Description of the illustration bpel_out_proc16.gif
  20. Drag and drop the Assign activity component to the Components pane and place it between the Receive activity component (receiveInput) and the Invoke activity component (Invoke_1).
    Oracle JDeveloper workspace area
    Description of the illustration bpel_out_proc17.gif
  21. Double-click the new Assign activity component (Assign_1).
    The Assign dialog is displayed.
    Assign dialog box
    Description of the illustration bpel_out_proc18.gif
  22. Click the Copy Operation tab.
  23. Click the Plus sign icon and select Copy Operation from the list of available operations.
    The Create Copy Operation dialog is displayed.
    Create Copy Operation dialog box
    Description of the illustration bpel_out_proc19.gif
  24. In the From pane, expand VariablesInputVariable, and then select payload.
  25. In the To pane, expand VariablesInvoke_1_queryWithView_InputVariable, and then select input_queryWithView.
  26. Click OK.
    You are returned to the Assign dialog.
    Assign dialog box
    Description of the illustration bpel_out_proc20.gif
  27. Click Apply and then OK.
  28. Drag and drop the Assign activity component to the Components pane and place it between the Invoke activity (Invoke_1) and the Reply activity (replyOutput).
    Oracle JDeveloper workspace area
    Description of the illustration bpel_out_proc21.gif
  29. Double-click the new Assign activity component (Assign_2).
    The Assign dialog is displayed.
    Assign dialog box
    Description of the illustration bpel_out_proc18.gif
  30. Click the Copy Operation tab.
  31. Click the Plus sign icon and select Copy Operation from the list of available operations.
    The Create Copy Operation dialog is displayed.
    Create Copy Operation dialog box
    Description of the illustration bpel_out_proc22.gif
  32. In the From pane, expand VariablesInvoke_1_queryWithView_OutputVariable, and then select output_queryWithView.
  33. In the To pane, expand VariablesoutputVariable, and then select payload.
  34. Click OK.
    You are returned to the Assign dialog.
    Assign dialog box
    Description of the illustration bpel_out_proc23.gif
  35. Click Apply and then OK.
    The completed activity flow is now displayed.
    Completed activity flow
    Description of the illustration bpel_out_proc24.gif
  36. Double-click composite.xml in the left pane.
    Application Navigator tab
    Description of the illustration bpel_out_proc25.gif
  37. Click the Save All icon in the menu bar to save the new outbound BPEL process component that was configured.
    Save All icon
    Description of the illustration bpel_out_proc26.gif

    You are now ready to deploy the BPEL outbound process.


Deploying the BPEL Outbound Process

Perform the following steps to deploy the BPEL outbound process.
  1. Right-click the project name in the left pane (for example, QueryWithView_Invoke), select Deploy, and then click QueryWithView_Invoke.
    Deploy context menu
    Description of the illustration bpel_out_deploy1.gif

    The Deployment Action dialog is displayed.
    Deployment Action dialog box
    Description of the illustration bpel_out_deploy2.gif
  2. Ensure that Deploy to Application Server is selected.
  3. Click Next.
    The Deploy Configuration dialog is displayed.
    Deploy Configuration dialog box
    Description of the illustration bpel_out_deploy3.gif
  4. Leave the default values selected and click Next.
    The Select Server dialog is displayed.
    Select Server dialog box
    Description of the illustration bpel_out_deploy4.gif
  5. Select an available application server that was configured and click Next.
    The SOA Servers dialog is displayed.
  6. Select a target SOA server and click Next.
    The Summary dialog is displayed.
    Summary dialog box
    Description of the illustration bpel_out_deploy5.gif
  7. Review and verify all the available deployment information for your project and click Finish.
    The process is deployed successfully.
    SOA Log tab
    Description of the illustration bpel_out_deploy6.gif

    If an Authorization Request dialog is displayed during the deployment process, provide the required user name and password and click OK.


Invoking the Input XML Document in the Oracle Enterprise Manager Console

Perform the following steps to invoke the input XML document in the Oracle Enterprise Manager console.
  1. Log in to the Oracle Enterprise Manager console by using the following URL:
    http://localhost:7001/em
    
  2. Expand your domain in the left pane followed by the SOA folder.
    Oracle Enterprise Manager console
    Description of the illustration bpel_out_test1.gif
  3. Select an available project (for example, Siebel_Outbound_queryWithView_BPEL).
    Test button
    Description of the illustration bpel_out_test2.gif
  4. Click Test in the right pane.
    The Test Web Service page is displayed.
    Test Web Service pane
    Description of the illustration bpel_out_test3.gif
  5. Click the Request tab.
  6. Scroll down to the Input Arguments section.
    Input Arguments section
    Description of the illustration bpel_out_test4.gif
  7. Select XML View from the list in the upper-left corner.
  8. Provide an appropriate input XML document in the Input Arguments area.
  9. Click Test Web Service.
    The output response is received in the Response tab of the Oracle Enterprise Manager console.
    Response tab
    Description of the illustration bpel_out_test5.gif


Testing Outbound BPEL and Mediator Processes

When testing an outbound BPEL process from the Oracle Enterprise Manager console or an outbound Mediator process from the Enterprise Manager console, do not use the XML envelopes that are generated by these consoles. Instead, remove them and use the XML payloads that are generated from the schemas, which conform to the WSDLs for namespace qualifications.
The Mediator data flows can be tested using the Enterprise Manager console. When creating a Mediator data flow and interactions, the Web services are created and registered with the Oracle Application Server.