Wednesday, April 30, 2008

ASP.NET AND ASP.NET WITH AJAX

Published: 14 Feb 2007
By:Xun Ding

Edited by Vinay k singh

The most important thing in this blog is the DISADVANTAGES OF ASP.NET.....

ASP.NET provides a number of ways of working with client-side script. This article explores the usage and drawbacks of ASP.NET script callbacks, and briefly presents a bird's view of ASP.NET AJAX.

Introduction

ASP.NET server-based web forms use a request-response model. Each request results in a roundtrip a.k.a postback to the server. Each postback causes the requesting page to be refreshed, regardless of the nature or the sender of the request. With web users becoming more and more sophisticated, the request-response-refreshing (or click-n-wait) model becomes less and less desirable and in the case of heavy webpages, the lack of smooth performance simply drives users away.

To remedy this, ASP.NET allows various ways to work with JavaScript. One class of them is the ClientScript class, which interjects JavaScript into a webpage, to perform a host of pure client-side tasks, such as window pop-ups, setting focus etc. This class uses strictly a server-centric model, in which the server controls the operation.

Another option is to use an object called XMLHttpRequest to bridge across server and clent-side script, and to enable client-side script to make direct calls to the server, retrieve server-side data, then partially and selectively refresh the calling page. With this model, ASP.NET enables you to create both server-centric and client-centric applications.

There are two ways from the client-side script to make server calls and achieve partial page rendering. One is using the ASP.NET built-in script callback mechanism, the other is the AJAX technology. In this article, we'll examine the Script Callback techniques in detail, we'll also briefly look at AJAX in general, and the programming models in ASP.NET AJAX.

ASP.NET JavaScript Callbacks

To shield programmers from the intricacies of making use of the XMLHTTP object, ASP.NET introduces a string of operations on the server and client side to accomplish Script Callbacks.

On the server side, the code-behind page class must define a method called GetCallbackEventReference method, it also must implement the ICalbackEventHandler interface. The ICalbackEventHandler interface requires two methods:

  1. RaiseCallbackEvent
  2. GetCallbackResult
The former method handles the necessary operation on the server such as data retrieval; the latter returns the result to the calling script.

Generally we define the GetCallbackEventReference method in the web form's Page_Load event. It returns the JavaScript command WebForm_DoCallback that is to be executed once the server has finished serving the call. The WebForm_DoCallback in turn is stored in the resources of the system.web assembly and will be retrieved through the WebResource.axd HTTP handler.

On the client side, at least two methods must be defined. The first one is the event handling method, responding to an event such as onclick, onmouseover; the second is used to process the response from the callback, and accordingly update's the necessary part of the page.

To illustrate these rather convoluted procedures, we use an example that provides suggestions based on user's input in a textbox. (Please note, this ASP.NET code is tailored from the original AJAX code written in ASP and JavaScript at http://www.w3schools.com/ajax/ajax_example_suggest.asp.)

Web form:
"form1" runat="server">
First Name: "GetHint();"/>

Suggestions: "txtHint">

Server-side Code
using System;

using System.Web.UI;

//implement ICallbackEventHandler Interface
public partial class scriptcallback : System.Web.UI.Page, ICallbackEventHandler
{
private String hint;
public String getHintFromServer;

//Define GetCallbackEventReference method
//
whose signature is as the following:
//public string GetCallbackEventReference(
//Control target,
//string argument,
//string clientCallback,
//string context,
//string clientErrorCallback,
//bool useAsync)
void Page_Load(object sender, System.EventArgs e)
{
getHintFromServer = this.ClientScript.GetCallbackEventReference
(this, "message", "ShowHint", "null", "null", false);
}

//The parameter eventArg is the argument parameter of
//the GetCallbackEventReference,passed from the JavaScript.
void ICallbackEventHandler.RaiseCallbackEvent(string eventArg)
{
String[] a = new String[31];
a[1] = "Anna";
a[2] = "Brittany";
a[3] = "Cinderella";
a[4] = "Diana";
a[5] = "Eva";
a[6] = "Fiona";
a[7] = "Gunda";
a[8] = "Hege";
a[9] = "Inga";
a[10] = "Johanna";
a[11] = "Kitty";
a[12] = "Linda";
a[13] = "Nina";
a[14] = "Ophelia";
a[15] = "Petunia";
a[16] = "Amanda";
a[17] = "Raquel";
a[18] = "Cindy";
a[19] = "Doris";
a[20] = "Eve";
a[21] = "Evita";
a[22] = "Sunniva";
a[23] = "Tove";
a[24] = "Unni";
a[25] = "Violet";
a[26] = "Liza";
a[27] = "Elizabeth";
a[28] = "Ellen";
a[29] = "Wenche";
a[30] = "Vicky";

Int32 i;

if (eventArg.Length > 0)
{
for (i = 1; i < 31; i++)
{
String suggestion = a[i].Substring(0, eventArg.Length).ToUpper();
if (eventArg.ToUpper() == suggestion)
{
if (hint == "")
hint = a[i];
else
hint = hint + " , " + a[i];
}

}//'Output "no suggestion" if no hint were found
// 'or output the correct values
if (hint == "")
hint = "no suggestion";
}
else
hint = "no suggestion";
}

//Return a string that will be received and processed
// by the clientCallback JavaScript funtion
String ICallbackEventHandler.GetCallbackResult()
{
return hint;
}
}
Client Side Code:
<script language=javascript>

