Ajax for Business Logic

Sunday, February 19, 2006

I created a JavaScript Wrapper for my C# Business Logic classes. You specify which dll to "wrap" and the wrapper spits out javascript.

The result is that you can write near-C# language in JavaScript! I have all the public classes, constructors, public constants, public methods and public properties available client side in javascript.

The methods and constructors are just "empty" functions that check if the correct number of parameters are specified and then perform a synchronous web service call. The web service then invokes the constructor or method and returns the resulting value.

This means that you don't need to write hundreds of web services and web service methods when you need to interact with the business entities and business logic.

In respect to security the wrapper only wraps public classes and namespaces. And furthermore it checks that a [Wrap] attribute is present.

For even more security WSE provides a mechanism to digitally sign SOAP messages.

Examples:

Creating an instance of Business.Logic.ContractSale using the constructor that takes an id as parameter, invoking Validate() and Accept(DateTime oDateAccepted) on the instance.

  var oContractSale = 
    new Business.Logic.ContractSale(iCSal_Id);

  if (oContractSale.Validate()) {
    oContractSale.Accept(new Date());
  }
  else {
    alert("Sales contract is not valid!");
  }

Creating a new instance of Business.Logic.InvoiceSale setting properties and invoking method Save() on the instance.

  var oInvoiceSale = 
    new Business.Logic.InvoiceSale();

  oInvoiceSale.DateInvoice = new Date();
  oInvoiceSale.Amount = 150;
  oInvoiceSale.Currency = Business.Logic.Currency.USD;
  oInvoiceSale.Save();

4 Comments:

Blogger Troels Wittrup said...

You have a nice demo on your web site, looks great and easy to use!

It's neat for users who are familiar with windows applications, the way the user experience is the same. I'll try it out.

I can download the webcast, but when I play it, there's no picture, only sound...

11:55 PM  
Blogger nnanno said...

I'll try it.

from Spain

2:38 PM  
Anonymous Anonymous said...

hi Troels

have you got a demo of your javascript business logic wrapper?

thanks
Karl

7:42 PM  
Blogger Troels Wittrup said...

Hi Karl

Thanks for your interest!

I have posted a sample project - I hope you find it useful, please post any comments!

1:17 PM  

Post a Comment

<< Home