bea.com | products | dev2dev | support | askBEA
 Download Docs   Site Map   Glossary 
Search

Programming WebLogic Web Services

 Previous Next Contents View as PDF  

Overview of WebLogic Web Services

The following sections provide an overview of Web Services, and how they are implemented in WebLogic Server:

 


What Are Web Services?

Web Services are a type of service that can be shared by and used as components of distributed Web-based applications. They commonly interface with existing back-end applications, such as customer relationship management systems, order-processing systems, and so on.

Traditionally, software application architecture tended to fall into two categories: huge monolithic systems running on mainframes or client-server applications running on desktops. Although these architectures work well for the purpose the applications were built to address, they are closed and can not be easily accessed by the diverse users of the Web.

Thus the software industry is evolving toward loosely coupled service-oriented applications that dynamically interact over the Web. The applications break down the larger software system into smaller modular components, or shared services. These services can reside on different computers and can be implemented by vastly different technologies, but they are packaged and transported using standard Web protocols, such as XML and HTTP, thus making them easily accessible by any user on the Web.

The concept of services is not new—RMI, COM, and CORBA are all service-oriented technologies. However, applications based on these technologies require them to be written using that particular technology, often from a particular vendor. This requirement typically hinders widespread acceptance of an application on the Web. To solve this problem, Web Services are defined to share the following properties that make them easily accessible from heterogeneous environments:

 


Why Use Web Services?

Major benefits of Web Services include:

Because you access Web Services using standard Web protocols such as XML and HTTP, the diverse and heterogeneous applications on the Web (which typically already understand XML and HTTP) can automatically access Web Services, and thus communicate with each other.

These different systems can be Microsoft SOAP ToolKit clients, J2EE applications, legacy applications, and so on. They are written in Java, C++, Perl, and other programming languages. Application interoperability is the goal of Web Services and depends upon the service provider's adherence to published industry standards.

 


Web Service Standards

A Web Service consists of the following components:

SOAP

SOAP (Simple Object Access Protocol) is a lightweight XML-based protocol used to exchange information in a decentralized, distributed environment. WebLogic Server includes its own implementation of SOAP 1.1, SOAP 1.2, and SOAP With Attachments specifications. The protocol consists of:

This information is embedded in a Multipurpose Internet Mail Extensions (MIME)-encoded package that can be transmitted over HTTP or other Web protocols. MIME is a specification for formatting non-ASCII messages so that they can be sent over the Internet.

The following example shows a SOAP request for stock trading information embedded inside an HTTP request:

POST /StockQuote HTTP/1.1
Host: www.sample.com
Content-Type: text/xml; charset="utf-8"
Content-Length: nnnn
SOAPAction: "Some-URI"
<SOAP-ENV:Envelope 
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<m:GetLastStockQuote xmlns:m="Some-URI">
<symbol>BEAS</symbol>
</m:GetLastStockQuote>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

WSDL 1.1

Web Services Description Language (WSDL) is an XML-based specification that describes a Web Service. A WSDL document describes Web Service operations, input and output parameters, and how to connect to the Web Service.

Developers of WebLogic Web Services do not need to create the WSDL files; you generate these files automatically as part of the WebLogic Web Services development process.

The following example, for informational purposes only, shows a WSDL file that describes the stock trading Web Service StockQuoteService that contains the method GetLastStockQuote:

<?xml version="1.0"?>
<definitions name="StockQuote"
targetNamespace="http://sample.com/stockquote.wsdl"
xmlns:tns="http://sample.com/stockquote.wsdl"
xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"
xmlns:xsd1="http://sample.com/stockquote.xsd"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns="http://schemas.xmlsoap.org/wsdl/">
<message name="GetStockPriceInput">
<part name="symbol" element="xsd:string"/>
</message>
<message name="GetStockPriceOutput">
<part name="result" type="xsd:float"/>
</message>
<portType name="StockQuotePortType">
<operation name="GetLastStockQuote">
<input message="tns:GetStockPriceInput"/>
<output message="tns:GetStockPriceOutput"/>
</operation>
</portType>
<binding name="StockQuoteSoapBinding" type="tns:StockQuotePortType">
<soap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="GetLastStockQuote">
<soap:operation soapAction="http://sample.com/GetLastStockQuote"/>
<input>
<soap:body use="encoded" namespace="http://sample.com/stockquote"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded" namespace="http://sample.com/stockquote"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>>
</binding>
<service name="StockQuoteService">
<documentation>My first service</documentation>
<port name="StockQuotePort" binding="tns:StockQuoteSoapBinding">
<soap:address location="http://sample.com/stockquote"/>
</port>
</service>
</definitions>

