Interoperability Between Java and .NET Web Services XML

You have created Web services by using the .NET platform and Java. However, it is essential that the Web services you created using the two platforms are interoperable with each other.

In this section, you will test the interoperability between Web services created using Java and .NET. To do this, you will create a client application in .NET by using Visual Studio .NET. Then you will access the Java Web services that you have created in this chapter by using the .NET client application.

Creating a Visual Basic .NET Client Application

To create a .NET client application, perform the following steps:

  1. Create a Visual Basic .NET Windows application in Visual Studio .NET.
  2. In the Solution Explorer window, right-click on the project name and select Add Web
  3. Reference from the displayed menu. The Add Web Reference dialog box is displayed, as shown in Figure.

    The Add Web Reference Dialog Box

    The Add Web Reference Dialog Box

  4. Enter the URL for the WSDL of the Web service that you created.
  5. Note?/td>Note that the Websphere Studio does not come with a fullfledged application server. Instead, it comes with a micro version of the Websphere application server, which you can use only within the Studio IDE. As a result, you cannot connect to it from Visual Studio .NET.

    The Web service that you built using Websphere Studio Application Developer is deployed on an internal version of Websphere; therefore, it uses one of the other Web services that you have deployed on Tomcat. Tomcat is a complete application server that can be accessed from external applications.

  6. After the WSDL file is displayed, click on the Add Reference button. The IDE will locally create a WSDL file and proxy.

The following code shows the content of the WSDL file for the Web service that you created and deployed on Tomcat:

As you can see, the preceding WSDL file is not very different from the WSDL file that you could have created using the Java2Wsdl tool.

The following code shows the content of the proxy class created in Visual Basic .NET, which represents the remote Web service:

The bold part of the preceding code shows the isValid() method and how neatly it encapsulates the isValid() method of the Web service.

Adding Code to the Button Control

Add a Button control to the Visual Basic .NET Windows application. To add functionality to the Button control, add the following code to the Click event of the button:

Now run the application and verify the functioning of the Web service by passing appropriate values to the isValid() method.


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

XML Topics