Introduction to NetBeans Web Services

jetmorebrisketΛογισμικό & κατασκευή λογ/κού

15 Αυγ 2012 (πριν από 5 χρόνια και 1 μέρα)

256 εμφανίσεις

Introduction to NetBeans Web
Services





2

NetBeans Web Services


REST
-
based.

RE
presentational
S
tate
T
ransfer is a new
way to create and communicate with web services. In
REST, resources have URIs and are manipulated through
HTTP header operations. For more details, see
RESTful
Web Services
.


SOAP/WSDL
-
based.

In traditional web service models,
web service interfaces are exposed through WSDL
documents (a type of XML), which have URLs. Subsequent
message exchange is in SOAP, another type of XML
document. For more details, see
SOAP
-
based Web
Services
.

3

REST
-
based Web Services


REST
-
based ("RESTful") web services are collections of
web resources identified by URIs.


Every document and every process is modeled as a web
resource with a unique URI.


These web resources are manipulated by the actions that
can be specified in an HTTP header.


Neither SOAP, nor WSDL, nor WS
-
* standards are used.
Instead, message exchange can be conducted in any
format

XML, JSON, HTML, etc. In many cases a web
browser can serve as the client.

4

REST
-
based Web Services


HTTP is the protocol in REST. Only four methods are
available: GET, PUT, POST, and DELETE.


Requests can be bookmarked and responses can be
cached. A network administrator can easily follow what is
going on with a RESTful service just by looking at the HTTP
headers.

5

REST
-
based Web Services


Software Needed for the Tutorial


Before you begin, you need to download and install the
following software on your computer:


NetBeans IDE 6.0 Web & Java EE installation (
download
).


Java Standard Development Kit (JDK) version 5.0 or
above with Java EE (
download
).


Glassfish V2 Web Server, which is bundled with the
NetBeans IDE 6.0 Web & Java EE installation.


In the IDE, go to the Plugin Manager, under the Tools
menu, and install the RESTful Web Services plugin, as
shown below (
Note:

This tutorial has been updated to
use the version 0.5 plugin).


6

REST
-
based Web Services


Introduction



Generating Entity Classes from a Database



Generating RESTful Web Services from Entity
Classes



Testing the RESTful Web Services



Adding a Google Map Feature

7

SOAP
-
based Web Services


In SOAP
-
based web services, Java utilities create a WSDL
file based on the Java code in the web service. The WSDL
is exposed on the net.


Parties interested in using the web service create a Java
client based on the WSDL.


Messages are exchanged in SOAP format. The range of
operations that can be passed in SOAP is much broader
than what is available in REST, especially in security.


SOAP
-
based web services are suitable for heavyweight
applications using complicated operations and for
applications requiring sophisticated security, reliability or
other WS
-
* standards
-
supported features.


8

SOAP
-
based Web Services


They are also suitable when a transport protocol other than HTTP
has to be used. Many of Amazon's web services, particularly those
involving commercial transactions, and the web services used by
banks and government agencies are SOAP
-
based.


The Java API for XML Web Services (JAX
-
WS) is the current
model for SOAP
-
based web services in Metro.


JAX
-
WS is built on the earlier JAX
-
RPC model but uses specific
Java EE 5 features, such as annotations, to simplify the task of
developing web services.


Because it uses SOAP for messaging, JAX
-
WS is transport neutral.


It also supports a wide range of modular WS
-
* specifications,
such as WS
-
Security and WS
-
ReliableMessaging.



9

SOAP
-
based Web Services


Software Needed for the Tutorial


Before you begin, you need to install the following
software on your computer:


NetBeans IDE 6.0 Web & Java EE (
download
).


Java Standard Development Kit (JDK) version 5.0 or
version 6.0 (
download
).


Glassfish V2 or Tomcat Web Server, both of which you
can select from the installer that you use to install
NetBeans IDE 6.0.


10

SOAP
-
based Web Services


Creating a Web Service


Designing the Web Service


Deploying and Testing the Web Service


Consuming the Web Service in


a Java class in a Java SE Application


a servlet in a web application


a JSP page in a web application