Saturday, 15 August 2015

Java Source World: What is webservices


Javasourceworld                   A Java quick reference blog

Web Services



A Web service is any piece of software that makes itself available over the Internet and uses a standardized XML messaging system. XML is used to encode all communications to a Web service. 

For example, a client invokes a Web service by sending an XML message, then waits for a corresponding XML response. Because all communication is in XML, Web services are not tied to any one operating system or programming language--Java can talk with Perl; Windows applications can talk with Unix applications. Beyond this basic definition, a Web service may also have two additional (and desirable) properties:

 First, a Web service can have a public interface, defined in a common XML grammar. The interface describes all the methods available to clients and specifies the signature for each method. Currently, interface definition is accomplished via the Web Service Description Language (WSDL). 

Second, if you create a Web service, there should be some relatively simple mechanism for you to publish this fact. Likewise, there should be some simple mechanism for interested parties to locate the service and locate its public interface. The most prominent directory of Web services is currently available via UDDI, or Universal Description, Discovery, and Integration.

Web services can be implemented in various ways. Web services can be classified as “Big” web services and “RESTful” web services.

In Java EE 6, JAX-WS provides the functionality for “big” web services, Big web services use XML messages that follow the Simple Object Access Protocol (SOAP) standard, an XML language defining a message architecture and message formats. Such systems often contain a machine-readable description of the operations offered by the service, written in the Web Services Description Language (WSDL), an XML language for defining interfaces syntactically.

SOAP Web Services:

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 may other issues. It's a pretty big and complicated and standard, but covers almost every messaging situation.

As in every topic in the java world, there are several libraries to build/consume web services. In the SOAP side we have the JAAX-WS standard and Apache Axis.

SOAP is appropriate in the fallowing scenarios:
  •                If you require asynchronous processing
  •                If you need formal contract/Interfaces.
JavaEE defines a whole bunch of APIs which are basically only interfaces, no implementations. JAX-WS is the API for SOAP based web services.

The implementation that is used depends on the Java container we use.Metro is the implementation bundled with the glassfish EE server,jboss used JBOSS-WS.

AXIS is yet another implementation that supports JAX-WS. There is also CXF and many others.

SOAP is the industry standard because there are a lot of standardized features and it has a descriptor in the form of WSDL (WADL for REST just isn't there yet).The descriptor (generated automatically by JAX-WS) describes the client how the web services should be involved and works.

It is trivial to import a WSDL generated by java in .NET for example.  

REST Web Services:

RESTful services relies of HTTP protocol and verbs (GET, POST, PUT, DELETE) to interchange messages in any format, preferable JSON and XML.

In REST you can use Restless or spring REST facilities among other libraries.

Restful services are appropriated 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 client require caching.

JAX-RS is the API for REST based web services. REST easier to understand because it is very light weight.


Read more:


                                                                  Javasourceworld                   A Java quick reference blog





No comments:

Post a Comment