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

Prerequisites

Before trying out this example, you will need to download and install Java EE 7 SDK which comes with GlassFish Open Source Edition 4 (currently 4.1.1) and then configure eclipse to deploy Java EE applications directly to GlassFish Server.

For details, refer to http://www.javajee.com/configuring-glassfish-server-4-with-eclipse-to-bu....

 

Getting Started

  • Start the Eclipse (Java EE eclipse configured with Glassfish server)

  • Create a Dynamic Web Project selecting Glassfish server as the Target runtime.

 

Screenshot: Dynamic Web Project

 

The Web Service

Right click on src folder under java resources and create a simple class annotated as web service:

package com.javajee.webservices.soap;

import javax.jws.WebService;

@WebService
public class MyWebService {

    public String myServiceMethod() {
        return "Message From myServiceMethod";

    }

}

 

Deploying and verifying the results

  • Right click Glassfish server in the servers tab, click on "Add or Remove", and add "WebServiceDemo".

  • Right click on the server in the servers view and go to Glassfish > view Admin Console. This will take you to the admin console @ http://localhost:4848/common/index.jsf.

    • Click on Applications tab on left to see the list of deployed applications. You can see the application WebServicesDemo. Note Engines are specified as webservices and web. 

    • Click on the application to go to Edit Application page.

    • Under 'Modules and Components' click on 'View Endpoint' link. It will provide links to the wsdl as well as a tester for testing out the SOAP web service. 

    • View the wsdl and test the application using the tester to see the SOAP request and SOAP response.

 

Screenshot: Tester

 

Common issues and solutions

Delpoyment may fail with below error:

cannot Deploy WebServiceDemo
deploy is failing=Application with name
[WebServiceDemo] is not deployed

Solution 1:

Check:

  1. if you have defined a package for your web service class. Default package will result in NullPointerException

  2. if you have at least one public method in your web service class

 

Solution 2: 

(If solution 1 did not help)

Right click Glassfish server in the servers tab and check (select) "Use JAR archives for deployment" in the Glassfish tab.

Search the Web

Custom Search

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