Using MABLE logic engine with existing .NET applications.

A

Al Fatykhov

Using MABLE logic engine with existing .NET applications.


MABLE web services provide an interface to MABLE business objects and logic.
Let us review some technical details of the MABLE web services.

· MABLE utilizes SOAP 1.2 protocol.
· MABLE uses AXIS 1.4 as a web service transport.
· MABLE support state-full conversations by implementing a conversation
session.

In this small article we will create a client application that use the MABLE
'Store' application

MABLE Web Service client has to maintain a state-full conversation with the
MABLE
engine. The best way to handle this is by keeping a single instance of the
MABLE web service on the client side during sequence of events. Of course,
if you are not going to use
multiple threads or MABLE applications you can create multiple instances.

Before operating and manipulating business objects and their logic and
rules, the Web Service client has to initiate the MABLE application and the
business objects that it will use.


MABLE .NET WEB SERVICE CLIENT

Here is the listing of the .NET C# console application that implements MABLE
web services. The first step we should do is to add a Web Reference to your
..NET project that is pointing to the following MABLE WSDL descriptor:

http://www.alfabdi.com/MABLEWebServiceModule/services/FFrontServiceController?wsdl

Listing MABLESimpleWebServiceClient.cs
------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Configuration;
using System.Web;
using System.Net;
using MABLESimpleWebServiceClient.com.alfabdi.www;

/// <summary>
/// Title: Mind Ahead Business Logic Engine - MABLE client
/// Description: MABLE Web Service
/// Copyright: (c) 2006
/// Company: AL&FA Business Data Integrity, http://www.alfabdi.com
/// Author: Alisher Fatykhov
/// </summary>

namespace MABLEClient
{
class WebServiceClient
{
private FFrontServiceControllerService mable = new
FFrontServiceControllerService();

public WebServiceClient()
{
initMable();
}

private void initMable()
{
CookieContainer newCookieContainer = new CookieContainer();
mable.CookieContainer = newCookieContainer;
mable.setEjbname("FFboSessionEjb");
mable.setHost("localhost");
mable.setConfig("store/faframework-fbo-config.xml");
mable.setDebug("store/faframework-config.xml", "STORE");
mable.addFboSet("FFboSessionEjb", "STORE", "PRODUCTSEARCH", "",
"", "", "true", true);
mable.addFboSet("FFboSessionEjb", "STORE", "PRODUCT", "", "",
"", "true", true);
}

public void getProduct()
{
mable.setParameter("STORE", "PRODUCTSEARCH", "STARTDATE",
"12/30/2005");
mable.sendAction("STORE", "PRODUCTSEARCH", "DATA-EVENTS",
"MAKEWHERE");

string message = "";
if (!mable.sendAction("STORE", "PRODUCT",
"DATA-EVENTS","ISNEW"))
{
message = mable.getExceptionMessage("STORE", "PRODUCT",
"ISNEW");
mable.sendAction("STORE", "PRODUCT", "DATA-EVENTS",
"ROLLBACK");
}
else
{
mable.sendAction("STORE", "PRODUCT", "DATA-EVENTS",
"COMMIT");
}

int size = mable.getFboSetSize("STORE", "PRODUCT");

System.Console.Write("\n\n");
System.Console.Write("\n numberProducts = " + size);
System.Console.Write("\n product = " +
mable.getParameter("STORE", "PRODUCT", "DESCRIPTION"));
System.Console.Write("\n shelf = " + mable.getParameter("STORE",
"PRODUCT", "SHELFID"));
System.Console.Write("\n status ="+ message);
System.Console.Write("\n\n");
}

static void Main(string[] args)
{
WebServiceClient mableClient = new WebServiceClient();
mableClient.getProduct();
}
}
}
----------------------------------------------------------------------------------------------------

After we compile our project we run the MABLESimpleWebServiceClient.exe

The result will be like:
--------------------------------------------------------------------------------------
C:\...bServiceClient\MABLESimpleWebServiceClient\bin\Debug>MABLESimpleWebServiceClient.exe

numberProducts = 2
product = My Cat
shelf = 5
status =This business object's record is not new !
--------------------------------------------------------------------------------------

If you take a closer look at the source code of this client application you
will find a lot of similarities with the web applications we created in the
previous chapters.

Now we trace step by step what this client does first.

1. After the service object is created, it is necessary to set a
session conversation.
CookieContainer newCookieContainer = new CookieContainer();
mable.CookieContainer = newCookieContainer;

2. Setting the MABLE EJB name by:
mable.setEjbname("FFboSessionEjb");

3. Setting the MABLE EJB connection parameters:
mable.setHost("localhost");

4. Setting the MABLE application metadata location:
mable.setConfig("store/faframework-fbo-config.xml");

5. Setting the MABLE application logging verbosity level:
mable.setDebug("store/faframework-config.xml", "STORE");

6. Adding and initializing the MABLE business object 'PRODUCTSEARCH':
mable.addFboSet("FFboSessionEjb", "STORE", "PRODUCTSEARCH", "",
"", "", "true", true);

7. Adding and initializing the MABLE business object 'PRODUCT':
mable.addFboSet("FFboSessionEjb", "STORE", "PRODUCT", "", "",
"", "true", true);

Now we will use newly created business objects and operate with their
business logic.

8. Creating a WHERE clause for the 'PRODUCT' business object:
mable.setParameter("STORE", "PRODUCTSEARCH", "STARTDATE", "12/30/2005");

This call sets the 'STARTDATE' section of the WHERE clause to the
'12/30/2005' value.

9. The client calls CCSC action 'MAKEWHERE' which will create a new
WHERE clause and repopulate the 'PRODUCT' business object.
mable.sendAction("STORE", "PRODUCTSEARCH", "DATA-EVENTS", "MAKEWHERE");

10. The client checks the first business object in the stack of the
business objects if it has the 'NEW 'status.
if (!mable.sendAction("STORE", "PRODUCT", "DATA-EVENTS","ISNEW"))

11. If the status of the business object is not 'NEW' than the client
gets a status message of the 'ISNEW' CCSC action.
message = mable.getExceptionMessage("STORE", "PRODUCT", "ISNEW");

12. Rolling back current business object transaction (In this example we
are not using MABLE auto commit feature):
mable.sendAction("STORE", "PRODUCT", "DATA-EVENTS", "ROLLBACK");

More information about MABLE logic engine can be found
http://www.alfabdi.com

Al Fatykhov



Copyright (c) 2006. AL&FA Business Data Integrity. All rights reserved.
Patents pending

Mind Ahead Business Logic Engine - MABLE, Mind Ahead Web Framework and
SuperGrid are registered trademarks of AL&FA Business Data Integrity
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top