Web Service development using Netbeans and JBoss

This article is an introduction to creating JavaFirst JAX-WS web service using Netbeans IDE and JBoss Application Server.

Web Services are playing a major part in the enterprise application domain. Before JAX-WS, JAX-RPC was used to develop web services in Java. Apache Axis has been one of the popular implementation for development of Web Services for Java. With the advent of JAX-WS developing web services has become much simpler. This article explains how to create simple web service using Netbeans and JBoss Application Server.

Prerequisites

  • - Download and Install Netbeans from Downloads.
  • - Download and Install Jboss Application Server.
  • - Download and Intsall JBossWS for your JBoss Application Server. Check the tutorial for the same here.
  • - Configure Netbeans to use JBoss Server using Server Manager.

Create Project

Netbeans provides very easy way to develop web services. First we need to create an EJB application. Start Netbeans and select File -> New Project. Select EJB Project as shown below:
Step 1. Creating a project Name the Module as JBossWSEJBModule or something you like.Make sure that you select JBoss Application Server as the Server. Select JavaEE5 for the JavaEE Version.
Step 2. Provide project properties

Once the project is created, you can check the files in the Projects window of Netbeans. Right click on the project name and select New -> Web Service ...
Step 3. Create new web service

<!--pagebreak-->

Provide values for the new web service
Step 4. Web service properties

Expand the Web services node in the project, and right click the Web Service. Add a new operation to your web site by clicking on New operation .. as shown below:


Step 6. New Webservice Operation


Finally your web service should look like the following in the editor:
Step 7. New Webservice Operation

<!--pagebreak-->

You can Click on the Source button to edit your web service Java Code. Update the sayHello method as follows: /** * Web service operation */ @WebMethod(operationName = "sayHello") public String sayHello(@WebParam(name = "name") String name) { return "Hello " + name; } So we have finished creating the simple web service that will sayHello! Now just right click on the project and Run to deploy your brand new web service into JBoss.You should see the output once your Web service is successfully deployed.

17:35:26,221 INFO  [BasicEndpointRegistry] register: jboss.ws:context=JBossWSEJBModule,endpoint=HelloWebService
17:35:26,237 INFO  [LifecycleHandlerImpl] WebService started: http://127.0.0.1:8080/JBossWSEJBModule/HelloWebService
You can check your web service status by going to http://localhost:8080/jbossws/services Also, you can see that your new web service's WSDL is available at: http://127.0.0.1:8080/JBossWSEJBModule/HelloWebService?wsdl



Comments

Post new comment

The content of this field is kept private and will not be shown publicly.