Wednesday, October 28, 2015

SOA environment with TIBCO BW 6

Hi,

As I've mentioned in my previous posts, my team at Clalit Health Services is in charge of all interfaces in Clalit's hospitals and community clinics.
These days we work on a migrate process from BizTalk 2010 to TIBCO BW 6.
That actually means developing all organization interfaces from scratch.

PROBLEM BACKGROUND


TIBCO BW 6 is a brand new product, so we have spent a lot of hours figuring how exactly we should work with it. Of course we ran into some product bugs (TIBCO were really helpful and even fixed some in later versions), but the big question was how to build a SOA environment (services has to be loosely-coupled).

For instance, let's say "Service A" needs to use "Service B".
"Service A" should have the option to invoke "Service B" by consuming its wsdl (using "Binding Reference"), but do NOT invoke "Service B" process directly (using "Process Binding").

"Binding Reference" advantages:
1.       "Service A" and "Service B" are loosely-coupled, and there is more control over the messages being passed (because the use of SOAP - via JMS or HTTP). All of our TIBCO services are exposed with JMS, and SOA allows full control on the messages going in and out from queues.
2.       An easy deploy after a change in service functionality. A change in service functionality will only affect the deployment package of the service itself. After deploying a changed service again, all other applications invoking it with "Binding Reference" would use the new service functionality.

"Process Binding" (tightly-coupled services) disadvantages: 
  1. There is no control over messages being sent from one to another (because they are sent using TIBCO internal engine and not with SOAP).
  2. When a service process gets changed – you would have to redeploy all applications that refer to it with "Process Binding" (because the service functionality is included in each application deployment package).

TIBCO Project types


TIBCO 6 project types:

Shared Module
A unit of shared resources.
In a short brief, whenever you want to share some resources across application modules – use should put them inside a "shared module" project.



Application Module
Application module is actually a shared module, but without the "sharing" part.
In contrast to shared modules, application modules cannot export its functionality.
Each application module can use (include) several shared modules.



Application
Contains the deployment package.













WSDL Types


Abstract wsdl 


A contract of each TIBCO process (service). Create an abstract wsdl when you develop a TIBCO process (service). It contains input, output and fault operations (each defined by an external or inline schema) for the process.

Concrete wsdl


Used for consume of a TIBCO process (service), because it contains a definition of "PortType". Create a concrete wsdl after you finish developing a TIBCO process that needs to be exposed (service).

You can set several types of concrete wsdl:

1.       Concrete wsdl which embed its abstract wsdl
A concrete wsdl has to know its abstract wsdl. You can actually embed a service abstract wsdl inside its concrete wsdl.
Why not? Whenever the service abstract wsdl would change during development, then you will have to regenerate (or change) the concrete wsdl as well.
Instead, hold inside the service concrete wsdl a reference to the service abstract wsdl using "wsdl:import" tag.
For instance:
<wsdl:import namespace="http://myns.com/WSDL/TibSrv_Cache.wsdl" location="TibSrv_Cache.wsdl"/>
("TibSrv_Cache.wsdl" is the abstract wsdl)

2.       Concrete wsdl which embed schemas
A concrete wsdl can contain all required schemas definitions in it.
Why not? If schema is defined more than once (For instance: inside a .xsd file and inside a service wsdl) in the same project, it will cause namespace collisions.
Instead, hold inside the service abstract wsdl a reference to the required schemas by adding "wsdl:types" and "xsd:import" tags.
For instance:
<wsdl:types>
                <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
                                <xsd:import namespace="http://myns.com/Schemas/Fault"                     schemaLocation="../Infrastructure/tibco.infrastructure.shared/Schemas/Fault.xsd">
                                </xsd:import>
</xsd:schema>
</wsdl:types>

3.       A light-weight service concrete wsdl which holds a reference to its abstract wsdl.

As you probably realized from 1 & 2 paragraphs – use option 3.


NOTES:

1. Writing reference links (locations) in an abstract or a concrete wsdl isn't enough.
All resources required for a concrete wsdl (abstract wsdl resource) and an abstract wsdl (schemas resources), should be placed in the same project.

2. Generate a concrete wsdl with embedded abstract wsdl and schemas for other clients (like .NET, JAVA etc.) that needs to invoke a TIBCO BW service.


