Saturday, February 16, 2013

How to Create, Test Webservice using Jdeveloper

Usecase : How to create & test a webservice using Jdeveloper

What is Web Service ?

A web service is a function that can be accessed by other programs over the web (Http).

Webservices are two types as follows 

1. SOAP(Simple Object Access Protocol) Webservice - SOAP Web Services are standard-based and supported by almost every software platform: They rely heavily in XML and have support for transactions, security, asynchronous messages and many other issues. It’s a pretty big and complicated standard, but covers almost every messaging situation. On the other side.

2. REST Webservice -

Representational State Transfer (REST) is an architectural style that specifies constraints, such as the uniform interface, that if applied to a web service induce desirable properties, such as performance, scalability, and modifiability, that enable services to work best on the Web.

RESTful services relies of HTTP protocol and verbs (GET, POST, PUT, DELETE) to interchange messages in any format, preferable JSON and XML. It’s a pretty simple and elegant architectural approach.
As in every topic in the Java World, there are several libraries to build/consume Web Services. In the SOAP Side you have the JAX-WS standard and Apache Axis, and in REST you can use Restlets or Spring REST Facilities among other libraries.

RESTful Services are appropriate in this scenarios:

If you have limited bandwidth
If your operations are stateless: No information is preserved from one invocation to the next one, and each request is treated independently.
If your clients require caching.

SOAP Services are appropriate in below scenarios

If you require asynchronous processing
If you need formal contract/Interfaces
In your service operations are stateful: For example, you store information/data on a request and use that stored data on the next one.

Implementation :

 - Create a simple Java class with a method called sayHello() as shown in below screenshot


- Right click on Java class, which need to be generated as web service, Choose 'Create Webservice' option

- Give web service name and port name

Choose SOAP binding version

Select the method want to expose in web service, Follow Next, Next..

 - Once the web service is created, Right click on web service and choose 'Test Web Service' option

- Test the web service as shown in below screen shot.



- Here is the webservice URL, and this can be consumed by any client using SOAP protocol.


http://localhost:7101/HelloWorldWebservice-Model-context-root/HelloWorldWSPort?wsdl

For More information about weservices 



No comments:

Post a Comment