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

In Part 1 of this two-part article I discussed interoperability between .NET and Weblogic 8.1 and issues that arise when transferring data between Web serivces. In Part 2 I will cover some advanced issues: SOAP exception handling, uploading binary information via Web services, and application navigation and workflow.

SOAP Exception Handling
In non-Web Services environments, we're used to building a hierarchy of exceptions and throwing the appropriate exception to indicate the correct feedback to the client. For example, we can define an application exception called "UserNotLoggedInException" (that extends System.ApplicationException) to indicate to the caller that the application has failed because the user isn't logged into the application properly. When the calling method catches this exception, it's aware of the type of error that's occurred.

Exception handling in Web Services differs from the structured exception handling offered in Java or C#, where a developer puts code that can cause an exception in a try/catch clause. Exceptions are caught in the catch clause or bubble up to the calling method if not handled in one of the catch clauses. When an exception is thrown to a calling method, the method understands the data type of the exception and can deal with it accordingly.

With Web Services, exception handling gets a bit more complicated. All exceptions thrown in a Web Service are wrapped by .NET (or WebLogic) as a SoapException. A SoapException generates a SoapResponse that replaces the body of the SOAP message with a SoapFault element. A SoapFault is an XML element that contains elements with information indicating the SoapFault type, an error number, an error message, and an error source. The SoapFault also indicates a URI, which is usually the method that generated the exception. Table 1 displays the layout of a SoapFault. The SoapFault element provides information to the calling method about the exception that occurred.

.NET wraps native exceptions in a SoapException because the Web Service client doesn't understand the native type of the exceptions that occurred in the Web Service. In the last example, a client application calling a Web Service that threw a UserNotLoggedInException exception wouldn't understand this exception class and wouldn't know how to handle it properly. So a Web Service client will always need to handle a SoapException and may need to process the exception further to determine the root of the problem.

The faultcode element is usually set to either "client" or "server." The faultcode is the mechanism that a Web Service can use to indicate to the caller if the source of the error was a server error or a client error. For example, if the application wasn't able to connect to the database, the SoapFault should indicate a (namespace qualified) faultcode element of "server." It indicates that the server encountered an error and the error wasn't dependent on client input. In this case, you would log the error on the server, and return an incident number to the client. The client would display a generic user-friendly error page that indicates to the user that an error occurred and provide an incident number to contact the help desk. The help desk could then review the incident details and attempt to diagnose the problem.

When an error occurs that's dependant on client input, additional processing has to occur. An example of this occurs when the client attempts to access a resource when they are not logged in. In this case, it doesn't make sense to display a generic user-friendly error page; we'd like to let the user know the cause of the error so he can correct the situation. In this case, we would like to redirect the user to a login page so he can be authenticated. A similar (and more likely) scenario occurs when a user attempts to violate a foreign key relationship. For example, a user may try to delete a client who has orders. In this case, we'd like to notify the client via a message that the client can't be deleted because they have dependant data (orders). In both cases, we need to provide additional processing.

To provide additional information to the Web Services client, we generate and throw a SoapException and set the SOAP fault type to "client." This overrides the generation of a default SoapException by .NET (or WebLogic) and returns our custom SoapException. By setting the faultcode to "client," we notify the caller that the error was caused by client input or action.

The SOAP specification indicates that a SoapFault contains a "details" element. The contents of the details element are left open to the developer to define the error information they'd like to communicate to the client. The first step is to define an XML schema to declare the structure of the SoapFault detail element. This is the contract between the Web Service and client that indicates the data that will be passed when a custom SoapException is thrown.

When an exception occurs, we want to pass a message to display to the client. We also want to pass the server exception message and a stack trace to log for assistance in diagnosing the production problems. Listing 1 shows the XML schema we defined to pass this information via a custom SoapException. Listing 2 shows the SoapException XML generated.