function GetHint()
{
var message = document.form1.tFirstName.value;
var context = '';
<%=getHintFromServer%>
}

function ShowHint(hint) {
var spanHint=document.getElementById("txtHint");
spanHint.innerHTML=timeMessage;
}
script>

Drawbacks of Using Script Callbacks

Using ASP.NET Script callbacks has a few issues:

1. Cross-browser Support

ASP.NET Script callbacks will work with Internet Explorer, Firefox and other Mozilla-compliant browsers. It ensures each compliant browser can call the server and return with server-side response, however not all browsers supports dynamic partial page updates. Even with those that do, it is important that script code strictly follows the W3C DOM (Document Object Model - DOM) standards.

In the above example, to update the text inside the span tag called txtHint, instead of directly calling txtHint.innerHTML or using document.all.txtHint: We use the document.getElementById method to retrieve the element then update its content:

var spanHint=document.getElementById("txtHint");

spanHint.innerHTML=...;

2. Server's Response Delivery Format

With each script's callback, the server responds with a string. This works very well with small amount of data. However, it gets problematic with large complex data types. It defeats the purpose if we have to rely on the client-side script on laborious and intensive data parsing, let alone doing so is error-prone.

3. Problem with multiple callbacks

ASP.NET script callback works fine with a single call generated from a single control. However, it gets messy if multiple controls issue multiple callbacks. Because no matter where and how the call is generated, it all gets to be handled by the RaiseCallbackEvent method on the server side. To differentiate the calls and their senders, there is only one way, which is to bundle all necessary information into a string and pass that to the GetCallbackEventReference method, which in turn will be passed to the RaiseCallbackEvent method. It is also possible to write a custom class to handle multiple callbacks.

For more details, please see Script Callbacks in ASP.NET 2.0 - interesting, but lacking.

AJAX

The bundle of technologies (DHTML, JavaScript, XmlHTTPRequest, CSS) that is now coded as AJAX (Asynchronous JavaScript And XML) has been around for a long time. However, only after the launch of a string of successful Google applications (such as Google Maps, Google Suggest, and Gmail) it gained enormous and lasting popularity.

In its bare bone, AJAX makes direct calls to server using the JavaScript XMLHttpRequest object. The XMLHttpRequest object has a readyState property with 5 possible values, a value of 4 indicates a call to server is complete and the calling party can update part of the page based on the response sent back from the server.

ASP.NET AJAX

The raw infrastructure and logic of AJAX is very simple. However, using AJAX in its raw form to write truly interactive and appealing web pages demands extensive skills in JavaScript and sidestepping the various traps caused by the subtle differences between various browsers. It also entails that programmers reinvent the wheel, repeatedly rewriting the same code to recreate the same behavior for common controls. Therefore, many AJAX frameworks have sprung up to free programmers from toiling around sending request and processing responses at its lowest level. Many frameworks also provide a set of sophisticated tools and protocols. ASP.NET AJAX (formerly known as ATLAS) is such a comprehensive yet still fast evolving framework designed for ASP.NET.

An ASP.NET AJAX application can be both server-centric or client centric. In a server-centric application, partial page updates are administrated by a server control called UpdatePanel. It behaves as a intermediate broker between the requesting and responding party, as shown in the following diagram:

