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 CollabNet, a global leader in enterprise software development, release automation and DevOps solutions, will be a Bronze Sponsor of SYS-CON's 20th International Cloud Expo®, taking place from June 6-8, 2017, at the Javits Center in New York City, NY. CollabNet offers a broad range of solutions with the mission of helping modern organizations deliver quality software at speed. The company’s latest innovation, the DevOps Lifecycle Manager (DLM), supports Value S...
SYS-CON Events announced today that Outscale will exhibit at SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. Outscale's technology makes an automated and adaptable Cloud available to businesses, supporting them in the most complex IT projects while controlling their operational aspects. You boost your IT infrastructure's reactivity, with request responses that only take a few seconds.
SYS-CON Events announced today that Peak 10, Inc., a national IT infrastructure and cloud services provider, will exhibit at SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. Peak 10 provides reliable, tailored data center and network services, cloud and managed services. Its solutions are designed to scale and adapt to customers’ changing business needs, enabling them to lower costs, improve performance and focus intern...
The 21st International Cloud Expo has announced that its Call for Papers is open. Cloud Expo, to be held October 31 - November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA, brings together Cloud Computing, Big Data, Internet of Things, DevOps, Digital Transformation, Machine Learning and WebRTC to one location. With cloud computing driving a higher percentage of enterprise IT budgets every year, it becomes increasingly important to plant your flag in this fast-expanding busin...
Internet of @ThingsExpo, taking place October 31 - November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA, is co-located with the 21st International Cloud Expo and will feature technical sessions from a rock star conference faculty and the leading industry players in the world. @ThingsExpo Silicon Valley Call for Papers is now open.
As cloud adoption continues to transform business, today's global enterprises are challenged with managing a growing amount of information living outside of the data center. The rapid adoption of IoT and increasingly mobile workforce are exacerbating the problem. Ensuring secure data sharing and efficient backup poses capacity and bandwidth considerations as well as policy and regulatory compliance issues.
DevOps is often described as a combination of technology and culture. Without both, DevOps isn't complete. However, applying the culture to outdated technology is a recipe for disaster; as response times grow and connections between teams are delayed by technology, the culture will die. A Nutanix Enterprise Cloud has many benefits that provide the needed base for a true DevOps paradigm.
SYS-CON Events announced today that SoftLayer, an IBM Company, has been named “Gold Sponsor” of SYS-CON's 18th Cloud Expo, which will take place on June 7-9, 2016, at the Javits Center in New York, New York. SoftLayer, an IBM Company, provides cloud infrastructure as a service from a growing number of data centers and network points of presence around the world. SoftLayer’s customers range from Web startups to global enterprises.
Five years ago development was seen as a dead-end career, now it’s anything but – with an explosion in mobile and IoT initiatives increasing the demand for skilled engineers. But apart from having a ready supply of great coders, what constitutes true ‘DevOps Royalty’? It’ll be the ability to craft resilient architectures, supportability, security everywhere across the software lifecycle. In his keynote at @DevOpsSummit at 20th Cloud Expo, Jeffrey Scheaffer, GM and SVP, Continuous Delivery Busine...
SYS-CON Events announced today that Loom Systems will exhibit at SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. Founded in 2015, Loom Systems delivers an advanced AI solution to predict and prevent problems in the digital business. Loom stands alone in the industry as an AI analysis platform requiring no prior math knowledge from operators, leveraging the existing staff to succeed in the digital era. With offices in S...
SYS-CON Events announced today that DivvyCloud will exhibit at SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. DivvyCloud software enables organizations to achieve their cloud computing goals by simplifying and automating security, compliance and cost optimization of public and private cloud infrastructure. Using DivvyCloud, customers can leverage programmatic Bots to identify and remediate common cloud problems in rea...
SYS-CON Events announced today that Tintri, Inc, a leading provider of enterprise cloud infrastructure, will exhibit at SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. Tintri offers an enterprise cloud platform built with public cloud-like web services and RESTful APIs. Organizations use Tintri all-flash storage with scale-out and automation as a foundation for their own clouds – to build agile development environments...
SYS-CON Events announced today that Progress, a global leader in application development, has been named “Bronze Sponsor” of SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. Enterprises today are rapidly adopting the cloud, while continuing to retain business-critical/sensitive data inside the firewall. This is creating two separate data silos – one inside the firewall and the other outside the firewall. Cloud ISVs ofte...
SYS-CON Events announced today that Tappest will exhibit MooseFS at SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. MooseFS is a breakthrough concept in the storage industry. It allows you to secure stored data with either duplication or erasure coding using any server. The newest – 4.0 version of the software enables users to maintain the redundancy level with even 50% less hard drive space required. The software func...
SYS-CON Events announced today that EARP will exhibit at SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. "We are a software house, so we perfectly understand challenges that other software houses face in their projects. We can augment a team, that will work with the same standards and processes as our partners' internal teams. Our teams will deliver the same quality within the required time and budget just as our partn...
SYS-CON Events announced today that Interoute has been named “Bronze Sponsor” of SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. Interoute is the owner operator of Europe's largest network and a global cloud services platform, which encompasses over 70,000 km of lit fiber, 15 data centers, 17 virtual data centers and 33 colocation centers, with connections to 195 additional partner data centers. Our full-service Unifie...
SYS-CON Events announced today that Super Micro Computer, Inc., a global leader in compute, storage and networking technologies, will exhibit at SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. Supermicro (NASDAQ: SMCI), the leading innovator in high-performance, high-efficiency server technology, is a premier provider of advanced server Building Block Solutions® for Data Center, Cloud Computing, Enterprise IT, Hadoop/...
SYS-CON Events announced today that Carbonite will exhibit at SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. Carbonite protects your entire IT footprint with the right level of protection for each workload, ensuring lower costs and dependable solutions with DoubleTake and Evault.
SYS-CON Events announced today that Technologic Systems Inc., an embedded systems solutions company, will exhibit at SYS-CON's @ThingsExpo, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. Technologic Systems is an embedded systems company with headquarters in Fountain Hills, Arizona. They have been in business for 32 years, helping more than 8,000 OEM customers and building over a hundred COTS products that have never been discontinued. Technologic Systems’ pr...
SYS-CON Events announced today that Cloudistics, an on-premises cloud computing company, has been named “Bronze Sponsor” of SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. Cloudistics delivers a complete public cloud experience with composable on-premises infrastructures to medium and large enterprises. Its software-defined technology natively converges network, storage, compute, virtualization, and management into a ...