In our sample application, we throw a custom SoapException from a WebLogic Web Service, catch, and process it in an ASP.NET application. The throwClientSoapException method throws a custom exception. The code for the throwClientSoapException method is shown in Listing 3.

The code calls the buildSoapFaultException method in the SOAPUtil class. This is a static helper method that builds the custom SoapException (see Listing 4).

The SOAP_NAMESPACE is defined as a Java constant:


public static final String SOAP_NAMESPACE =
"http://www.justwebsolutions.com/articles";
The ASP.NET client code catches the SoapException and then creates a DataSet, and uses the SoapExceptionDetail.xsd schema we defined to read the XML schema into the DataSet (via the ReadXmlSchema method).

//Get SoapExceptionDetail.xsd full path
string schemaRelativePath = "../schemas/SoapExceptionDetail.xsd";
string schemaFullPath =
HttpContext.Current.Server.MapPath(schemaRelativePath);

//Read the Schema into the DataSet
dsError.ReadXmlSchema(schemaFullPath);

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.

@ThingsExpo Stories
The current age of digital transformation means that IT organizations must adapt their toolset to cover all digital experiences, beyond just the end users’. Today’s businesses can no longer focus solely on the digital interactions they manage with employees or customers; they must now contend with non-traditional factors. Whether it's the power of brand to make or break a company, the need to monitor across all locations 24/7, or the ability to proactively resolve issues, companies must adapt to...
"We view the cloud not as a specific technology but as a way of doing business and that way of doing business is transforming the way software, infrastructure and services are being delivered to business," explained Matthew Rosen, CEO and Director at Fusion, in this SYS-CON.tv interview at 18th Cloud Expo (http://www.CloudComputingExpo.com), held June 7-9 at the Javits Center in New York City, NY.
DXWorldEXPO LLC announced today that the upcoming DXWorldEXPO | CloudEXPO New York event will feature 10 companies from Poland to participate at the "Poland Digital Transformation Pavilion" on November 12-13, 2018.
As data explodes in quantity, importance and from new sources, the need for managing and protecting data residing across physical, virtual, and cloud environments grow with it. Managing data includes protecting it, indexing and classifying it for true, long-term management, compliance and E-Discovery. Commvault can ensure this with a single pane of glass solution – whether in a private cloud, a Service Provider delivered public cloud or a hybrid cloud environment – across the heterogeneous enter...
DXWorldEXPO LLC announced today that ICC-USA, a computer systems integrator and server manufacturing company focused on developing products and product appliances, will exhibit at the 22nd International CloudEXPO | DXWorldEXPO. DXWordEXPO New York 2018, colocated with CloudEXPO New York 2018 will be held November 11-13, 2018, in New York City. ICC is a computer systems integrator and server manufacturing company focused on developing products and product appliances to meet a wide range of ...
More and more brands have jumped on the IoT bandwagon. We have an excess of wearables – activity trackers, smartwatches, smart glasses and sneakers, and more that track seemingly endless datapoints. However, most consumers have no idea what “IoT” means. Creating more wearables that track data shouldn't be the aim of brands; delivering meaningful, tangible relevance to their users should be. We're in a period in which the IoT pendulum is still swinging. Initially, it swung toward "smart for smart...
Major trends and emerging technologies – from virtual reality and IoT, to Big Data and algorithms – are helping organizations innovate in the digital era. However, to create real business value, IT must think beyond the ‘what’ of digital transformation to the ‘how’ to harness emerging trends, innovation and disruption. Architecture is the key that underpins and ties all these efforts together. In the digital age, it’s important to invest in architecture, extend the enterprise footprint to the cl...
Headquartered in Plainsboro, NJ, Synametrics Technologies has provided IT professionals and computer systems developers since 1997. Based on the success of their initial product offerings (WinSQL and DeltaCopy), the company continues to create and hone innovative products that help its customers get more from their computer applications, databases and infrastructure. To date, over one million users around the world have chosen Synametrics solutions to help power their accelerated business or per...
Coca-Cola’s Google powered digital signage system lays the groundwork for a more valuable connection between Coke and its customers. Digital signs pair software with high-resolution displays so that a message can be changed instantly based on what the operator wants to communicate or sell. In their Day 3 Keynote at 21st Cloud Expo, Greg Chambers, Global Group Director, Digital Innovation, Coca-Cola, and Vidya Nagarajan, a Senior Product Manager at Google, discussed how from store operations and ...
Dion Hinchcliffe is an internationally recognized digital expert, bestselling book author, frequent keynote speaker, analyst, futurist, and transformation expert based in Washington, DC. He is currently Chief Strategy Officer at the industry-leading digital strategy and online community solutions firm, 7Summits.
We are seeing a major migration of enterprises applications to the cloud. As cloud and business use of real time applications accelerate, legacy networks are no longer able to architecturally support cloud adoption and deliver the performance and security required by highly distributed enterprises. These outdated solutions have become more costly and complicated to implement, install, manage, and maintain.SD-WAN offers unlimited capabilities for accessing the benefits of the cloud and Internet. ...
In an era of historic innovation fueled by unprecedented access to data and technology, the low cost and risk of entering new markets has leveled the playing field for business. Today, any ambitious innovator can easily introduce a new application or product that can reinvent business models and transform the client experience. In their Day 2 Keynote at 19th Cloud Expo, Mercer Rowe, IBM Vice President of Strategic Alliances, and Raejeanne Skillern, Intel Vice President of Data Center Group and ...
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...
Founded in 2000, Chetu Inc. is a global provider of customized software development solutions and IT staff augmentation services for software technology providers. By providing clients with unparalleled niche technology expertise and industry experience, Chetu has become the premiere long-term, back-end software development partner for start-ups, SMBs, and Fortune 500 companies. Chetu is headquartered in Plantation, Florida, with thirteen offices throughout the U.S. and abroad.
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...
From 2013, NTT Communications has been providing cPaaS service, SkyWay. Its customer’s expectations for leveraging WebRTC technology are not only typical real-time communication use cases such as Web conference, remote education, but also IoT use cases such as remote camera monitoring, smart-glass, and robotic. Because of this, NTT Communications has numerous IoT business use-cases that its customers are developing on top of PaaS. WebRTC will lead IoT businesses to be more innovative and address...
Charles Araujo is an industry analyst, internationally recognized authority on the Digital Enterprise and author of The Quantum Age of IT: Why Everything You Know About IT is About to Change. As Principal Analyst with Intellyx, he writes, speaks and advises organizations on how to navigate through this time of disruption. He is also the founder of The Institute for Digital Transformation and a sought after keynote speaker. He has been a regular contributor to both InformationWeek and CIO Insight...
Gemini is Yahoo’s native and search advertising platform. To ensure the quality of a complex distributed system that spans multiple products and components and across various desktop websites and mobile app and web experiences – both Yahoo owned and operated and third-party syndication (supply), with complex interaction with more than a billion users and numerous advertisers globally (demand) – it becomes imperative to automate a set of end-to-end tests 24x7 to detect bugs and regression. In th...
Michael Maximilien, better known as max or Dr. Max, is a computer scientist with IBM. At IBM Research Triangle Park, he was a principal engineer for the worldwide industry point-of-sale standard: JavaPOS. At IBM Research, some highlights include pioneering research on semantic Web services, mashups, and cloud computing, and platform-as-a-service. He joined the IBM Cloud Labs in 2014 and works closely with Pivotal Inc., to help make the Cloud Found the best PaaS.
Cloud-enabled transformation has evolved from cost saving measure to business innovation strategy -- one that combines the cloud with cognitive capabilities to drive market disruption. Learn how you can achieve the insight and agility you need to gain a competitive advantage. Industry-acclaimed CTO and cloud expert, Shankar Kalyana presents. Only the most exceptional IBMers are appointed with the rare distinction of IBM Fellow, the highest technical honor in the company. Shankar has also receive...