JAX-RPC

The Java API for XML-based RPC (JAX-RPC) is a Sun Microsystems specification that defines the client API for invoking a Web Service.

The following table briefly describes the core JAX-RPC interfaces and classes.

Table 1-1 JAX-RPC Interfaces and Classes

java.xml.rpc Interface or Class

Description

Service

Main client interface. Used for both static and dynamic invocations.

ServiceFactory

Factory class for creating Service instances.

Stub

Represents the client proxy for invoking the operations of a Web Service. Typically used for static invocation of a Web Service.

Call

Used to dynamically invoke a Web Service.

JAXRPCException

Exception thrown if an error occurs while invoking a Web Service.

For detailed information on JAX-RPC, see the following Web site: http://java.sun.com/xml/jaxrpc/index.html.

For a tutorial that describes how to use JAX-RPC to invoke Web Services, see http://java.sun.com/webservices/docs/ea1/tutorial/doc/JAXRPC.html.

UDDI 2.0

The Universal Description, Discovery and Integration (UDDI) specification defines a standard way to describe a Web Service; register a Web Service in a well-known registry; and discover other registered Web Services.

See http://www.uddi.org.

 


WebLogic Web Service Features

The WebLogic Web Services subsystem has the following features (new features in Version 8.1 of WebLogic Server are listed first:

 


Examples Of Creating and Invoking a Web Service

WebLogic Server includes the following example of creating and invoking WebLogic Web Services in the WL_HOME\samples\server\src\examples\webservices directory, where WL_HOME refers to the main WebLogic Platform directory:

For detailed instructions on how to build and run the example, open the following Web page in your browser:

WL_HOME\samples\server\src\examples\webservices\package-summary.html

Additional examples of creating and invoking WebLogic Web Services are listed on the Web Services Web page on the dev2dev Web site.

 


Creating WebLogic Web Services: Main Steps

The following procedure describes the high-level steps to create a WebLogic Web Service. Most steps are described in detail in later chapters.

Creating a WebLogic Web Service: A Simple Example, briefly describes an example of creating a Web Service.

  1. Design the WebLogic Web Service.

    Decide on a synchronous or asynchronous Web Service; the type of back-end components that implement the service; whether your service uses only built-in data types or custom data types; whether you need to intercept the incoming or outgoing SOAP message; and so on.

    See Designing WebLogic Web Services.

  2. Implement the WebLogic Web Service.

    Write the Java code of the back-end components that make up the Web Service; optionally create SOAP message handlers that intercept the SOAP messages; optionally create your own serialization class to convert data between XML and Java; and so on.

    See Implementing WebLogic Web Services.

  3. Assemble and package the WebLogic Web Service.

    Gather all the implementation class files into an appropriate directory structure; create the Web Service deployment descriptor file; create the supporting parts of the service (such as client JAR file); and package everything into a deployable EAR file.

    If your Web Service is fairly simple, use the servicegen Ant task which performs all the assembly steps for you. If your Web Service is more complicated, use additional Ant tasks or assemble the Web Service manually.

    See Assembling WebLogic Web Services Using Ant Tasks.

  4. Create a client that accesses the Web Service to test that your Web Service is working as you expect. You can also use the Web Service Home Page to test your Web Service.

    See Invoking Web Services.

  5. Deploy the WebLogic Web Service.

    Make the service available to remote clients. Because WebLogic Web Services are packaged as standard J2EE Enterprise applications, deploying a Web Service is the same as deploying an Enterprise application.

    See Deployment.

  6. Optionally publish your Web Service in a UDDI registry. See Publishing and Finding Web Services Using UDDI.

 


Unsupported Features

WebLogic Server does not support the following WSDL and XML Schema features:

 


Editing XML Files

When creating or invoking WebLogic Web Services, you might need to edit XML files, such as the web-services.xml Web Services deployment descriptor file, the EJB deployment descriptors, the Java Ant build files, and so on. You edit these files with the BEA XML Editor.

Note: This guide describes how to create or update the web-services.xml deployment descriptor manually so that programmers get a better understanding of the file and how the elements describe a Web Service. You can also use the BEA XML Editor to update the file.

The BEA XML Editor is a simple, user-friendly Java-based tool for creating and editing XML files. It displays XML file contents both as a hierarchical XML tree structure and as raw XML code. This dual presentation of the document gives you two options for editing the XML document:

The BEA XML Editor can validate XML code according to a specified DTD or XML schema.

For detailed information about using the BEA XML Editor, see its online help.

You can download the BEA XML Editor from dev2dev Online.

 

Back to Top Previous Next