Implementation

Use shared modules to create a small "expose" unit for each service.
For instance: Creating an "expose" shared module for Service A.
"Service A shared module" would contain a concrete wsdl, an abstract wsdl and schemas.
As mentioned before, the concrete wsdl reference to the abstract wsdl, which reference to the schemas.
If "Service B" wants to invoke "Service A" - it would add "Service A" shared module to its service appliaction module.


Environment architecture diagram:


































Application C, Application D – represents typical TIBCO applications with processes that doesn't exposed as a web-service.

ESB Service A, ESB Service B – represents typical TIBCO applications with processes that exposed as a web-service.

ESB Service A shared module – Contains shared resources of ESB Service A (its abstract wsdl, concrete wsdl and schemas). Basically, it's all resources that Service A concrete wsdl needs.

ESB Service B shared module – Contains shared resources of ESB Service B (its abstract wsdl, concrete wsdl and schemas). Basically, it's all resources that Service B concrete wsdl needs.

Infrastructure shared module – Contains shared resources across ALL modules (for instance: fault schemas, trace schemas, infrastructure sub-processes etc.).


Diagram explanation:


1 - "ESB Service A" includes "ESB Service A shared module"
The service process inside "ESB Service A" application module needs its abstract wsdl and schemas resources from "ESB Service A shared module".

3 - "ESB Service A" includes "ESB Service B shared module"
"ESB Service A" wants to invoke "ESB Service B", so it needs "ESB Service B" concrete wsdl (placed in "ESB Service B shared module").

2 - "ESB Service A" includes "Infrastructure shared module"
"ESB Service A" needs to use global resources.
For instance: process which uses a shared trace schema.

4 - "ESB Service A shared module" includes "Infrastructure shared module"
"ESB Service A shared module" needs to use global resources.
For instance: if the abstract wsdl points to a shared fault schema.


Application "Includes" example:















How to consume service in the process ?

After including a service shared module project, just use "Invoke" shape in the process. 
Choose "Binding Reference", then the service abstract wsdl and at last add a SOAP binding. 

















Under "WSDL Port:" choose the service port type (which is defined in the concrete wsdl).






Friday, September 18, 2015

Simple HTML Paging with JavaScript

Hi,
In this post i'll take you step by step with a little upgrade I wrote for this nice plugin:

You can checkout the demo over here:

Unfortunately, that cool plugin has one thing missing for my use-case. In case of a large table with many rows, you cannot limit the paging number.
You CAN limit the rows per page, but CANNOT limit the number of pagination links.

So I decided to enhance the "paging.js" file.
Let's take a brief look over the changes i've made. 
Changes I made are marked with red.

Added "limitPaging" property


First, I needed to add a property that would hold the maximum number of paging links:
options: {
                limit: 5,
                limitPaging: 5,
                rowDisplayStyle: 'block',
                activePage: 0,
                rows: []
            }

Notice that "limit" is the number of rows per page.

Hiding unnecessary links when initializing the navbar


The blue navigation bar is intialized at "_getNavBar" function.
I needed to  add a code that displays the first numbers until limitPaging value. 
For instance: if limitPaging is 5, then only "1 2 3 4 5" links should be presented.

var rows = this.options.rows;
                var nav = $('<div>', { class: 'paging-nav' });
                var displayVal;
                for (var i = 0; i < Math.ceil(rows.length / this.options.limit); i++) {
                    displayVal = 'display:inline-block';
                    if (i > this.options.limitPaging)
                        displayVal = 'display:none';

                    this._on($('<a>', {
                        href: '#',
                        text: (i + 1),
                        "data-page": (i),
                        style: displayVal
                    }).appendTo(nav),
                            { click: "pageClickHandler" });

                }

Basically, the number of the "for" loop runs equals to the number of pages. I did not want to change any of that logic, just to hide some of them (according to limitPaging).
"displayVal" holds the style configuration for showing/not showing the paging link.
In case a page number ("i" var) is bigger then the limitPaging prop - then displayVal gets the hiding config.