For a regular ASP.NET server page to realize partial page-update, the easiest way is to place one or more parts of web page inside an UpdatePanel. A web page can have multiple UpdatePanel controls, an UpdatePanel can also have nested UpdatePanel controls. It is also allowed to have controls outside of an UpdatePanel defined as triggers to fire a partial update.

While it is possible for the UpdatePanel control to work with client script, the functionalities are rather limited - such as stopping and canceling asynchronous postbacks, custom error-message handling, etc. And you must call a reference to the PageRequestManager class in the Microsoft AJAX library. It is more common to use the AJAX library to create custom client components to enable client behaviors, and then use these components as server controls' extensions. The host of components provided by the ASP.NET AJAX Control Toolkit is such custom client components.

In a client-centric AJAX application, a JavaScript function directly calls a Webservice through a script proxy class. Again a new set of rules must be strictly followed. First for a webservice to be consumed by a client-side script, it must be marked with the ScriptService attribute. In the calling page, a reference to the Webservice must be placed inside a ScriptManager control and specify its path to the Webservice, as in the following code:

"server" ID="scriptManager">


"MyWebService.asmx" />

It is also possible to for a JavaScript to call a static page method that is marked with the [WebMethod] keyword.

Summary:

To enable the communication between server and client, more importantly, to enable partial page rendering, ASP.NET has two major approaches: one is script callbacks, the other ASP.NET AJAX. While script callbacks represents an earlier primitive approach which leaves much to be desired, ASP.NET AJAX represents a sophisticated framework that includes server and client-side components, a JavaScript library (AJAX library), and a collection of server-side classes and methods (AJAX extensions).

While ASP.NET AJAX has enjoyed a lot of exposure and gained lasting popularity and influence, script callbacks are much less well-known. However, given that script callbacks are extensively used by such ASP.NET controls as the TreeView and GridView, its approach still merits some exploration. Therefore this article showed the details of the usage of script callbacks, examining some of its downsides, and briefly introduces the underlying logic of AJAX, and the programming models of ASP.NET AJAX in particular.

Friday, March 28, 2008

Registry In's and Out's Using C#

Registry In's and Out's Using C#
By Michael Bright

his is an article on using the Registry in C#. Having been looking around the web and on the MSDN libraries, I have determined that there is not a complete guide on using all the registry tools accessible using C#. So this article is going to cover all methods exposed to the user when developing in C#. Firstly i would like to say that I am very aware that the current consensus is that we should not be using the Registry to hold information about our programs anymore and that the ".NET" way is to store information in XML files. Well if that is you then you don't really need this article, however if you are accessing information from the registry then this is the source for you, please note that i have also included information from my previous article on "Advance Registry Access in C#". Ok so lets get down to business.

When using the .NET framework in C# the user needs to add access to the Microsoft.Win32 namespace in order to access registry manipulation tools, this is done as shown in the below code

using Microsoft.Win32;
Once this reference has been added along with the other, it gives us access to the elements involved within registry control. There are two main classes associated with this namespace, RegistryKey and Registry. These classes are used together to allow us to do pretty much everything in the registry.

RegistryKey Class
The RegistryKey class is the most important part in terms of registry manipulation when using C#. The RegistryKey class has many methods which the use can exploit to create and delete data. Before we can do any of this we have to create an Instance of a Registry Key, this is done using the code below:
RegistryKey OurKey = Registry.Users;

In the above code extract we have created a instance of RegistryKey called OurKey, we have initialized this key to be the HKEY_USERS subkey in the registry. Basically this mean that any method we use in this key will effect the direct subkeys of HKEY_USERS and their data items.

OpenSubKey()

OpenSubkey is a very important method when using the RegistryKey class, because it allows us to access/manipulate the subkey of the top key. This may sound a tad strange, basically if as above we have "OurKey" set to the HKEY_USERS key, using the OpenSubKey method we can set "OurKey" to a subkey of HKEY_USERS. The best we to demonstrate this is to show you some code (See below).

RegistryKey OurKey = Registry.Users;
OurKey = OurKey.OpenSubKey(".DEFAULT",true);


