Professional Documents
Culture Documents
Web Services are published, found, and used through the Web.
• HTML
• XML
If you want to study these subjects first, find the tutorials on our Home page.
XML provides a language which can be used between different platforms and programming
languages and still express complex messages and functions.
Web services use XML to code and to decode data, and SOAP to transport it (using open protocols).
With Web services, your accounting department's Win 2k server's billing system can connect with
your IT supplier's UNIX server.
There is things applications need very often. So why make these over and over again?
Web services can offer application-components like: currency conversion, weather reports, or even
language translation as services.
Web services can help to solve the interoperability problem by giving different applications a way to
link their data.
With Web services you can exchange data between different applications and different platforms.
Web Services have three basic platform elements: SOAP, WSDL and UDDI.
What is SOAP?
SOAP is an XML-based protocol to let applications exchange information over HTTP.
What is WSDL?
WSDL is an XML-based language for locating and describing Web services.
What is UDDI?
UDDI is a directory service where companies can register and search for Web services.
Imports System
Imports System.Web.Services
end class
This document is saved as an .asmx file. This is the ASP.NET file extension for XML Web Services.
Example Explained
Note: To run this example, you will need a .NET server.
The first line in the example states that this is a Web Service, written in VBScript, and has the class
name "TempConvert":
The next lines import the namespace "System.Web.Services" from the .NET framework:
Imports System
Imports System.Web.Services
The next line defines that the "TempConvert" class is a WebService class type:
The next steps are basic VB programming. This application has two functions. One to convert from
Fahrenheit to Celsius, and one to convert from Celsius to Fahrenheit.
The only difference from a normal application is that this function is defined as a "WebMethod()".
Use "WebMethod()" to convert the functions in your application into web services:
end class
Publish the .asmx file on a server with .NET support, and you will have your first working Web
Service.
If you look closer at our example Web Service, you will see that ASP.NET has automatically created
a WSDL and SOAP request.
Fahrenheit to Celsius:
Submit
Celsius to Fahrenheit:
Submit
How To Do It
Here is the code to add the Web Service to a web page:
<form
action='http://www.example.com/webservices/tempconvert.asmx/FahrenheitToCelsius'
method="post" target="_blank">
<table>
<tr>
<td>Fahrenheit to Celsius:</td>
<td><input class="frmInput" type="text" size="30" name="Fahrenheit"></td>
</tr>
<tr>
<td></td>
<td align="right"><input type="submit" value="Submit" class="button"></td>
</tr>
</table>
</form>
<form
action='http://www.example.com/webservices/tempconvert.asmx/CelsiusToFahrenheit'
method="post" target="_blank">
<table>
<tr>
<td>Celsius to Fahrenheit:</td>
<td><input class="frmInput" type="text" size="30" name="Celsius"></td>
</tr>
<tr>
<td></td>
<td align="right"><input type="submit" value="Submit" class="button"></td>
</tr>
</table>
</form>
Substitute the "www.example.com" in the code above with the address of your web site.
You have learned how to use XML to send messages between applications.
You have also learned how to export a function (create a web service) from your application.
WSDL
WSDL is an XML-based language for describing Web services and how to access them.
WSDL describes a web service, along with the message format and protocol details for the web
service.
If you want to learn more about WSDL, please visit our WSDL tutorial.
SOAP
SOAP is a simple XML-based protocol that allows applications to exchange information over HTTP.
If you want to learn more about SOAP, please visit our SOAP tutorial.
Web Services
Normally a Service represents any kind of feature or some piece of
functionality that a specific kind of client can take it from. For
example, a printer service, where the clients are either the
applications or the programs using the printers. Likewise, consumers
of an ATM service are Bank Customers. These are the list of real-world
services goes on in our daily-life.
Web services was first time introduced in EJB2.1, while EJB3.0 made
the web services development easy and more flexible. Here we are
going to describe the general concept of web services and then explain
them how the ejb supports to implement both the web services and
web services client.
• A service requestor uses the selection criteria to the query registry for finding the
services description.
• A service requestor can bind and use the service if it finds a suitable descriptor.
• Language Independent
• Operating System Independent
Language Independent:
Lets take a quick look over WSDL and UDDI, but we are not going to
cover these topics here because these are less useful. The requestor
does not necessarily have the registry to know the services and its end
point address. Registry not only supports a simple naming service but
also queries for the services that follow the given predicate.
WSDL: There is no need to write down the xml file. The tool you are
using automatically creates an xml file. A number of things are worth
nothing while using WSDL.
Two options are there to deploy an application, you can use one of the
two deployment options given below:
Java Class versus Stateless EJB: It depends upon you whether you
should have a regular Java class or EJBs as your technology to build a
Web Service. We can easily develop java classes than EJBs. Java
classes are pure java objects and do not have the extra baggage that
the EJBs do. One benefit of using EJB is that it supports the features
such as declarative transaction and security. EJB leaves free to the
developer just to concentrate only on applying the business logic
without worrying about the infrastructure services.
/WEB-INF/
web.xml
webservices.xml
oracle-webservices.xml
mapping-file.xml
wsdl/ it is wsdl
file
/classes/(includes
endpoint and bean classes)
/lib/
/META-INF/
ejb-jar.xml
webservices.xml
oracle-
webservices.xml
mapping-file.xml
wsdl/ the wsdl file
ejb classes (includes
endpoint and bean classes)
• WSDL: We are not going to discuss about the WSDL any more as we have
already discuss it in the previous section.
• Web Services Deployment Descriptor: webservices.xml is the standard
deployment descriptor that a JEE plateform requires. This descriptor specifies the
description for deployment about the set of web services into the JEE application
server and also their dependencies on the container resources and services. The
mapping.xml file that contains Java-to-WSDL mapping and the service endpoint
interface for the HelloWorld web service is also specified by this deployment
descriptor.
• Endpoint interface: The Web Service endpoint implements the java.rmi.Remote
interface therefore every method of web service endpoint interface must throw the
java.rmi.RemoteException. The deployment descriptor registers to the end point
for the module (ejb-jar.xml) or web.xml. The deployment descriptor (e.g. ejb-
jar.xml) should have the following entry.
<service-endpoint>
oracle.ejb21.ws.HelloServiceInf
</service-endpoint>
Following is the code for the Web Service endpoint for a HelloWorld
web service:
• Top-down approach: While building the services from scratch, this is the most
appropriate approach. With this approach start describing the service with WSDL
instead of jumping right into the implementation. This is the most preferable
approach since services become maintainable, more usable and interoperable due
to the control over the WSDL while deploying your web service, careful
consideration of the operations and message exposed. Several JEE vendors
provide tools to make the approach easier such as Oracle Application Server's
web services assembler generates deployment descriptors, interfaces and skeleton
implementation classes which can be used to build your application.
• Bottom-up approach: This approach is used whenever an existing Java class or
EJB is to be exposed as a Web Service. The reason behind the populalrity of this
approach is that, this approach allows to reuse the existing business logic without
rewriting the applications. While using this approach, you have to create a WSDL
to describe the Web Service along with other deployment descriptors and add a
web service end-point interface for the implementation to which you want to
expose as a Web Service. Tools provided by application servers (such as Oracle
Application Server's web services assembler tool) are used to make the life
simpler by generating the descriptors such as webservices.xml, WSDL and
mapping files for Web Services components free up the developer from manually
creating these files.
Tips for developing Web Services: Here are the some points
that must follow while developing Web Services.
• Most of the conventional best practices are for JEE applications that are relevant
to Web Services. for example, avoid exposing a component involve in the long-
run transaction as a Web Service.
• Confirm design of your Web Service so that it can create minimum network
traffic.
• Do not overuse Web Services in your applications. Check the necessity to expose
your application as a Web Service.
• Compare your security requirements with the performance of your application as
security comes with the higher cost. Performance of end-to-end security for web
services are quite costly.
Invoking Web Services: Web Service can have the client of any of
the following type: Dynamic Invocation Interface (DII) or dynamic
proxy, static stub.
<service-ref>
<service-ref-
name>service/HelloWorldService</service-ref-
name>
<service-
interface>oracle.ws.HelloWorldService</service-
interface>
<wsdl-file>META-
INF/HelloWorldService.wsdl</wsdl-file>
<service-qname>urn:oracle-ws</service-qname>
</service-ref>
• Allow your application to find Web Service just by specifying the location of the
Web Service in the vendor-specific deployment descriptor.
<service-ref-mapping
name="service/HelloWorldService">
<port-info>
<wsdl-port namespaceURI="urn: HelloWorldService"
localpart="HelloWorldServicePort"/>
<stub-property>
<name>javax.xml.rpc.service.endpoint.address</name>
<value>http://localhost:8888/hello/HelloWorldInf</value>
</stub-property>
</port-info>
</service-ref-mapping>
•
• Package type classes and end-point interface with your application before
deploying it to the server. Make the JNDI lookup to use a Web Service.
To develop a simple Java Web Service in JEE 1.4, several Web Service
artifacts such as mapping files, WSDL, proprietary web services
deployment descriptor and several verbose standard are designed in
JEE 5.0. Web Services Metadata specification receives a by default
configuration approach similar to EJB 3.0 for simplifying the
development process. Web Services Metadata annotation process
generates these files for you so just concentrate on the
implementation class.
package oracle.jr181.demo;
import javax.jws.WebMethod;
import javax.jws.WebService;
@WebService(name =
"HelloWorldService",
targetNamespace =
"http://hello/targetNamespace" )
public class HelloWorldService {
@WebMethod public String
sayhello(String name ) {
return "Hello” +name+ “ from
jws";
}
}
EJB 3.0 uses regular Java classes to simplify the development process.
EJB-based Web Services developed using EJB 3.0 and Web Services
Metadata, are much simpler. HelloWorld EJB is the example given
below developed by using EJB 3.0 and Web Services Metadata. Don't
worry while creating WSDL, deployment descriptors, etc., since the
application server generates these artifacts during deployment.
package oracle.ejb30.ws;
import javax.ejb.Remote;
import javax.jws.WebService;
@WebService
public interface HelloServiceInf extends
java.rmi.Remote{
@WebMethod java.lang.String
sayHello(java.lang.String name)
throws java.rmi.RemoteException;
}
package oracle.ejb30.ws;
import java.rmi.RemoteException;
import javax.ejb.Stateless;
@Stateless(name="HelloServiceEJB")
public class HelloServiceBean
implements HelloServiceInf {
public String sayHello(String name) {
return("Hello "+name +" from first
EJB3.0 Web Service");
}
}
The above example demonstrates the simplification of service
development while simplifying by using Web Services Metadata and
EJB 3.0.
Conclusion
This articles gives you the understanding about the basics of building
Web Services using the J2EE platform. You can build and deploy your
Web Services in J2EE-compliant application servers such as Sun Java
System Application Sever, Oracle Application Server 10g, etc.
Web service
Web services architecture.
Specifications
+Profiles
Additional specifications, WS
WS-Security
Defines how to use XML Encryption and XML Signature in SOAP to secure
message exchanges, as an alternative or extension to using HTTPS to secure the
channel.
WS-Reliability
An OASIS standard protocol for reliable messaging between two Web services.
WS-Transaction
A way of handling transactions.
WS-Addressing
Is a standard way to insert address in the SOAP header.
Styles of use
Web services are a set of tools that can be used in a number of
ways. The three most common styles of use are RPC, SOA and REST.
The first Web services tools were focused on RPC, and as a result this
style is widely deployed and supported. However, it is sometimes
criticised for not being loosely coupled, because it was often
implemented by mapping services directly to language-specific
functions or method calls. Many vendors felt this approach to be a
dead end, and pushed for RPC to be disallowed in the WS-I Basic
Profile.
Service-oriented architecture
WSDL version 2.0 offers support for binding to all the HTTP request
methods (not only GET and POST as in version 1.1) so it enables a
better implementation of RESTful Web services.[2] However, support
for this specification is still poor in software development kits, which
often offer tools only for WSDL 1.1.
Criticisms
Critics of non-RESTful Web services often complain that they are too
complex[3] and based upon large software vendors or integrators,
rather than open source implementations.
One big concern of the REST Web Service developers is that the SOAP
WS toolkits make it easy to define new interfaces for remote
interaction, often relying on introspection to extract the WSDL and
service API from Java, C# or VB code. This is viewed as a feature by
the SOAP stack authors (and many users) but it is feared that it can
increase the brittleness of the systems, since a minor change on the
server (even an upgrade of the SOAP stack) can result in different
WSDL and a different service interface. The client-side classes that can
be generated from WSDL and XSD descriptions of the service are often
similarly tied to a particular version of the SOAP endpoint and can
break if the endpoint changes or the client-side SOAP stack is
upgraded. Well designed SOAP endpoints (with handwritten XSD and
WSDL) do not suffer from this but there is still the problem that a
custom interface for every service requires a custom client for every
service.
There are also concerns about performance due to Web services' use
of XML as a message format and SOAP and HTTP in enveloping and
transport, however emerging XML parsing/indexing technologies, such
as VTD-XML, promise to address those XML-related performance
issues.
Similar efforts
Several other approaches exist to solve the set of problems that Web
services address, both preceding and contemporary to it. RMI was one
of many middleware systems that have seen wide deployment. More
ambitious efforts like CORBA and DCOM attempted to effect distributed
objects, which Web services implementations sometimes try to mimic.
More basic efforts include XML-RPC, a precursor to SOAP that was only
capable of RPC, and various forms of HTTP usage without SOAP.
List of Web service specifications
From Wikipedia, the free encyclopedia
Jump to: navigation, search
Contents
[hide]
• 17 See also
[edit] Privacy
• P3P
[edit] Other
• Devices Profile for Web Services (DPWS)
• ebXML
[edit] Standardization
• ISO/IEC 19784-2:2007 Information technology -- Biometric application
programming interface -- Part 2: Biometric archive function provider interface
• ISO 19133:2005 Geographic information -- Location-based services -- Tracking
and navigation
• ISO/IEC 20000-1:2005 Information technology -- Service management -- Part 1:
Specification
• ISO/IEC 20000-2:2005 Information technology -- Service management -- Part 2:
Code of practice
• ISO/IEC 24824-2:2006 Information technology -- Generic applications of ASN.1:
Fast Web Services
• ISO/IEC 25437:2006 Information technology -- Telecommunications and
information exchange between systems -- WS-Session -- Web Services for
Application Session Services