In the event handler code ( .on() - http://api.jquery.com/on/ ), each link is created.
I added a style attribute with the display value.

Clicking on a paging link


After a click on a paging link - "pageClickHandler" gets fired.
I wanted that the selected page would always be in the middle.
"itemsOnEachSide" - defines the number of visible paging index on each side
"startPage" - defines the index of the first visible paging index
"endPage" - defines the index of the last visible paging index
"pagingLinks" - holds all the paging links

In the "for" loop, there is an iteration on each paging links and you can see that the display logic is pretty simple.

pageClickHandler: function (event) {
                event.preventDefault();
                $(event.target).siblings().attr('class', "");
                $(event.target).attr('class', "selected-page");
                var pageNum = $(event.target).attr('data-page');
                var itemsOnEachSide = this.options.limitPaging / 2;
                var startPage = Math.floor(parseInt(pageNum) - itemsOnEachSide + 1); // Plus 1 because the array of links starts in "1" index and not "0". "0" index is the next (">>") button 
                var endPage = Math.ceil(parseInt(pageNum) + itemsOnEachSide + 1);
                var pagingLinks = $(event.target).parent().children();
                for (var i = 1; i < pagingLinks.length - 1; i++) {
                    if(i>=startPage && i<=endPage)
                        $(pagingLinks[i]).css('display', 'inline-block');
                        else
                            $(pagingLinks[i]).css('display', 'none');
                }

                this.showPage(pageNum);
            }


Final Look:








Updating widget after loading

JQuery Widget has to be loaded only once. 
If you want to update the paging navigation bar (in case the amount of list rows gets changed), be sure to add an "update" method in this "paging.js" file and use it.


JSFiddle


http://jsfiddle.net/ohadinho/vnv646mp/

Tuesday, August 18, 2015

Creating a Service, WSDL, Schema for WSDL and operations with TIBCO BW 6.0

Hi,

Recently our BizTalk team started to work on a huge mission - migration from BizTalk Server to TIBCO ActiveMatrix BusinessWorks 6.
TIBCO ActiveMatrix BusinessWorks 6 is one of the most powerful enterprise integration platforms on the market.

As the project leader, one of our goals is to write clear documents which match the development strategy.
So here is the first piece. 
In this document, we would create a "Human" service with two operations: Walk & Sleep.

TibSrv_Human

Create Process

1. Choose Processes --> New --> BusinessWorks Process





2. Set "Package" to "Starters"
Set "Process Name" to "TibSrv_Human"





Press Finish.

Create Service & Operation

3. Now we would create the service inside the process.
Navigate to the green arrow on the right and click it.



4. In the "New Service" pop-up, choose "Create a new WSDL".
Set "File Name" to "TibSrv_Human.wsdl"
Set "Target Namespace" to "http://thisismytest.com/WSDL/TibSrv_Human/TibSrv_Human.wsdl"
Set "Interface Name" to "TibSrv_Human"
Set "Operation Name" to "operation_Walk"
Mark "Output" and "Throw a Fault" with V sign.


Press Next.

5. In the next screen you need to assign a schema to the new wsdl.
Set "File Name" to "TibSrv_Human.xsd"
Set "Target Namespace" to "http://thisismytest.com/Schemas/TibSrv_Human/TibSrv_Human.xsd"


       Press Finish.

After pressing Finish, your workspace should look like this:



6. Press right click on "operation_Walk" --> Operation --> Implement Constructor Operation




After clicking, you should get the following screen:



7. Choose from Project Explorer -->  Module Descriptors --> Components
Under "ComponentTibSrv_Human", choose "TibSrv_Human" and press Properties view.



8. Choose "Bindings" tab, and press "Add Binding" button on the right:



9. Choose "SOAP Binding"



    Press Finish.

10. Set "Name"
a. For HTTP binding - to "TibSrv_Human_HTTP" 
b. For JMS binding - to "TibSrv_Human_JMS" 
Also choose the relevant "Transport Type", "HTTP Connector Name" and "Endpoint URI"



Create Schemas

11. Now we will create Request\Response schemas.
From project explorer choose Schemas --> New --> XML Schema File



12. Set "Name" to "Walk_Request.xsd".




Press Finish.

By pressing double-click on "Walk_Request.xsd" schema, you should see the schema GUI:



13. Set "Target namespace" to "http://thisismytest.com/Schemas/TibSrv_Human/Walk_Request.xsd".

14. Press right click on "Elements", and then choose "Add Element".




15. Set "Name" to "Walk_Request", and from "Type" drop-down-list choose "New"





16. You should see the "NewType" pop-up.
Set to "Complex Type", and mark "Create as local anonymous type" option.



Press OK.


17. Now that you have a new root element, please press double click on it.





You should be moved to this screen:




18. Right click on "(Walk_RequestType)" and click on "Add Element".




19. Set "Name" to "Kilometers".



20. For the response schema (Walk_Response.xsd) repeat 11-19 steps.


Configuring the schemas inside the abstract WSDL

21. On project explorer, open "Service Descriptors" and choose "TibSrv_Human.wsdl".




22. Press the arrow near "operation_WalkRequest".




23. Right click on "in" parameter from "(operation_WalkRequestType)".
Press Delete.



24. Right click on "(operation_WalkRequestType)".
Choose "Add Element Ref".




25. From the "Reference" drop-down list, choose "Browse…"



26. From the "Set element reference" pop-up, Set "Search scope" to "Workspace", and then choose "Walk_Request".



Press OK.

27. Repeat 22-26 steps in order to configure the response schema.

Create another operation

28.       Right Click on the service name à Refactor à Create Operation



29.       From the "Create Operation" pop-up:
Set "Operation Name" to "operation_Sleep"
Choose "Request-Response".
Tick "Throw a Fault" option.

Press OK.
30.       From "Basic Activities", choose "Constructor" shape, and drag it to the process GUI.



31.       Choose the green starter (Marked with "1" in the following image).
Click "Select a Partner Link" arrow (Marked with "2" in the following image), choose "TibSrv_Human".
Click "Select an operation" arrow (Marked with "3" in the following image), choose "operation_Sleep".



32.       From "Basic Activities", choose "Reply" shape, and drag it to the "operation_Sleep" GUI.



33.  Click the "Reply" shape, and Set "Name" to "operation_SleepOut".
Click "Select a Partner Link" arrow and choose "TibSrv_Human".
Click "Select an operation" arrow and choose "operation_Sleep".



34.       Repeat steps 11-26, in order to create the operation schemas and relate them to the service wsdl.

Creating a Sub-Process with TIBCO BW 6.0

A sub-process is actually a process without a component which exposes it. A sub-process will not have a SOAP binding (JMS/HTTP), but would have a wsdl.

1.       On project explorer, choose "Processes" à "New" à BusinessWorks Process

2.   Set "Package" to "Walk"
Set "Process Name" to "WalkDispatcher"


Press Finish.

3.       Now we would create the service inside the process.
Navigate to the green arrow on the right and click it.



4.   In the "New Service" pop-up, choose "Create a new WSDL".
                        Set "File Name" to "WalkDispatcher.wsdl"
Set "Target Namespace" to "http://thisismytest.com/WSDL/TibSrv_Human/WalkDispatcher.wsdl"
Set "Interface Name" to " WalkDispatcher"
Set "Operation Name" to "operation_Walk"
Mark "Output" and "Throw a Fault" with V sign.





Press Next.

5.       We would use WSDL inline schema in order to represent the service.
Choose "Create WSDL inline schema".


Press Finish.

6.       In Project explorer, choose Components.
Delete "ComponentWalkDispatcher".



7.       Now you can go to "WalkDispatcher.wsdl", and define appropriate Request & Response schemas (In each operation defined in the inline wsdl schema. See also 21-26 steps).

Summary

That's it! 
Now you have a Process which contains a Service (with Service WSDL named "TibSrv_Human.wsdl" and "TibSrv_Human.xsd" attached to it). 
"TibSrv_Human.xsd" contains the service operations elements, and inside them you can configure elements or a reference to other schema.

You can now add sub-process invokation to the main process, which is the entry point of all operations: 
On "TibSrv_Human" process, add an invoke shape which calls "WalkDispatcher" sub-process from "operation_Walk".

See you next time with some more interesting stuff!

Thank you Blogger, hello Medium

Hey guys, I've been writing in Blogger for almost 10 years this is a time to move on. I'm happy to announce my new blog at Med...