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

Related Topics: Weblogic

Weblogic: Article

Integrating J2EE and .NET Web Services

Integrating J2EE and .NET Web Services

Many articles have claimed that Java 2, Enterprise Edition (J2EE) and .NET Web services are interoperable. What does this mean from a developer's perspective? What issues and problems arise as you actually do the work?

For our purposes, I'll define Web services as self-contained, modular business applications that have open, Internet-oriented, standards-based interfaces. The standards I'm referring to are Simple Object Access Protocol (SOAP) and Web Services Definition Language (WSDL). SOAP is a lightweight XML-based message format for communication between Web services. WSDL is a schema that describes the way in which a Web service is to be used. WSDL documents answer the following questions about a Web service: What data is exchanged, how do you interact with the service, and where is the service located? When I refer to term interoperability between Web services, I mean that you can call J2EE Web services from a .NET client application and the reverse is also true.

Analysts have projected that J2EE and .NET will each have approximately 40% of the Web services that will be implemented on their platform. This means that for a customer to be able to utilize all the Web services that will be available in the future, the platforms need to interoperate. Companies from both camps are working together to ensure interoperability. Several standards bodies have been formed to drive interoperability between the various Web services platform providers. For example, both SOAPBuilders and the Web Services Interoperability Organization (WS-I) are involved in interoperability efforts.

To prove that simple J2EE and .NET Web services can interoperate, two things must be demonstrated. One, a .NET Web services client should be able to call and receive a response from a J2EE Web service, and two, a J2EE Web services client should be able to call and receive a response from a .NET Web service.

Case Study
In the interest of reusing code and knowledge, the same application was used to prove both points. I started with an existing J2EE application that uses servlets, JavaServerPages (JSPs), and Enterprise JavaBeans (EJBs) that I converted into a Web service. This application allows a field agent to view, edit, and create orders for a fictional construction company. The field agent is also able to sort existing orders by customer name,employee id, or order status.

Calling a J2EE Web Service from a .NET Client
Making Orders a J2EE Web Service

In order to reuse as much code as possible, I used the EJBs that had been written and deployed on WebLogic Server to implement the business logic on the back end. First, I needed to create a Web service that exposed the methods of the EJBs. To create a Web service in BEA WebLogic Workshop, I used the wizard provided and named it Orders (see Figure 1). This generates a Web service file with the name Orders.jws. Using the WebLogic Server 7.0 and WebLogic Workshop Web service runtime environment, I added the EJBs to my Web service with controls. Controls are a mechanism in WebLogic Workshop for interacting with resources from within a Web service. They can be interfaces to databases, EJBs, JMS queues, or other Web services.

Calling the EJBs from the Web Service
In order to call the EJBs from my Web service in WebLogic Workshop, I need a handle to an EJB and this is what the control does. As you can see in the following code sample, the SearchEJB variable is my control; I call a particular method, getOrdersByID, and pass it the incoming parameter, ID. This is where the WebLogic Workshop tool really provides value to the developer. I didn't have to worry about getting references to the home and remote interfaces for the EJB. The control hides this complexity and simplifies the coding required to interface with the EJB. The jws:operation tag in the code sample is a signal to the WebLogic Server that this method is part of the Web service's public contract and is available for clients to invoke.

