How to create WebService in JBoss AS7 using eclipse.

JBoss Application Server 7.1 comes bundled with JBossWS component. This component is based on Apache CXF. So those people who know Apache CXF, you will love JBoss AS.

First of all, you need to have few basic requirements:

JDK 1.7 (JDK 1.6 is sufficient, but using newest one is recommended)

eclipse indigo (Java EE developer) from eclipse.org

JBoss AS7

JBoss Tools:

You cannot immediately start developing applications for JBoss AS7. You need to get Plugins for your eclipse.

Open eclipse –> Help –> Install new software

add following URL :  http://download.jboss.org/jbosstools/updates/development/indigo

now expand “JBoss Web and JavaEE development”

select following components:

  • JBossAS Tools
  • JBoss WebServices Tools
  • Hibernate Tools
  • JBoss JAX-RS Tools

Now, install all these components.

Once installation in complete, you need to restart eclipse.

Now, add JBoss AS7 as WebServer to your eclipse workspace.

Now, click finish to add JBossAS7 to your eclipse workspace.

Create new Dynamic Web Project:

now, click on “Modify” button to change configuration, select “JBoss Web Services Core”

Click OK –> next –> Generate Web.xml = true –> Next

Image

Select “Server Supplied JBossWS runtime”

click Finish.

Create new class: Calculator

Image

NOTE: This step can be safely SKIPPED!

Create new WebService:

click on WebService Runtime: Apache Axix (in configuration section above) select JBossWS

Click OK

Image

Click Next

Select both option –> Next

Click on “Start Server” –> Wait for Server startup –> Next –> Finish

Now, right click on your project name (My project name is “MyServiceApp1” –>Run as –> Run on Server

change URL in web-browser to include your service name eg. http://localhost:8080/MyServiceApp1/Calculator?wsdl

(Please change port no and application name if they are different)

I you get to see wsdl for newly created web services then you are done!

You can now test this web service using eclipse:

goto Run menu –> Lauch web services explorer

Image

click on “WSDL page” button in top-right¬† corner

Image

Once you click on “Go” button, you will be presented a page where you can test this Service

Image

now, click on link to method “sum”

enter two value and click go..

Image

It’s done….

Advertisements