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:
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...
I'll try it.
from Spain
hi Troels
have you got a demo of your javascript business logic wrapper?
thanks
Karl
Hi Karl
Thanks for your interest!
I have posted a sample project - I hope you find it useful, please post any comments!
Post a Comment
<< Home