In the above code sample we have created our instance of the RegistryKey class and given it the value of the HKEY_USERS key. The next step is that we have opened a subkey within HKEY_USERS called ".DEFAULT", we should also note that it doesn't have to be a top level subnode either, We could have opened ".DEFAULT\subkey". The second part to the method is defining if the key is opened and Read-only mode or Read/Write mode. If the value is true we can edit items within the key, and the key itself.

DeleteSubKey() / CreateSubKey() & DeleteSubKeyTree()

All these three methods are to do with the management of Subkeys under the current selected key. These methods are pretty self explanatory and the below code shows there implementation.

RegistryKey OurKey = Registry.Users; // Create OurKey set to HKEY_USERS
OurKey = OurKey.OpenSubKey(".DEFAULT",true); // Set it to HKEY_USERS\.DEFUALT
OurKey.CreateSubKey("OurSubKey"); // Create the key HKEY_USERS\.DEAFULT\OurSubKey
OurKey.CreateSubKey(@"OurSubKey\Subkey"); // Create a sub key HKEY_USERS\.DEFAULT\OurSubKey\Subkey
OurKey.DeleteSubKey(@"OurSubKey\SubKey"); // Delete the subkey name "subkey"
OurKey.DeleteSubKeyTree("OurSubKey"); // Delete the whole subkey and any subkeys below it

GetSubKeyNames()

GetSubKeyNames is an important method because it allows us to get all the names of the secondary subkeys, For instance we could get all the names of the subkeys below "HKEY_USERS". The only draw back being that it only gets the immediate subkey names. However with a little recursion we can get them all, the first code snippet is of the basic use of GetSubKeyNames().

//The first example shows it using a foreach loop to display each subkeyname
foreach
(string Keyname in OurKey.GetSubKeyNames())
{
MessageBox.Show(Keyname);
}
//The second example shows how to tranfer the names into a string array
string[] Keynames = OurKey.GetSubKeyNames();

In the next snippet of code we see how we can use recursion to obtain all the names of the subkeys.

private void GetSubKeys(RegistryKey SubKey)
{
foreach(string sub in SubKey.GetSubKeyNames())
{
MessageBox.Show(sub);
RegistryKey local = Registry.Users;
local = SubKey.OpenSubKey(sub,true);
GetSubKeys(local); // By recalling itself it makes sure it get all the subkey names
}
}

//This is how we call the recursive function GetSubKeys
RegistryKey OurKey = Registry.Users;
OurKey = OurKey.OpenSubKey(@".DEFAULT\test",true);
GetSubKeys(OurKey);

GetValue() / GetValuesNames()

These methods are also very important when you want to extract information form the registry, when you used the other methods to get to the subkey that you want you would like to extract the information from them. The first methods, GetValue allows you obtain the value held in a registry value by specifying its name, For example in our "test" subkey used earlier, i have a string (REG_SZ) value named "Testvalue" with the value "This is a test". To extract the value i would use the below code.

RegistryKey OurKey = Registry.Users;
OurKey = OurKey.OpenSubKey(@".DEFAULT\test",true);
MessageBox.Show(OurKey.GetValue("Testvalue").ToString());

As you will have noticed when we get information out of the registry we are always converting it using the ToString() method, this is because values and subkeys within the registry are classed as object and must therefore be converted, either via the ToString() method or by Casting.

As we have seen using the GetSubKeyNames() method we get the collection of names returned, this is also the case when we use the GetValueNames() methods. Using the code similar to the code used earlier we can obtain the names of the values, and also their values at the same time, as shown below.

RegistryKey OurKey = Registry.Users;
OurKey = OurKey.OpenSubKey(@".DEFAULT\test",true);

foreach(string valuename in OurKey.GetValueNames())
{
MessageBox.Show(valuename + " " + OurKey.GetValue(valuename).ToString());
}

SetValue()

The SetValue method does exactly what it says, it sets the value of a registry value, to use the function you supply the name of the value and what you want to set it to, if the value doesn't exist it creates it, simple as that, see the code below:

RegistryKey OurKey = Registry.Users;
OurKey = OurKey.OpenSubKey(@".DEFAULT\test",true);
OurKey.SetValue("Testvalue",0);

Using the SubKeyCount and Valuecount properties

You can use these two properties to obtain firstly of how many subkeys there directly below the specified key, and also the number of values under the specified key. to help understand we can look at the below code:

RegistryKey OurKey = Registry.Users;
OurKey = OurKey.OpenSubKey(@".DEFAULT\test",true);
MessageBox.Show(OurKey.SubKeyCount.ToString());
MessageBox.Show(OurKey.ValueCount.ToString());

