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)

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.


IoT & Smart Cities Stories
René Bostic is the Technical VP of the IBM Cloud Unit in North America. Enjoying her career with IBM during the modern millennial technological era, she is an expert in cloud computing, DevOps and emerging cloud technologies such as Blockchain. Her strengths and core competencies include a proven record of accomplishments in consensus building at all levels to assess, plan, and implement enterprise and cloud computing solutions. René is a member of the Society of Women Engineers (SWE) and a m...
Andrew Keys is Co-Founder of ConsenSys Enterprise. He comes to ConsenSys Enterprise with capital markets, technology and entrepreneurial experience. Previously, he worked for UBS investment bank in equities analysis. Later, he was responsible for the creation and distribution of life settlement products to hedge funds and investment banks. After, he co-founded a revenue cycle management company where he learned about Bitcoin and eventually Ethereal. Andrew's role at ConsenSys Enterprise is a mul...
In his general session at 19th Cloud Expo, Manish Dixit, VP of Product and Engineering at Dice, discussed how Dice leverages data insights and tools to help both tech professionals and recruiters better understand how skills relate to each other and which skills are in high demand using interactive visualizations and salary indicator tools to maximize earning potential. Manish Dixit is VP of Product and Engineering at Dice. As the leader of the Product, Engineering and Data Sciences team at D...
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...
Nicolas Fierro is CEO of MIMIR Blockchain Solutions. He is a programmer, technologist, and operations dev who has worked with Ethereum and blockchain since 2014. His knowledge in blockchain dates to when he performed dev ops services to the Ethereum Foundation as one the privileged few developers to work with the original core team in Switzerland.
Whenever a new technology hits the high points of hype, everyone starts talking about it like it will solve all their business problems. Blockchain is one of those technologies. According to Gartner's latest report on the hype cycle of emerging technologies, blockchain has just passed the peak of their hype cycle curve. If you read the news articles about it, one would think it has taken over the technology world. No disruptive technology is without its challenges and potential impediments t...
If a machine can invent, does this mean the end of the patent system as we know it? The patent system, both in the US and Europe, allows companies to protect their inventions and helps foster innovation. However, Artificial Intelligence (AI) could be set to disrupt the patent system as we know it. This talk will examine how AI may change the patent landscape in the years to come. Furthermore, ways in which companies can best protect their AI related inventions will be examined from both a US and...
Bill Schmarzo, Tech Chair of "Big Data | Analytics" of upcoming CloudEXPO | DXWorldEXPO New York (November 12-13, 2018, New York City) today announced the outline and schedule of the track. "The track has been designed in experience/degree order," said Schmarzo. "So, that folks who attend the entire track can leave the conference with some of the skills necessary to get their work done when they get back to their offices. It actually ties back to some work that I'm doing at the University of San...
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...
Bill Schmarzo, author of "Big Data: Understanding How Data Powers Big Business" and "Big Data MBA: Driving Business Strategies with Data Science," is responsible for setting the strategy and defining the Big Data service offerings and capabilities for EMC Global Services Big Data Practice. As the CTO for the Big Data Practice, he is responsible for working with organizations to help them identify where and how to start their big data journeys. He's written several white papers, is an avid blogge...