[Lab-Analysis] Deploying a Bottum-up SOAP Web Service in Glassfish Server from Eclipse

We will quickly review the results of the lab @ http://javajee.com/lab-deploying-a-simple-soap-web-service-in-glassfish-....

 

The Web Service

We had deployed the below simple web service in Glassfish server using eclipse and all it took was to use an annotation @WebService to make it a web service. 

package com.javajee.webservices.soap;

import javax.jws.WebService;

@WebService
public class MyWebService {

    public String myServiceMethod() {

      return "From myServiceMethod";

    }
}

We did not had to do any other configurations because Java EE 5 and above compliant application servers such as Glassfish, comply to JSR 109 (Web services 1.2/1.3) and JSR 224 (JAX-WS 2.0/2.1/2.2). However, to deploy web service on a web container like tomcat, you will need to do some additional steps, which we will see later.

Also, traditionally we used to create an interface called Service Endpoint Interface (SEI) and an implementation class called Service Implementation Bean (SIB) that implements this interface. However, current standard allows us to create web services using just a POJO with annotations without a separate interface. We will see the SIB with SEI apprach in another example. 

 

Endpoint and WSDL URLs

Endpoint URL can be considered as an url where you can access your web service.  

Endpoint URL for our service is: http://localhost:8080/WebServiceDemo/MyWebServiceService

Note: 'Service' is appended to the class name MyWebService.

 

Web Services Description Language (WSDL) describes our web service.

WSDL URL for our service is: http://localhost:8080/WebServiceDemo/MyWebServiceService?wsdl

Note: '?wsdl' is appended to the endpoint URL

 

Generated WSDL

Generated WSDL will look as below:

 

Tester Output (SOAP Request and SOAP Response)

The tester will show you the actual SOAP request sent and SOAP response received from the web service.

As you can see, SOAP request and SOAP response are XML messages with some SOAP specific elements. We will see them in more detail later.

 

Important notes: 

Even if you do multiple requests to the deployed SOAP web service, it will all be handled by the same instance.

Glassfish tester has some limitations and a standard testing tool such as SOAP UI or even the Eclipse Web Service Explorer is preferred. For instance, an exception thrown in your web service is returned back as SOAP fault element. While the response is actually a SOAP message with SOAP fault element, Glassfish will show the complete stack trace instead of the original SOAP response message.

These tools are also handy when you are deploying web services on a server that does not provide an inbuilt tester (for example Apache Tomcat web container). Hence. we will also see SOAP UI and the Eclipse Web Service Explorer.

 

Summary

Don't rely on these screenshots. Do it yourself and see the result yourself.

Don't worry if you have not understood everything we have discussed here; we will be discussing all of these in detail.

See additional excercise section for more problems to try out.

Search the Web

Custom Search

Searches whole web. Use the search in the right sidebar to search only within javajee.com!!!