Closing What we've worked on

I should also mention that when you have finished working and using a section of registry it makes good error free practice to close the key you have been using, this is done via the Close() method. See code below.

RegistryKey OurKey = Registry.Users;
OurKey.Close()

Unsupported Registry Functions
The .NET Framework supports a lot and in C# the RegistryKey class is very powerful and can be used well to manipulate the registry. Most of the Win32 APIs which we would have had to use previously have been built in however there are a few that are not, and this is where i refer to my Article "Advance Registry Work in C#". These are RegLoadKey() and RegUnloadKey(). These two calls allow you to load registry Hives into the registry and then manipulate them. As you will have seen in that article you need to declare these calls and you also need to gain relevant privileges to use them. API's Declared

[StructLayout(LayoutKind.Sequential)]
public struct LUID
{
public int LowPart;
public int HighPart;
}
[StructLayout(LayoutKind.Sequential)]
public struct TOKEN_PRIVILEGES
{
public LUID Luid;
public int Attributes;
public int PrivilegeCount;
}

[DllImport("advapi32.dll", CharSet=CharSet.Auto)]
public static extern int OpenProcessToken(int ProcessHandle, int DesiredAccess,
ref int tokenhandle);

[DllImport("kernel32.dll", CharSet=CharSet.Auto)]
public static extern int GetCurrentProcess();

[DllImport("advapi32.dll", CharSet=CharSet.Auto)]
public static extern int LookupPrivilegeValue(string lpsystemname, string lpname,
[MarshalAs(UnmanagedType.Struct)] ref LUID lpLuid);

[DllImport("advapi32.dll", CharSet=CharSet.Auto)]
public static extern int AdjustTokenPrivileges(int tokenhandle, int disableprivs,
[MarshalAs(UnmanagedType.Struct)]ref TOKEN_PRIVILEGES Newstate, int bufferlength,
int PreivousState, int Returnlength);

[DllImport("advapi32.dll", CharSet=CharSet.Auto, SetLastError=true)]
public static extern int RegLoadKey(uint hKey,string lpSubKey, string lpFile);

[DllImport("advapi32.dll", CharSet=CharSet.Auto, SetLastError=true)]
public static extern int RegUnLoadKey(uint hKey, string lpSubKey);

public const int TOKEN_ADJUST_PRIVILEGES = 0x00000020;
public const int TOKEN_QUERY = 0x00000008;
public const int SE_PRIVILEGE_ENABLED = 0x00000002;
public const string SE_RESTORE_NAME = "SeRestorePrivilege";
public const string SE_BACKUP_NAME = "SeBackupPrivilege";
public const uint HKEY_USERS = 0x80000003;
public string shortname;
bool unloaded = false;
API's Used
int token=0;
int retval=0;

TOKEN_PRIVILEGES TP = new TOKEN_PRIVILEGES();
TOKEN_PRIVILEGES TP2 = new TOKEN_PRIVILEGES();
LUID RestoreLuid = new LUID();
LUID BackupLuid = new LUID();

retval = OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, ref token);
retval = LookupPrivilegeValue(null, SE_RESTORE_NAME, ref RestoreLuid);
retval = LookupPrivilegeValue(null, SE_BACKUP_NAME, ref BackupLuid);
TP.PrivilegeCount = 1;
TP.Attributes = SE_PRIVILEGE_ENABLED;
TP.Luid = RestoreLuid;
TP2.PrivilegeCount = 1;
TP2.Attributes = SE_PRIVILEGE_ENABLED;
TP2.Luid = BackupLuid;

retval = AdjustTokenPrivileges(token, 0, ref TP, 1024, 0, 0);
retval = AdjustTokenPrivileges(token, 0, ref TP2, 1024, 0, 0);

// Loading a Hive "C:\NTUSER.DAT"

RegLoadKey(HKEY_USERS,"NTUSER.DAT",@"C:\NTUSER.DAT");)

// Unloading a Hive "C:\NTUSER.DAT"

RegUnLoadKey(HKEY_USERS,"NTUSER.DAT");

About the Author

