Free Training


C Language  |  CSS  |  MainFrame  |  VBScript  |  PHP  |  XML  |  C++ Tutorials  |  Ajax  |  JavaScript  |  CSS3  |  UML  |  jQuery  |  Microsoft AJAX

SOA Web Services Tutorials

 
Home Tutorials SOA Web Services
 

SOA Web Services - Java EE and .NET Integration using Web Services

 
Category: SWS
Comments (0)

Java EE and .NET Integration using Web Services

So far, we have looked into the various aspects of interoperability between web services deployed on disparate platforms. If the web services follow the compliance requirements of the Basic Profile discussed earlier, they can interoperate easily.



Fortunately for us, most of the vendors have updated their development platforms to meet the WS-I compliance requirements for creating web services. In this section, we will look at the integration of web services deployed on two popular platforms, Java EE and .NET.


Sample Integration Scenario

We will develop a .NET web service that will be deployed on a .NET server. We will also develop a Java web service that is deployed on a Sun Application Server. We will then write a C# console application that calls both the services and prints the results of the two web service calls on the user console. The application architecture is illustrated in the following figure.



I have kept this application very simple so that we can focus more on the compliance requirements. The service methods on both the web services simply return a greeting message to the caller.


Developing the Java Web Service

First, we will develop a Java web service. Creating a Java web service on the latest Java EE platform is an easy task. Write a simple Java class as shown in the following listing.




Sample Code
  1. package endpoint;
  2.  
  3. import javax.jws.WebService;
  4.  
  5. @WebService
  6. public class Hello
  7. {
  8.  
  9.  
  10.  public String SayHello()
  11. {
  12. return "\nHello from Java Service!";
  13. }
  14. }
Copyright exforsys.com


You need to import the javax.jws.WebService package as seen in the listing. The Hello.java file contains a public class Hello. To convert this into a component that can be deployed as a web service, simply annotate the class with the @WebService attribute. The deployment tool then provides the required plumbing to expose this class as a web service. In the class, we write the service methods that can be invoked by a service consumer. We write a single method in this class called SayHello that returns a greeting message to the caller.


Deploying the Service

The easiest way to build and deploy the web service is to use a vendor-supplied IDE. You may use Java Studio Enterprise or NetBeans IDE to build and deploy the service. I used NetBeans 5.5 IDE to deploy the service. The NetBeans 5.5 version provides a template for creating web services. This template creates EJB components for service objects. As I said, to keep the things simple, I avoided using this template. Rather, I used the ant Build to compile and deploy the project. You will fi nd the sample build.xml file in your NetBeans installation. This file is also available in the code download for this book.


NetBeans IDE can be configured for deployment to any server. I used SunOne Application Server PE 9 for testing. NetBeans also comes with a bundled Tomcat server. You may use this for deployment. If you decide to use Sun App Server for deployment, you will have to add the server in the NetBeans configuration. Incidentally, the Sun Application Server is installed on your machine as a part of Java EE installation.


Once you deploy the service, you can verify it by examining the WSDL generated during the deployment process. To look up the WSDL, type the following URL in your browser:


http://localhost:8080/Hello/HelloService?WSDL



This will show the generated WSDL in the browser window. We will now examine this WSDL to verify that this is BP compliant.



Read Next: SOA Web Services - WSDL for Java Web Service



 
Related Topics

Related Jobs


 

Comments



Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    

Weekly Offers

Sponsored Links