* @jws:operation
public ordermasterfields[] getOrdersByID(String ID)
ordermasterfields[] orderArray = null;
LinkedList orderList = SearchEJB.getOrdersbyID(ID);
orderArray = getArray(orderList)
catch(Exception e){
System.out.println("*** In getOrdersByID method *** \n
Exception is: " + e.getMessage());
return (orderArray);

Once I added the EJBs to the Web service, I carefully checked the data types that were being returned from the EJB methods. I wanted to make sure that each of these data types is serializable so that I can return them over the wire to the Web service client. Notice in the code above that my EJB method returns a LinkedList that is not serializable. There are two possible solutions to this problem. I could choose to either change the code in the EJB to return a serializable data type and redeploy the EJB, or I could convert the data type inside the Web service before returning it to the client. I chose the second option for simplicity: I didn't have to redeploy the EJBs and I could still use the original front-end Web application if necessary. Since LinkedLists are not serializable, I converted the Web service method to return an array of "ordermasterfields". This class, ordermasterfields, is user-defined and will be included in the WSDL document so the client knows what the user-defined types are. The getArray method performs the conversion.

The next step is to generate a WSDL document for use by a .NET client. In WebLogic Workshop I simply clicked on the "Generate WSDL Document" button and it automatically generated the WSDL document for me. I'm now ready to create a client that will use the Orders J2EE Web service. Notice that all we've really done is add a new Web service interface to the EJBs. As a matter of fact, the Web application front end that I started with is still usable since the EJBs have not been changed. In addition to returning HTML from the original Web application, we are now returning an XML document that contains an array of Orders via SOAP from our Web service.

Creating a .NET Client for the J2EE Orders Web Service
Now that I've created a J2EE Web service I need to create a .NET client that will access it. In Visual Studio .NET, the first step is to import a WSDL document into the ASP.NET Web services client by adding a Web reference to the client through a wizard in Visual Studio .NET. You can either point to a file on your local system or to the URL of a Web service on the Internet. I added the Web reference for the J2EE Orders Web service and Visual Studio .NET automatically generated a client proxy file. This file maps all the operations and data types from the WSDL document to a client proxy code file, Reference.cs, on the client side. Then, all that is necessary is to create a variable that uses the client proxy to call methods on the Web service. The following code fragment contains excerpts from the Reference.cs file that show where to find the Web service and defines return types for a particular method.

public Orders() {
this.Url = "http://localhost:7001/Orders/Orders.jws";

public ordermasterfields[] getOrdersByID(string ID) {
object[] results =
this.Invoke("getOrdersByID", ne object[] {ID});
return ((ordermasterfields[])(results[0]));

Now that I have added the Web reference and Visual Studio .NET has created a client proxy, I need to create an instance of the Web reference, Orders, and invoke a method. This is all the code I need to write to invoke a particular method on the Orders Web service.

using OrderWebApplication.WebReference1;

WebReference1.Orders orders = new WebReference1.Orders();

WebReference1.ordermasterfields[] ordersResult =

.NET has a concept of strict separation between the presentation and the implementation of code. They use what they call a code-behind file that is tied to the WebForm page that contains all the code (see Figure 2). All of the presentation is handled in the WebForm.aspx file, which is an ASP.NET page, and all code is written in the WebForm.aspx.cs file. The idea is the same as a JSP file where HTML is the presentation or static content and dynamic content is inserted in JSP tag sections. .NET simply extended that and moved the embedded code sections to a separate code file. I could still implement the ASP.NET page with combined HTML and ASP.NET code in the same file if I wanted to. I also created new presentation code with ASP.NET pages that duplicates what was already available on the J2EE platform, but this is not covered in this article.

Request and Response Code
Now that I have both a client and a Web service, let's look at what happens when I make a request to the Web service. With Web services, SOAP request and response messages are sent back and forth either asynchronously or synchronously. Here I show only the portion of the SOAP message that pertains to the Web service method I am invoking. I am calling the getOrdersByID method and passing it an ID parameter with a value of JANE.

<getOrdersByID xmlns="http://www.openuri.org/">

In response from the Web service, I get an array of ordermasterfields that represents all orders with an ID of JANE.

<ArrayOfordermasterfields xmlns="http://www.openuri.org/">
<customerName>Johns Lock Shop</customerName>

Figure 3 is my completed .NET client and J2EE Orders Web service.

Calling a .NET Web Service from a J2EE Client
At this point I need to prove that a J2EE Web service client can invoke a .NET Web service. In this case I didn't have a preexisting .NET application so I created a .NET Web service from scratch.

Creating a .NET Web Service
I decided to re-create the same Orders application since I already knew how this application worked on the J2EE side. First I created a new database using Microsoft Access to duplicate the tables. Second, I added ADO.NET objects to access the database and exposed those methods through a Web service page, Orders.asmx.

In order to make the method available through the Web service interface I added the [Web Method] designation in front of the method signature. The DataSet type is a new data type that is currently available only in .NET languages. This means that the Web service client must be able to translate this data type to an equivalent one in the language it implements. In this case, the J2EE client must be able to convert the DataSet type into a Java equivalent.

[ WebMethod ]
public DataSet getOrdersByCustomer(int customerNbr)
DataSet ds = new DataSet("OrderSet");
oleDbDataAdapter1.SelectCommand.CommandText = "SELECT
FROM OrderMaster WHERE CustomerNbr=" + customerNbr +
" ORDER BY OrderNumber";
return ds;

Creating a J2EE Client for the .NET Orders Web Service
Next I began creating the J2EE client for the .NET Orders Web service. Most of the steps between WebLogic Workshop and Visual Studio .NET are the same, but the way they implement them is slightly different. WebLogic Workshop will also need a WSDL document in order to generate the client proxy, but the WSDL document must first be added to the lib directory before I can create a service control for the .NET Web service from the WSDL document. In the next code snippet I created an instance of the Service Control, created methods that mapped to the Web service methods, and then invoked the method.

private OrdersNETControl OrdersNETClient;

public Node getOrdersByCustomer(int customerNbr)
return (Node)

Notice that WebLogic Workshop is expecting a Node to be returned from the .NET Orders Web service. Workshop has mapped the DataSet data type from .NET to a generic XML document Node in order to be able to extract the data values. This is still a little cumbersome to figure out. I had to hunt through the Control file that is generated by WebLogic Workshop to discover this.

/** @editor-info:link source="OrdersNET.wsdl" autogen="true" */
import Weblogic.jws.control.ServiceControl;
* @jws:location http-url="http://localhost/OrderRetrieval/Service1.asmx"
* @jws:wsdl file="#OrdersNETWsdl"
public interface OrdersNETControl extends ServiceControl
public org.w3c.dom.Node getOrdersByEmployee
(java.lang.String EmployeeID);

Request and Response Code
Now that I have both a client and a Web service, let's look at what happens when I make a request to the Web service. With Web services, SOAP messages are sent back and forth either asynchronously or synchronously. Here I show only the portion of the SOAP message that pertains to the Web service method that I am invoking. I am calling the getOrdersByCustomer method and passing it a customerNbr parameter with a value of 200.

<getOrdersByCustomer xmlns="http://tempuri.org/">
Fragment 9 - Request XML message

In response from the Web service I get an array of Orders that represent all orders with a customerNbr of 200.

<OrderSet xmlns="">
<Orders diffgr:id="Orders1" msdata:rowOrder="0">
<CustomerName>Set in Place</CustomerName>

Considerations and Conclusions
Simple Web services interoperability with SOAP and WSDL can be proven with the following steps:

  • A J2EE client can invoke a .NET Web service
  • A J2EE client can use a .NET WSDL document to create a stub
  • A .NET client can invoke a J2EE Web service
  • A .NET client can use a J2EE WSDL document to create a stub

    There are additional steps that need to be taken by the industry to enhance interoperability between J2EE and .NET. First, support should be added for all XML Schema types. For example, the XML Schema type choice has no standard equivalent in the Java language. Second, support should be added for .NET data types that do not have an equivalent Java type. The ADO.NET type DataSet also has no equivalent Java type. In my experience, WebLogic Workshop translated a DataSet as a generic XML Node that is then parsed on the Java side to pull out the DataSet values. Third, support should be added to J2EE for the extensions that Microsoft has added to their SOAP implementation.

    WSDL is at the heart of service interoperability and, a common WSDL interface can increase reuse. Since WSDL defines the data types that a Web service is expecting, it enables interoperability with SOAP clients to the Web service. There are a number of tools available for both J2EE and .NET that can generate client-side proxies, which hides a layer of complexity from the developer. Other best practices include sticking with well-accepted standards (e.g., SOAP 1.2), keeping your data types as simple as possible, and providing XML Schema definitions for all of your data types.

    Web services can be written successfully in either .NET or J2EE. Simple interoperability between J2EE and .NET Web services is possible today, and continued improvements are coming from the interoperability standards bodies. Using common data types that can be easily serialized makes the developer's job easier. Learning a new language or a new programming paradigm might be necessary depending on your programming background.


  • BEA Systems: www.bea.com
  • D.H. Brown Associates, Inc. "Web Services and Application Integration with J2EE and Microsoft .NET." December 2002.
  • Smith, David; Mark Driver; Chris Le Tocq; Whit Andrews, et al. "Weaving the Future: Microsoft's .NET Initiative," Gartner, September 20, 2001.
  • HP Developer's Central: www.hp.com/go/developers
  • HP Java products: www.hp.com/go/java
  • Karpinski, Richard. "Mission Interoperable: Rivals Aim to Link Web Services." InternetWeek, March 6, 2002.
  • Roman, Ed, and Chad Vawter. (June 2001) "J2EE vs. Microsoft.NET: A comparison of building XML-based Web services." The Middleware Company.
  • Microsoft Developer Network: http://msdn.microsoft.com
  • SOAPBuilders: www.soapbuilders.org.
  • Svoboda, Zdenek. (February 2002) "Developing Interoperable Web Services - Integrating Java and Microsoft .NET." Systinet.
  • Web Services Interoperability Organization: www.ws-i.org.
  • 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
    It is of utmost importance for the future success of WebRTC to ensure that interoperability is operational between web browsers and any WebRTC-compliant client. To be guaranteed as operational and effective, interoperability must be tested extensively by establishing WebRTC data and media connections between different web browsers running on different devices and operating systems. In his session at WebRTC Summit at @ThingsExpo, Dr. Alex Gouaillard, CEO and Founder of CoSMo Software, presented ...
    WebRTC is great technology to build your own communication tools. It will be even more exciting experience it with advanced devices, such as a 360 Camera, 360 microphone, and a depth sensor camera. In his session at @ThingsExpo, Masashi Ganeko, a manager at INFOCOM Corporation, introduced two experimental projects from his team and what they learned from them. "Shotoku Tamago" uses the robot audition software HARK to track speakers in 360 video of a remote party. "Virtual Teleport" uses a multip...
    Business professionals no longer wonder if they'll migrate to the cloud; it's now a matter of when. The cloud environment has proved to be a major force in transitioning to an agile business model that enables quick decisions and fast implementation that solidify customer relationships. And when the cloud is combined with the power of cognitive computing, it drives innovation and transformation that achieves astounding competitive advantage.
    Data is the fuel that drives the machine learning algorithmic engines and ultimately provides the business value. In his session at Cloud Expo, Ed Featherston, a director and senior enterprise architect at Collaborative Consulting, discussed the key considerations around quality, volume, timeliness, and pedigree that must be dealt with in order to properly fuel that engine.
    IoT is rapidly becoming mainstream as more and more investments are made into the platforms and technology. As this movement continues to expand and gain momentum it creates a massive wall of noise that can be difficult to sift through. Unfortunately, this inevitably makes IoT less approachable for people to get started with and can hamper efforts to integrate this key technology into your own portfolio. There are so many connected products already in place today with many hundreds more on the h...
    When shopping for a new data processing platform for IoT solutions, many development teams want to be able to test-drive options before making a choice. Yet when evaluating an IoT solution, it’s simply not feasible to do so at scale with physical devices. Building a sensor simulator is the next best choice; however, generating a realistic simulation at very high TPS with ease of configurability is a formidable challenge. When dealing with multiple application or transport protocols, you would be...
    Detecting internal user threats in the Big Data eco-system is challenging and cumbersome. Many organizations monitor internal usage of the Big Data eco-system using a set of alerts. This is not a scalable process given the increase in the number of alerts with the accelerating growth in data volume and user base. Organizations are increasingly leveraging machine learning to monitor only those data elements that are sensitive and critical, autonomously establish monitoring policies, and to detect...
    In his keynote at 18th Cloud Expo, Andrew Keys, Co-Founder of ConsenSys Enterprise, provided an overview of the evolution of the Internet and the Database and the future of their combination – the Blockchain. 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 settl...
    In his session at @ThingsExpo, Dr. Robert Cohen, an economist and senior fellow at the Economic Strategy Institute, presented the findings of a series of six detailed case studies of how large corporations are implementing IoT. The session explored how IoT has improved their economic performance, had major impacts on business models and resulted in impressive ROIs. The companies covered span manufacturing and services firms. He also explored servicification, how manufacturing firms shift from se...
    DevOpsSummit New York 2018, colocated with CloudEXPO | DXWorldEXPO New York 2018 will be held November 11-13, 2018, in New York City. Digital Transformation (DX) is a major focus with the introduction of DXWorldEXPO within the program. Successful transformation requires a laser focus on being data-driven and on using all the tools available that enable transformation if they plan to survive over the long term. A total of 88% of Fortune 500 companies from a generation ago are now out of bus...
    The Jevons Paradox suggests that when technological advances increase efficiency of a resource, it results in an overall increase in consumption. Writing on the increased use of coal as a result of technological improvements, 19th-century economist William Stanley Jevons found that these improvements led to the development of new ways to utilize coal. In his session at 19th Cloud Expo, Mark Thiele, Chief Strategy Officer for Apcera, compared the Jevons Paradox to modern-day enterprise IT, examin...
    IoT solutions exploit operational data generated by Internet-connected smart “things” for the purpose of gaining operational insight and producing “better outcomes” (for example, create new business models, eliminate unscheduled maintenance, etc.). The explosive proliferation of IoT solutions will result in an exponential growth in the volume of IoT data, precipitating significant Information Governance issues: who owns the IoT data, what are the rights/duties of IoT solutions adopters towards t...
    Amazon started as an online bookseller 20 years ago. Since then, it has evolved into a technology juggernaut that has disrupted multiple markets and industries and touches many aspects of our lives. It is a relentless technology and business model innovator driving disruption throughout numerous ecosystems. Amazon’s AWS revenues alone are approaching $16B a year making it one of the largest IT companies in the world. With dominant offerings in Cloud, IoT, eCommerce, Big Data, AI, Digital Assista...
    Organizations planning enterprise data center consolidation and modernization projects are faced with a challenging, costly reality. Requirements to deploy modern, cloud-native applications simultaneously with traditional client/server applications are almost impossible to achieve with hardware-centric enterprise infrastructure. Compute and network infrastructure are fast moving down a software-defined path, but storage has been a laggard. Until now.
    Digital Transformation is much more than a buzzword. The radical shift to digital mechanisms for almost every process is evident across all industries and verticals. This is often especially true in financial services, where the legacy environment is many times unable to keep up with the rapidly shifting demands of the consumer. The constant pressure to provide complete, omnichannel delivery of customer-facing solutions to meet both regulatory and customer demands is putting enormous pressure on...
    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...
    DXWorldEXPO LLC announced today that All in Mobile, a mobile app development company from Poland, will exhibit at the 22nd International CloudEXPO | DXWorldEXPO. All In Mobile is a mobile app development company from Poland. Since 2014, they maintain passion for developing mobile applications for enterprises and startups worldwide.
    "Akvelon is a software development company and we also provide consultancy services to folks who are looking to scale or accelerate their engineering roadmaps," explained Jeremiah Mothersell, Marketing Manager at Akvelon, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
    IoT is at the core or many Digital Transformation initiatives with the goal of re-inventing a company's business model. We all agree that collecting relevant IoT data will result in massive amounts of data needing to be stored. However, with the rapid development of IoT devices and ongoing business model transformation, we are not able to predict the volume and growth of IoT data. And with the lack of IoT history, traditional methods of IT and infrastructure planning based on the past do not app...
    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.