My name is Michael Bright, I'm a university student studying a Bsc in Computer Science at University College Chester. I have a love for all thing computers and have only worked with C# for about 3 months. I am currently training for my MCP in it. My other interests are C, VB, HTML, ASP and also Flash. I have interests in Developing Network app's and Network Security. My Web site is csharp.brightweb.co.uk where you can find examples of my Work, including my Defender Security applications.

Friday, January 4, 2008

.NET and J2EE interoperability for .Net Developers

I like to share knowledge with my friends---"Vinay"

.NET and J2EE interoperability for .Net Developers

Introduction

In this paper we will compare J2EE and .Net technologies. We will explore the Interoperability scenarios and available options. Also, this paper is written for .Net developers, who are at advanced level of .Net knowledge and having no or minimum knowledge of J2EE.

Interoperability Overview

"Interoperability: The capability to communicate, execute programs, or transfer data among various functional units in a manner that requires the user to have little or no knowledge of the unique characteristics of those units."
—ISO/IEC 2382 Information Technology Vocabulary

Many Enterprises have been building based on mixed environments i.e. J2EE and/or .Net. If company sees a need of new application to their current enterprise, first thinking is to reuse and/or integrate the new application with existing applications and systems. Integrating systems with partners and suppliers is another increasing demand by businesses/enterprises, where security, performance and scalability come as standard requirements.

Migrating, rebuilding or replicating the functionality is not possible in most of cases. Even if we decide to migrate application(s) to other platform, most of the time migration has to be phased and integrated with other platform until complete system migration.

Interoperability allows the core systems to communicate with internal and external applications including partners and suppliers. Performance overhead, security and reduction in functionalities should be considered while designing solutions for interoperability.

In coming sections we will explore following topics:

  1. Interoperability Scenarios and technology mapping
  2. Interoperability Technologies
  3. J2EE for .Net Developers
  4. .Net and J2EE Feature Mapping
  5. Interoperability using XML
  6. Summary

Interoperability Scenarios and technology mapping

Following are the common Interoperability scenarios in an Enterprise:

  1. .Net Presentation Layer with J2EE Business Layer
  2. J2EE Presentation Layer with .Net Business Layer
  3. .Net Business Layer with J2EE Business Layer
  4. Sharing resources between .Net and J2EE

Note: Above are most common scenarios but not all, for instance there is also a possibility of .Net Presentation and J2EE Presentation layer interoperability.Please See “Interoperability Technologies” section for mapping between scenarios and technologies recommendation.

Following diagrams maps the layers and shows above interoperability scenarios:


.Net Presentation Layer with J2EE Business Layer





J2EE Presentation Layer with .Net Business Layer

Interoperability Technologies

There are multiple technologies for .Net and J2EE interoperability. Each technology has pros and cons. It also depends on your functional and/or non-functional requirements i.e. performance or scalability. Following are the technologies, which we can use for interoperability between J2EE and .Net:

  • XML Web Services
  • Runtime Bridges
  • Message Orientated Middleware
  • Shared Database
  • Integration Brokers

*Please note following is a high level overview of each technology from interoperability point of view. For more information please use appropriate resources.

XML web services have been matured by the time and are supported by both J2EE and .Net. Web services provide an interface for communicating with other applications and systems. However, web services hide the method level implementation, therefore applications can only communicate through defined interfaces and contracts. Web service is a good choice for Presentation to Business, Business to Business and Business to Data interoperability.

Using XML web services, you cannot call a class method or access J2EE classes from .Net or vice-versa. Runtime Bridges provides the ability to access classes from one platform to another. Runtime Bridges are developed by 3rd parties, JNBridgePro and Ja.Net are most prominent in the market. Runtime Bridges allows you to use .Net Remoting to handle classes at Java side.

Messaging and Share databases provide asynchronous communication mechanism. Messaging is based on MSMQ and IBM MQSeries and both supports security, message recording and transactions. Using the share database technique, one common database (SQL Server or Oracle etc.) is being accessed by .Net and J2EE applications. .Net application uses ODBC and J2EE application uses JDBC.

Integration Brokers are typically built on messaging framework that provides the integration and automation between business processes across distributed applications and Enterprise. Integration brokers are a good answer for integration of partners and suppliers. BizTalk Server, CommerceBroker and IBM MQSeries are the most well-known integration brokers in the market.

Following table shows the mapping between interpretability scenarios and technologies. These recommendations are from Microsoft and could differ to your problem and solution.


Web Services

