Hello Web Service end to end scenario
Author: Lukas Jungmann
Last update: $Date: 2009/10/29 16:50:43 $, $Revision: 1.1.1.1 $
Introduction:
This end to end scenario should test creation of simple web service
from scratch with simple logging message handler in web project.
The scenario covers developing of simple JAX-WS 2.0 based web service
with message handler.
The document is not intended as test specification for this
feature but describes developing simple web service in NetBeans 5.5.
Table of Contents
- Creating web project
- Creating web service
- Implementing web service
- Creating message handler
- Testing web service
Web application sources are avalaible here.
Creating web project
- Go to File - New Project - Web - Web Application
- Specify
HelloWsas Project Name - Specify project's directory
- Choose
Java EE 5as J2EE version and - Click
Finish
Creating web service
- Go to File - New File - Web services - Web Service - Next
- Specify name of web service, eg.
HelloWebService - Specify package for the web service, eg.
org.netbeans.end2end.hellosample - Click
Finish
Implementing web service
- Uncomment commented code in source file
- Add
serviceName="GreeterWs"toWebServiceannotation - Add
operationName="sayHi"toWebMethodannotation - Add
@WebParam(name="name")toString paramargument of methodoperation - Add new
sayHello(String): Stringoperation to web service usingWeb Service -> Add Operation...action in editor - Implement both operation, so the implementation class will look like this:
Creating message handler
- Go to File - New File - Web services - Message Handler - Next
- Specify name of message handler, eg.
MessageHandler - Specify package for the message handler, eg.
org.netbeans.end2end.hellosample - Click
Finish - Implement simple
logmethod in handler, eg. like on following picture: - And add handler to the webservice using
Configure Handlers...action in context menu onHelloWebService's node
Testing web service
Now we finished our web application with web service and we're ready to build and deploy it and check web service if it works correctly.
- Invoke
Deployaction from project's context menu - Invoke
Test Web Serviceaction from web service's context menu
Let's test web service using the form opened in web browser:
