Welcome!

Weblogic Authors: Yeshim Deniz, Elizabeth White, Michael Meiner, Michael Bushong, Avi Rosenthal

Related Topics: Weblogic

Weblogic: Article

Integrating an ASP.NET Application with J2EE PART 2

Platform interoperability

To view the images, the process is also pretty straightforward. The WebLogic Web Service opens the file based on the file name passed as a parameter. The Web Service then gets the binary data from the file and returns it via a binary data type. The ASP.NET client code calls the Web Service, sets the content type for the Web page (via Response.ContentType) based on the file extension and then sends the binary stream via the Response.BinaryWrite method. The WebLogic code is shown in Listing 8 while the ASP.NET code is shown in Listing 9.

Application Navigation and Workflow
One of the areas in which many Web applications are difficult to maintain is application workflow. I define application workflow as the way in which applications validate data and handle navigation. One of the common issues we've seen in ASP and ASP.NET applications is that there's a lot of page navigation logic buried inside code - behind pages or ASP scripts - and changing the location of the name of a Web page causes broken links in the application. J2EE applications commonly take advantage of an open source framework called "Struts." Struts provides a number of useful features:

  • Struts abstracts page navigation into XML configuration files. Pages are referenced by name rather than URL so that URLs can be easily changed in the XML configuration file.
  • Struts encourages development using a MVC (Model-View-Controller) architecture.
  • Struts abstracts HTTP response data into separate classes ("ActionForm" classes) that are simple classes with attributes that match the response parameters and accessor/mutator (get/set) methods.
  • Struts provides a main controller class (servlet) to which every page will submit. The controller class abstracts the HTTP response data into ActionForm classes, delegates control to a business class (Action class) that applies complex validations, and determines the next page to access.
Having built a few successful J2EE applications, we wanted to capture the best elements of the Struts framework for our ASP.NET application. Some Struts features are already built into ASP.NET. For example, ASP.NET provides a number of validation controls (RequiredFieldValidator, CompareValidator, RangeValidator, RegularExpressionValidator, and CustomValidator) that assist in validating form on an ASP.NET page. Struts also provides page validation framework support and a validation summary control type.

While Struts offers a central controller to which all pages must submit, ASP.NET offers a different model in which pages submit back to themselves. This enables the event-driven programming model and page state (ViewState) features in ASP.NET. The two architectures are quite different. After taking a look at the options, we felt that developing a central controller similar to Struts would take a great deal of effort and the result would be a less optimal architecture. So we decided not to develop a central controller like Struts.

Several benefits of Struts are predicated on the submission of each Web page to a main controller class and wouldn't work well in an ASP.NET environment. Specifically, the abstraction of HTTP request data into separate classes and the delegation to a business processing and validation class were dependent on the submission to a main controller class. Besides, delegation to a business processing class was something we were already doing in an ASP.NET environment. One of the features of Struts that we felt we could adapt relatively easily that didn't rely on the submission of each Web page to a main controller class was the abstract page navigation available in Struts.

Abstracting Page Navigation
When developing an application under Struts, a developer defines an XML configuration file that indicates absolute URL addresses for Web pages and assigns a logical name for the page. In an ASP.NET application, the logical name "LoginPage" can be assigned to "http://myserver/myapplication/Login.aspx." Developers can code Response.Redirect statements and URL links using the logical name rather than the absolute URL address. Should the page name or location have to change in the future, a simple change to the XML configuration file is all that's needed. For example, the code to redirect to the login page would be:

Response.Redirect(getPageURL(Page.Login));

To implement this concept in ASP.NET, we implemented a class called "NavigationController." It would read and cache the page name and URL information stored in an XML configuration file (NavigationConfig.xml), offer helper methods to return the absolute page URL when passed the logical name, and provide generic methods to redirect forward and backward in the application.

The example application provides a simple example of using the NavigationController. The page navigation information is stored in the NavigationConfig.xml file:


<?xml version="1.0" encoding="utf-8" ?>
<!--The order of items determine the sequence in which they appear in the module -->
<MyApplication>
<MyModule>
<Page Name="Page1" Url="~/Navigation/Page1.aspx"/>
<Page Name="Page2" Url="~/Navigation/Page2.aspx"/>
<Page Name="Page3" Url="~/Navigation/Page3.aspx"/>
<Page Name="Page4" Url="~/Navigation/Page4.aspx"/>
</MyModule>
</MyApplication>
The NavigationController class reads the NavigationConfig.xml file and builds a collection of PageConfiguration objects. Each PageConfiguration object contains the navigation information for a page. A Hashtable collection of PageConfiguration objects is built and the Hashtable collection is stored in the ASP.NET Application object.

There are four pages, Pages 1-4, all with back and next buttons. The back button executes the RedirectBack method in the NavigationController class. The next button executes the RedirectForward method in the NavigationController class.

The code for the RedirectForward method is shown in Listing 10.

The current page for the application is stored in the ASP.NET Session object for each user. This is set to the first page of the application ("Page1") via code in the Page_Load method of the Page1.cs.aspx. Each page has a PageConfiguration object stored in the Hashtable. The PageConfiguration object is aware of the current page, the previous, and next pages in the application navigation flow. If the next page is valid, the URL for the page is obtained and the NavigationController class redirects the application to the next page.

Listing 11 contains the entire code from the NavigationController class and the PageConfiguration class.

