Welcome!

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

Related Topics: Weblogic

Weblogic: Article

WebLogic & .NET: Making Web services that work

WebLogic & .NET: Making Web services that work

As a developer for a company selling application services to Fortune 500 companies, I was excited about the release of WebLogic 6.1. While its support of J2EE 1.3 features in and of itself is a reason to upgrade or adopt this product, the introduction of SOAP/WSDL-based Web services technology is a significant step forward for an already great application server. What I found interesting about BEA's approach is how relatively simple it is to tap the power of this new infrastructure. For RPC (synchronous-style) services it is a straightforward two-step process.

First, create a stateless session EJB that implements the application logic. The only catch here is to design the interface method signatures in such a way that only simple objects are passed. Think of these objects as complex types that expose no behavior other than get/set functionality to manipulate properties (as per the JavaBeans spec). Arrays of complex types and nesting of complex types are also supported. The key design principle is to keep the approach simple and drive behavior into the service itself. If heterogeneity is a design goal, then don't think of Web services as an object serialization technique but rather as a way of exposing business-event functionality.

Second, use the wsgen Ant task to create the enterprise archive .ear file. WebLogic bundles this task as well as Ant version 1.3 with the WLS product distribution. The product documentation provides a detailed description of exactly how to accomplish this. My build.xml scripts include the following snippet:

<target name="webservice" depends="init">
<wsgen destpath="/xylo/dev/${beanname}.ear" con
text="/${beanname}" protocol="http">
<rpcservices
path="${jardest}/ejb_${beanname}.jar">
<rpcservice bean="${beanname}"
uri="/${beanname}"/>
</rpcservices>
</wsgen>
</target>

This defines a new target called webservice. It depends upon a target called init, which by convention defines environment variables and parameters. All of my scripts define the beanname variable that's used in various ways to name the necessary files. This target will create and deploy the .ear file within a running WLS instance. That's all there is to it! WLS 6.1 implements a conservative subset of SOAP and WSDL in a very simple way. It leverages the framework already established by EJB and provides the developer with a mechanism for exposing existing EJB components as Web services without any additional Java coding.

Bumps in the Road Are Inevitable in Any Journey

I was working on a project that required that .NET clients be able to call WLS-deployed services. My code worked well when my method signatures used native types (as defined by XML Schema) as a parameter or return value. Unfortunately, complex types or arrays of any type were another matter entirely. This is an unacceptable limitation in the face of real-world requirements. I turned to the WLS documentation looking for insight and saw a note stating that WLS 6.1 supports version 2.0 SP2 of Microsoft's SOAP Toolkit. As a key player on the W3C XML committees, Microsoft decided to adopt the 2001 XML Schema (XSD) specification in its .NET Framework. The SOAP Toolkit is based on the 1999 recommendation, as is WLS 6.1

It's ironic that there's a need for this article, considering that Web services are being touted as the interoperability panacea. In all fairness, the issues addressed arise because newer technologies forming the foundation for emerging protocols such as SOAP and WSDL are still evolving. Understandably, application server vendors must provide infrastructure components that are stable and reliable. These needs must override the desire to support the latest and greatest industry specifications. Undaunted, I decided to dig down deeper into the interoperability issues in the belief that these problems are solvable, given the simplicity and elegance of XML-based Web services technology.

Interoperability Issues

This article outlines the XML-related interoperability issues a developer must face, given the current state of WLS and .NET. They can be categorized into two areas of concern pertinent to WSDL and SOAP, respectively. WSDL (Web Services Description Language) seems like a logical place to begin since before a newly created Web service can be invoked, it must be bound to the calling process.

WSDL Stack Interoperability Issues

When a WLS Web service is deployed, a public-facing Web page (JSP) is made accessible. This page contains two links: the first generates the WSDL file that describes the service, and the second allows for the downloading of a file called client.jar by convention. This .jar file contains the client-side proxy class, SOAP codecs, and some fairly lightweight infrastructure classes provided by BEA to simplify the consumption of services. This is the only .jar file needed in the CLASSPATH, other than client application-related code. For Java-based clients the WSDL is extraneous and is useful only for UDDI registries. For non-Java clients, the opposite is true.

Considering the problem, I knew that the first step in consuming the service was to create the necessary client-side proxy with C# code (although VB.NET would be an equally viable alternative). As a Java programmer with a C/C++ background, I felt comfortable with C# almost immediately, which drove my choice of languages. After downloading and installing the ASP.NET package, I immediately learned that Microsoft's approach to Web services involves the compilation of the WSDL to generate the proxy code. This can be accessed via the command-line utility WSDL.EXE or by using Visual Studio .NET. These tools are HTTP-enabled and can retrieve and compile the WSDL in one step. The WSDL compiler generates a source file with a .cs extension named by the name attribute of the service XML element in the WSDL file. This file is then compiled into a .dll. The service is called from the client code by instantiating the generated proxy class and invoking its methods as if they were local to the client process. In my case, the WSDL document created by WLS wouldn't compile correctly with the .NET-provided compiler.