Runtime Bridges

Messaging

Share Databases

Integration Brokers

Presentation to Presentation


X


X


Presentation to Business

X

X

X



Business to Business

X

X

X


X

Business to Data

X



X

X

J2EE Overview for .Net Developers

Unlike Microsoft .NET, Java 2 Platform, Enterprise Edition or J2EE is a set of linked specification but not a product. These specifications consist of a series of downloadable .PDF files that describe application agreements and the makeup of the containers in which these applications run.

Sun Microsystems developed Java as platform and a programming language.
There are currently three editions of the Java platform:

  • J2SE (Java 2 Standard Edition)
  • J2EE (Java 2 Enterprise Edition)
  • J2ME (Java 2 Micro Edition)

Note: The term “Java” mostly refers to functionality available within J2SE. Areas that require the Enterprise Edition include the term J2EE.

For more information about J2EE history please visit http://en.wikipedia.org/wiki/Java_Platform,_Enterprise_Edition#History

As mentioned before J2EE is a series of specification but platform unlike .Net. There are other differences between J2EE and .Net, which should also be understood. Differences can be categorized in three main areas:

  1. Operating System
  2. Language Support
  3. Execution Process or Technique

As we know, .Net can run only on Windows platform but Java was designed to run on multiple platforms i.e. Windows, UNIX, Linux, MacOS and BeOS.

We can write applications in Java using Java Programming Language only but in .Net you can write applications in any language, which is supported by .Net.

There is also a major difference between the two platforms at application run time. When you build a project based on a .NET language, the output consists of MSIL code that the JIT compiler compiles at runtime. To deploy a Java program, you compile the application to create Java bytecode. The JVM running on the target operating system then interprets this bytecode to produce the relevant instructions.

Note: There are also Java JIT compilers that work in a similar fashion to the .NET Framework component.

Some of the vendors have created their own implementations of J2EE specification, which were built by Sun Microsystems. Following vendors implemented these specifications:

  • Sun (Sun ONE Application Server)
  • IBM (WebSphere)
  • BEA (WebLogic)
  • JBoss (Open source implementation) http://www.jboss.org/

J2EE also includes additional components, which were evolved over the past decade:

  • Java Server Pages (JSPs)
  • Server side APIs or servlets
  • Enterprise Java Beans (EJBs)
  • Java Naming and Directory Interface (JNDI)
  • Java Message Service (JMS)
  • Java API for XML-based RPC (JAX-RPC)
  • J2EE Connector Architecture
  • J2EE Management Model
  • J2EE Deployment API
  • Java Management Extensions (JMX)
  • J2EE Authorization Contract for Containers
  • Java API for XML Registries (JAXR)
  • Java Transaction API (JTA)
  • Common Object Request Broker Architecture (CORBA)
  • JDBC data access API

You can map few components in .Net e.g.,JMS is equivalent to System.Messaging namespace.

.Net and J2EE Feature Mapping

Following table helps to understand the comparison of J2EE and .Net features.

Feature

J2EE

.NET

Type of technology

Standard

Product

Middleware Vendors

30+

Microsoft

Interpreter

JRE

CLR

Dynamic Web Pages

JSP

ASP.NET

Middle-Tier/Server Side Components

EJB

.NET Managed Components

Database access

JDBC SQL/J

ADO.NET

SOAP, WSDL, UDDI

Yes

Yes

Implicit middleware
(load-balancing, etc)

Yes

Yes

Web Apps Hosting

Multiple (depends on vendor implementation)

Internet Information Server

Directory Access

Java Naming and Directory Service (JNDI) through LDAP

Active Directory Services Interface (ADSI) through LDAP

Remote Invocation

RMI-IIOP

.NET Remoting

Messaging

JMS

Microsoft Message Queuing

Transactional Support

JTA

COM+/Distributed Transaction Controller (DTC)

Summary

It is not possible or appropriate for Enterprises to build systems based on only J2EE or .Net technologies. Some organizations have already built their core systems using J2EE or .Net platform and interoperability is an ongoing requirement for enterprises. There are different types of Interoperability i.e. Presentation to Business or Business to Business layers and there are multiple recommended technologies to these interoperability types. In past decade SOA and Enterprise Service Bus have become prominent and mature in Enterprises .These techniques will provide more scalable and extendable architectures, which makes interoperability much easy and seamless.