The NavigationController class in its current incarnation works well for a simple wizard-based application in which the navigation is relatively simple. To support more complex navigation, you'd need additional processing to delegate to a business class that provides complex validations, performs business calculations, and determines the next page that the application should navigate to based on business rules.

See Sidebar "Article Information Box".

Summary
In this article I have discussed the integration of an ASP.NET client with a J2EE (WebLogic) middle-tier using Web Services. I discussed some of the issues that arise in this type of hybrid environment and how we addressed them. The application we developed using the technologies and techniques discussed here is now in production and the general feedback from the developers, the client, and users is very positive. I hope you found this article useful and, as always, I would love to hear from other developers and architects with ideas and suggestions based on their experiences.

More Stories By Blair Taylor

Blair Taylor is president of JustWebSolutions.com, a Canadian company specializing in the architecture and development of distributed systems. Blair has authored several publications covering client-server and distributed technologies and is certified in both Java and .NET technologies. Blair can be reached via e-mail at [email protected] or at www.justwebsolutions.com.

Comments (1) View Comments

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


Most Recent Comments
mo 06/28/05 03:43:02 AM EDT

Good article.
I completely support the article approach when dealing with simple text based services. Web services is a satisfying solution . Unfortunately , I believe that binary data shouldn't be handled using Web services. It's just not up to it and the writer have proved it when dealing with .NET exceptions. There are better solutions for such cases. I can think of at least one solution that converts .NET binary into pure Java binary: http://dev.mainsoft.com/ but I'm sure there are more.

IoT & Smart Cities Stories
The challenges of aggregating data from consumer-oriented devices, such as wearable technologies and smart thermostats, are fairly well-understood. However, there are a new set of challenges for IoT devices that generate megabytes or gigabytes of data per second. Certainly, the infrastructure will have to change, as those volumes of data will likely overwhelm the available bandwidth for aggregating the data into a central repository. Ochandarena discusses a whole new way to think about your next...
DXWorldEXPO LLC announced today that Big Data Federation to Exhibit at the 22nd International CloudEXPO, colocated with DevOpsSUMMIT and DXWorldEXPO, November 12-13, 2018 in New York City. Big Data Federation, Inc. develops and applies artificial intelligence to predict financial and economic events that matter. The company uncovers patterns and precise drivers of performance and outcomes with the aid of machine-learning algorithms, big data, and fundamental analysis. Their products are deployed...
Dynatrace is an application performance management software company with products for the information technology departments and digital business owners of medium and large businesses. Building the Future of Monitoring with Artificial Intelligence. Today we can collect lots and lots of performance data. We build beautiful dashboards and even have fancy query languages to access and transform the data. Still performance data is a secret language only a couple of people understand. The more busine...
All in Mobile is a place where we continually maximize their impact by fostering understanding, empathy, insights, creativity and joy. They believe that a truly useful and desirable mobile app doesn't need the brightest idea or the most advanced technology. A great product begins with understanding people. It's easy to think that customers will love your app, but can you justify it? They make sure your final app is something that users truly want and need. The only way to do this is by ...
CloudEXPO | DevOpsSUMMIT | DXWorldEXPO are the world's most influential, independent events where Cloud Computing was coined and where technology buyers and vendors meet to experience and discuss the big picture of Digital Transformation and all of the strategies, tactics, and tools they need to realize their goals. Sponsors of DXWorldEXPO | CloudEXPO benefit from unmatched branding, profile building and lead generation opportunities.
Digital Transformation and Disruption, Amazon Style - What You Can Learn. Chris Kocher is a co-founder of Grey Heron, a management and strategic marketing consulting firm. He has 25+ years in both strategic and hands-on operating experience helping executives and investors build revenues and shareholder value. He has consulted with over 130 companies on innovating with new business models, product strategies and monetization. Chris has held management positions at HP and Symantec in addition to ...
Cell networks have the advantage of long-range communications, reaching an estimated 90% of the world. But cell networks such as 2G, 3G and LTE consume lots of power and were designed for connecting people. They are not optimized for low- or battery-powered devices or for IoT applications with infrequently transmitted data. Cell IoT modules that support narrow-band IoT and 4G cell networks will enable cell connectivity, device management, and app enablement for low-power wide-area network IoT. B...
The hierarchical architecture that distributes "compute" within the network specially at the edge can enable new services by harnessing emerging technologies. But Edge-Compute comes at increased cost that needs to be managed and potentially augmented by creative architecture solutions as there will always a catching-up with the capacity demands. Processing power in smartphones has enhanced YoY and there is increasingly spare compute capacity that can be potentially pooled. Uber has successfully ...
SYS-CON Events announced today that CrowdReviews.com has been named “Media Sponsor” of SYS-CON's 22nd International Cloud Expo, which will take place on June 5–7, 2018, at the Javits Center in New York City, NY. CrowdReviews.com is a transparent online platform for determining which products and services are the best based on the opinion of the crowd. The crowd consists of Internet users that have experienced products and services first-hand and have an interest in letting other potential buye...
When talking IoT we often focus on the devices, the sensors, the hardware itself. The new smart appliances, the new smart or self-driving cars (which are amalgamations of many ‘things'). When we are looking at the world of IoT, we should take a step back, look at the big picture. What value are these devices providing. IoT is not about the devices, its about the data consumed and generated. The devices are tools, mechanisms, conduits. This paper discusses the considerations when dealing with the...