The Web service I created and deployed on WLS is called PresentationController and has one method, named dispatchAction. This method takes five parameters. The first four are simple string types and the last is an array of NameValuePair JavaBean instances specific to my application code. The WSDL file generated by WLS is shown in Listing 1 . Notice the description element at the top of the document. The namespace attribute references the 1999 XSD spec. This is the first of three changes that must be made to the WSDL to bring it up to 2001 compatibility. Because my code utilizes the NameValuePair JavaBean, the WSDL contains an embedded XSD schema enclosed with a schema element. This element contains standard XSD definitions of any complex types that are referenced by the service described. The 1999 XSD specification allowed members of a complex type to be specified using attribute elements, while the 2001 spec uses element elements (confusing, eh?). Also, the 2001 spec mandates that all members of the complex type be enclosed within a sequence element to preserve order occurrence. The modified and MS-compatible WSDL file is shown in Listing 2. I wrote a simple tool that parses the WSDL file as an XML DOM, makes the changes I've previously described, and generates the converted document. The code for this utility is in Listing 3. A slicker approach would be to create a chained servlet that does the conversion on the fly without intermediary files. This exercise is left to the reader.

SOAP Stack Interoperability Issues
The next category of interoperability issues revolves around the SOAP messages sent from client to server. As with WSDL, the .NET platform SOAP messages conform to XSD-2001. For the most part these messages are backward-compatible with the WLS FastParser. The showstopper is in the SOAP ArrayType encoding for arrays passed from the client. This is a problem with arrays of native types as well. According to the WLS release notes, there is a known issue, #055596: "WLS Web services do not support SOAP 1.1 multireference compound data types." Again, no workaround is given. XSD-2001 provides a slick optimization technique that allows a node to be referenced in multiple places. For large arrays this can greatly reduce the size of the message, thus conserving bandwidth and shortening parse times. Similar to the WSDL converter, what is needed is a mechanism to filter SOAP interactions.

The Microsoft .NET Framework provides an API for intercepting and altering the SOAP XML payload. It is called SOAP Extensions and can be utilized in client-side proxies as well as .NET-hosted services. Listing 4 contains the C# source code for an extension called DispatchExtension, as well as its related DispatchExtensionAttribute attribute class. It's beyond the scope of this article to describe in detail how to write .NET SOAP extensions; suffice it to say that the method fixXML() does most of the heavy lifting. For the sake of simplicity this is a brute-force approach that completely discards and rebuilds the message body. As an exercise for the reader, this code could be generalized to automatically detect array types and apply intelligent filtering.

When you've written and compiled your SOAP extension, there's one final step. That is to register the attribute class with the appropriate method in your generated proxy class. The following C# snippet from the PresentationController proxy class shows how this is done:

[DispatchExtension()]
public string dispatchAction(string arg0, string arg1, string arg2,
string arg3, NameValuePair[] arg4) {

In the snippet above, the attribute constructor for DispatchExtension is placed before the dispatchAction method. Be careful! If you change the interface of your service you will need to reapply this modification.

Conclusion
When resolving interoperability challenges, be sure to plan for the eventual removal of adapter code as infrastructure vendors evolve their product offerings and correct software deficiencies.

Hopefully, the next release of WLS will include an update of the XML serialization/deserialization infrastructure and SOAP codecs to resolve these issues. Also, the ability to manipulate the SOAP interactions via a callback interface would be a big plus. Overall, BEA has done a superb job in delivering entry-level Web services capabilities in its currently shipping product release. This platform, combined with the excellent tool offerings of .NET, will provide the developer with a best-of-breed toolbox of architectural options.

More Stories By Guy Molinari

Guy Molinari has more than 15 years of experience in developing enterprise applications. For the past three years he has provided Web architecture/infrastructure support for Onvia.com and Xylo, Inc., a Bellevue, WA-based application service provider.

Comments (0)

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.


@ThingsExpo Stories
SYS-CON Events announced today that CAST Software will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 - Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. CAST was founded more than 25 years ago to make the invisible visible. Built around the idea that even the best analytics on the market still leave blind spots for technical teams looking to deliver better software and prevent outages, CAST provides the software intelligence that matter ...
SYS-CON Events announced today that Daiya Industry will exhibit at the Japanese Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Ruby Development Inc. builds new services in short period of time and provides a continuous support of those services based on Ruby on Rails. For more information, please visit https://github.com/RubyDevInc.
As businesses evolve, they need technology that is simple to help them succeed today and flexible enough to help them build for tomorrow. Chrome is fit for the workplace of the future — providing a secure, consistent user experience across a range of devices that can be used anywhere. In her session at 21st Cloud Expo, Vidya Nagarajan, a Senior Product Manager at Google, will take a look at various options as to how ChromeOS can be leveraged to interact with people on the devices, and formats th...
SYS-CON Events announced today that Yuasa System will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Yuasa System is introducing a multi-purpose endurance testing system for flexible displays, OLED devices, flexible substrates, flat cables, and films in smartphones, wearables, automobiles, and healthcare.
SYS-CON Events announced today that Taica will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Taica manufacturers Alpha-GEL brand silicone components and materials, which maintain outstanding performance over a wide temperature range -40C to +200C. For more information, visit http://www.taica.co.jp/english/.
Enterprises have taken advantage of IoT to achieve important revenue and cost advantages. What is less apparent is how incumbent enterprises operating at scale have, following success with IoT, built analytic, operations management and software development capabilities – ranging from autonomous vehicles to manageable robotics installations. They have embraced these capabilities as if they were Silicon Valley startups. As a result, many firms employ new business models that place enormous impor...
SYS-CON Events announced today that SourceForge has been named “Media Sponsor” of SYS-CON's 21st International Cloud Expo, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. SourceForge is the largest, most trusted destination for Open Source Software development, collaboration, discovery and download on the web serving over 32 million viewers, 150 million downloads and over 460,000 active development projects each and every month.
SYS-CON Events announced today that Dasher Technologies will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 - Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Dasher Technologies, Inc. ® is a premier IT solution provider that delivers expert technical resources along with trusted account executives to architect and deliver complete IT solutions and services to help our clients execute their goals, plans and objectives. Since 1999, we'v...
As popularity of the smart home is growing and continues to go mainstream, technological factors play a greater role. The IoT protocol houses the interoperability battery consumption, security, and configuration of a smart home device, and it can be difficult for companies to choose the right kind for their product. For both DIY and professionally installed smart homes, developers need to consider each of these elements for their product to be successful in the market and current smart homes.
SYS-CON Events announced today that MIRAI Inc. will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. MIRAI Inc. are IT consultants from the public sector whose mission is to solve social issues by technology and innovation and to create a meaningful future for people.
SYS-CON Events announced today that Massive Networks, that helps your business operate seamlessly with fast, reliable, and secure internet and network solutions, has been named "Exhibitor" of SYS-CON's 21st International Cloud Expo ®, which will take place on Oct 31 - Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. As a premier telecommunications provider, Massive Networks is headquartered out of Louisville, Colorado. With years of experience under their belt, their team of...
SYS-CON Events announced today that TidalScale, a leading provider of systems and services, will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 - Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. TidalScale has been involved in shaping the computing landscape. They've designed, developed and deployed some of the most important and successful systems and services in the history of the computing industry - internet, Ethernet, operating s...
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, will discuss how from store operations...
Widespread fragmentation is stalling the growth of the IIoT and making it difficult for partners to work together. The number of software platforms, apps, hardware and connectivity standards is creating paralysis among businesses that are afraid of being locked into a solution. EdgeX Foundry is unifying the community around a common IoT edge framework and an ecosystem of interoperable components.
In a recent survey, Sumo Logic surveyed 1,500 customers who employ cloud services such as Amazon Web Services (AWS), Microsoft Azure, and Google Cloud Platform (GCP). According to the survey, a quarter of the respondents have already deployed Docker containers and nearly as many (23 percent) are employing the AWS Lambda serverless computing framework. It’s clear: serverless is here to stay. The adoption does come with some needed changes, within both application development and operations. Tha...
SYS-CON Events announced today that IBM has been named “Diamond Sponsor” of SYS-CON's 21st Cloud Expo, which will take place on October 31 through November 2nd 2017 at the Santa Clara Convention Center in Santa Clara, California.
In his Opening Keynote at 21st Cloud Expo, John Considine, General Manager of IBM Cloud Infrastructure, will lead you through the exciting evolution of the cloud. He'll look at this major disruption from the perspective of technology, business models, and what this means for enterprises of all sizes. John Considine is General Manager of Cloud Infrastructure Services at IBM. In that role he is responsible for leading IBM’s public cloud infrastructure including strategy, development, and offering ...
Infoblox delivers Actionable Network Intelligence to enterprise, government, and service provider customers around the world. They are the industry leader in DNS, DHCP, and IP address management, the category known as DDI. We empower thousands of organizations to control and secure their networks from the core-enabling them to increase efficiency and visibility, improve customer service, and meet compliance requirements.
Join IBM November 1 at 21st Cloud Expo at the Santa Clara Convention Center in Santa Clara, CA, and learn how IBM Watson can bring cognitive services and AI to intelligent, unmanned systems. Cognitive analysis impacts today’s systems with unparalleled ability that were previously available only to manned, back-end operations. Thanks to cloud processing, IBM Watson can bring cognitive services and AI to intelligent, unmanned systems. Imagine a robot vacuum that becomes your personal assistant tha...
With major technology companies and startups seriously embracing Cloud strategies, now is the perfect time to attend 21st Cloud Expo October 31 - November 2, 2017, at the Santa Clara Convention Center, CA, and June 12-14, 2018, at the Javits Center in New York City, NY, and learn what is going on, contribute to the discussions, and ensure that your enterprise is on the right path to Digital Transformation.