Programming WebLogic Web Services
Programming WebLogic Web Services
Server ™
Programming WebLogic
Web Services
Version 8.1
Revised: June 28, 2006
Copyright
Copyright © 2004 BEA Systems, Inc. All Rights Reserved.
2. Architectural Overview
Overview of WebLogic Web Services Architecture. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-1
Back-end Component Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2
Back-end Component and SOAP Message Handler Chain Operation . . . . . . . . . . . . . . . 2-3
SOAP Message Handler Chain Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-4
13.Configuring Security
Overview of Web Services Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-1
What Type of Security Should You Configure? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-2
14.Internationalization
Overview of Internationalization. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-1
Internationalizing a WebLogic Web Service. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-2
Specifying the Character Set for a WebLogic Web Service . . . . . . . . . . . . . . . . . . . 14-2
Updating the web-services.xml File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-2
Setting a WebLogic Server System Property . . . . . . . . . . . . . . . . . . . . . . . . . . 14-3
Order of Precedence of Character Set Configuration Used By WebLogic Server. . 14-3
Invoking a Web Service Using a Specific Character Set . . . . . . . . . . . . . . . . . . . . . . . . 14-4
Setting the Character Set When Invoking a Web Service . . . . . . . . . . . . . . . . . . . . 14-4
Character Set Settings in HTTP Request Headers Honored by WebLogic Web Services
14-5
19.Interoperability
Overview of Interoperability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19-1
Avoid Using Vendor-Specific Extensions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19-2
Stay Current With the Latest Interoperability Tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19-2
Understand the Data Models of Your Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19-3
Understand the Interoperability of Various Data Types . . . . . . . . . . . . . . . . . . . . . . . . . 19-3
Results of SOAPBuilders Interoperability Lab Round 3 Tests . . . . . . . . . . . . . . . . . . . . 19-5
Interoperating With .NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19-5
20.Troubleshooting
Using the Web Service Home Page to Test Your Web Service . . . . . . . . . . . . . . . . . . . 20-2
URL Used to Invoke the Web Service Home Page . . . . . . . . . . . . . . . . . . . . . . . . . 20-2
Testing the Web Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20-4
Viewing SOAP Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20-4
Setting Verbose Mode with Ant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20-4
Setting Verbose Mode Programatically . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20-5
Posting the HTTP SOAP Message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20-5
Composing the SOAP Request. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20-7
Debugging Problems with WSDL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20-8
Verifying a WSDL File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20-9
Verifying an XML Schema . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20-10
Debugging Data Type Generation (Autotyping) Problems . . . . . . . . . . . . . . . . . . . . . . 20-10
Common XML Schema Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20-10
Common Java Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20-11
Debugging Performance Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20-11
This document describes BEA WebLogic® Web Services and describes how to develop them
and invoke them from a client application.
The document is organized as follows:
z Chapter 4, “Designing WebLogic Web Services,” describes the design issues you should
consider before developing a WebLogic Web Service.
z Chapter 5, “Implementing WebLogic Web Services,” describes how to create the back-end
components that implement a Web Service.
z Chapter 6, “Assembling WebLogic Web Services Using Ant Tasks,” describes how to use
the WebLogic Web Services Ant tasks to automatically generate the final parts of a Web
Service (such as the serialization information for non-built-in data types and client JAR
file), package them all together into a deployable EAR file, and deploy the EAR file on
WebLogic Server.
z Chapter 7, “Invoking Web Services from Client Applications and WebLogic Server,”
describes how to write a client application that invokes WebLogic Web Services.
z Chapter 8, “Using the WebLogic Web Services APIs,” describes how to use the WebLogic
Web Services APIs in your client applications.
z Chapter 9, “Using JMS Transport to Invoke a WebLogic Web Service,” describes how to
configure your Web Service so that client applications can use JMS, rather than the default
HTTP/S, as the transport when invoking a Web Service.
z Chapter 10, “Using Reliable SOAP Messaging,” describes how you can asynchronously
and reliably invoke a Web Service running on another WebLogic Server instance.
z Chapter 11, “Using Non-Built-In Data Types,” describes how to create the serializers and
deserializers that convert user-defined data types between their XML and Java
representations.
z Chapter 12, “Creating SOAP Message Handlers to Intercept the SOAP Message,”
describes how to create handlers that intercept a SOAP message for further processing.
z Chapter 13, “Configuring Security,” describes how to configure security for WebLogic
Web Services.
z Chapter 14, “Internationalization,” describes how to specify the character set for a
WebLogic Web Service and in a client application that invokes a Web Service.
z Chapter 15, “Using SOAP 1.2,” describes how you can use SOAP 1.2, rather than the
default SOAP 1.1. as the message format when invoking a WebLogic Web Service.
z Chapter 17, “Administering WebLogic Web Services,” describes how to use the
Administration Console to administer WebLogic Web Services.
z Chapter 18, “Publishing and Finding Web Services Using UDDI,” describes how to use the
UDDI features included in WebLogic Server.
z Chapter 19, “Interoperability,” describes what it means for Web Services to interoperate
with each other and provides tips for creating highly interoperable Web Services.
z Chapter 22, “Using WebLogic Workshop With WebLogic Web Services,” describes how to
use WebLogic Workshop with WebLogic Web Services.
z Appendix B, “Web Service Ant Tasks and Command-Line Utilities,” describes the Ant
tasks, along with their equivalent command-line utilities, used to assemble WebLogic Web
Services.
Audience
This document is written for Java developers who want to create a Web Service that runs on
WebLogic Server.
It is assumed that readers know Web technologies, XML, and the Java programming language.
A PDF version of this document is available on the WebLogic Server documentation Home page
on the e-docs Web site (and also on the documentation CD). You can open the PDF in Adobe
Acrobat Reader and print the entire document (or a portion of it) in book format. To access the
PDFs, open the WebLogic Server documentation Home page, click Download Documentation,
and select the document you want to print.
Adobe Acrobat Reader is available at no charge from the Adobe Web site at
http://www.adobe.com.
Contact Us!
Your feedback on BEA documentation is important to us. Send us e-mail at
[email protected] if you have questions or comments. Your comments will be reviewed
directly by the BEA professionals who create and update the documentation.
In your e-mail message, please indicate the software name and version you are using, as well as
the title and document date of your documentation. If you have any questions about this version
of BEA WebLogic Server, or if you have problems installing and running BEA WebLogic
Server, contact BEA Customer Support through BEA WebSupport at http://www.bea.com. You
can also contact Customer Support by using the contact information provided on the Customer
Support Card, which is included in the product package.
When contacting Customer Support, be prepared to provide the following information:
Documentation Conventions
The following documentation conventions are used throughout this document.
monospace Code samples, commands and their options, Java classes, data types,
text directories, and file names and their extensions. Monospace text also
indicates text that you enter from the keyboard.
Examples:
import java.util.Enumeration;
chmod u+w *
config/examples/applications
.java
config.xml
float
Convention Usage
... Indicates one of the following in a command line:
• An argument can be repeated several times in the command line.
• The statement omits additional optional arguments.
• You can enter additional parameters, values, or other information
. Indicates the omission of items from a code example or from a syntax line.
.
.
The following sections provide an overview of Web Services, and briefly describe how they are
implemented in WebLogic Server:
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 has evolved toward loosely coupled service-oriented applications that
interact dynamically 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.
This 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:
z Web Services communicate with clients (both end-user applications or other Web Services)
through XML messages that are transmitted by standard Internet protocols, such as HTTP.
z Interoperability among distributed applications that span diverse hardware and software
platforms
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.
z A standard for transmitting data and Web Service invocation calls between the Web
Service and the user of the Web Service.
WebLogic Web Services use Simple Object Access Protocol (SOAP) 1.1 and 1.2 as the
message format and HTTP and JMS as the connection protocol. See “SOAP” on page 1-4.
z A standard for describing the Web Service to clients so they can invoke it.
WebLogic Web Services use Web Services Description Language (WSDL) 1.1, an
XML-based specification, to describe themselves. See “WSDL 1.1” on page 1-5.
z A standard for digitally signing and encrypting the SOAP request and response messages
between a client application and the Web Service it is invoking.
WebLogic Web Services implement the following OASIS Standard 1.0 Web Services
Security specifications, dated April 6 2004:
– Web Services Security: SOAP Message Security
– Web Services Security: Username Token Profile
– Web Services Security: X.509 Token Profile
For more information, see “Web Services Security (WS-Security)” on page 1-7.
z A standard for client applications to find a registered Web Service and to register a Web
Service.
WebLogic Web Services implement the Universal Description, Discovery, and Integration
(UDDI) specification. See “UDDI 2.0” on page 1-8.
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 (SAAJ) specifications.
The protocol consists of:
z An envelope that describes the SOAP message. The envelope contains the body of the
message, identifies who should process it, and describes how to process it.
<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>
For more information, see SOAP 1.1 at http://www.w3.org/TR/SOAP and SOAP With
Attachments API for Java (SAAJ) 1.1 at http://java.sun.com/xml/saaj/index.html.
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 a client application connects 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>
For more information, see Web Services Description Language (WSDL) 1.1 at
http://www.w3.org/TR/wsdl.
JAX-RPC 1.0
The Java API for XML-based RPC (JAX-RPC) 1.0is a Sun Microsystems specification that
defines the Web Services APIs.
WebLogic Server implements all required features of the JAX-RPC Version 1.0 specification.
Additionally, WebLogic Server implements optional data type support, as specified in:
z “Non-Built-In Data Types Supported by servicegen and autotype Ant Tasks” on page 6-18
WebLogic Server does not implement optional features of the JAX-RPC specification, other than
what is described in these sections.
The following table briefly describes the core JAX-RPC interfaces and classes.
Service Main client interface. Used for both static and dynamic
invocations.
Stub Represents the client proxy for invoking the operations of a Web
Service. Typically used for static invocation of a Web Service.
These mechanisms can be used independently (for example, to pass a security token) or in
a tightly integrated manner (for example, signing and encrypting a message and providing
a security token hierarchy associated with the keys used for signing and encryption).
For more information, see the OASIS Web Service Security Web page at
http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=wss.
UDDI 2.0
The Universal Description, Discovery and Integration (UDDI) specification defines a standard
for describing a Web Service; registering a Web Service in a well-known registry; and
discovering other registered Web Services.
For more information, see http://www.uddi.org.
The clientgen Ant task can now generate stubs for invoking a Web Service operation
asynchronously. The stub contains two methods: the first invokes the operation with the
required parameters but does not wait for the result to return; later, the second method
returns the actual results. You use this asynchronous client when using reliable SOAP
messaging. See “Writing an Asynchronous Client Application” on page 7-11.
z Implementation of the SOAP with Attachments API For Java (SAAJ) 1.1 - New 8.1
Feature
SAAJ enables developers to produce and consume messages conforming to the SOAP 1.1
specification and SOAP with Attachments note. This specification is derived from the
javax.xml.soap package originally defined in the JAXM 1.0 specification.
See “Directly Manipulating the SOAP Request and Response Message Using SAAJ” on
page 12-12 for information about using SAAJ in a SOAP message handler to view and
manipulate a SOAP attachment.
z Standard Specifications
See “Web Service Standards” on page 1-3.
z Point-to-Point Security
WebLogic Server supports connection oriented point-to-point security for WebLogic Web
Service operations, as well as authorization and authentication of Web Service operations.
See “Configuring Transport-Level Security (SSL): Main Steps” on page 13-31.
z Interoperability
WebLogic Web Services interoperate with major Web Service platforms such as Microsoft
.NET.
Unsupported Features
The following list describes the features that are not supported in this release of WebLogic Web
Services:
z WebLogic Server does not support the XMLBeans data type as an input parameter or
return value of a Web Service operation.
z WebLogic Server does not support the following XML Schema features:
– Complex data type inheritance by restriction
– Union simple data types
– References to named model groups
– Nested content models in a single complex type
– Redefinition of declarations
– Identity constraints (key, keyref, unique)
– Nested XSD model groups with other content models at the same level.
There cannot be a modelgroup (say sequence) that contains another nested modelgroup
(say choice), and a content element (say element). So, if a nested modelgroup is
required, make sure that it contains only another model group and no other content
element.
– Wildcards
– Substitution groups
Note: If you use the autotype, servicegen, or clientgen Ant tasks to generate the
serialization components for any non-built-in XML Schema data type that uses one
of the preceding constructs (either directly or by containing a type that uses them),
the Ant tasks map that data type to javax.xml.soap.SOAPElement. This gives you
access to the full XML via a DOM-like API.
Additionally, the autotype Ant task does not comply with the JAX-RPC
specification if the XML Schema data type (for which it is generating the Java
representation) has certain characteristics; see “Data Type Non-Compliance with
JAX-RPC” on page 6-21 for details.
z basic.javaclass: Uses a Java class back-end component with built-in data types as its
parameters and return value.
WL_HOME/samples/server/examples/src/examples/webservices/package-summary.html
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 individual Ant tasks.
See Chapter 6, “Assembling WebLogic Web Services Using Ant Tasks.”
5. 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 Chapter 7, “Invoking Web Services from Client Applications and WebLogic Server.”
6. Configure additional WebLogic Web Service features, such as security, reliable SOAP
messaging, JMS transport, internationalization, and so on. See:
– Chapter 13, “Configuring Security”
– Chapter 10, “Using Reliable SOAP Messaging”
– Chapter 9, “Using JMS Transport to Invoke a WebLogic Web Service”
– Chapter 14, “Internationalization”
9. Optionally publish your Web Service in a UDDI registry. See Chapter 18, “Publishing and
Finding Web Services Using UDDI.”
Create (implement) the Web Service “Overview of Implementing a WebLogic Web Service” on page 5-1
back-end components.
“Writing the Java Code for the Components” on page 5-3
Assemble the Web Service into a “Overview of Assembling WebLogic Web Services Using Ant Tasks”
deployable unit. on page 6-1
Deploy and test the Web Service. “Deploying and Testing WebLogic Web Services” on page 6-23
Invoke the Web Service. “Overview of Invoking Web Services” on page 7-2
Secure the Web Service. “Overview of Web Services Security” on page 13-1
Upgrade a 6.1 or 7.0 WebLogic Web “Upgrading a 7.0 WebLogic Web Service to 8.1” on page 21-1
Service.
“Upgrading a 6.1 WebLogic Web Service to 8.1” on page 21-2
Troubleshoot problems. “Using the Web Service Home Page to Test Your Web Service” on
page 20-2
z The hierarchical tree view allows structured, constrained editing, with a set of allowable
functions at each point in the hierarchical XML tree structure. The allowable functions are
syntactically dictated and in accordance with the XML document's DTD or schema, if one
is specified.
z The raw XML code view allows free-form editing of the data.
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 at
http://dev2dev.bea.com/resourcelibrary/utilitiestools/xml.jsp.
Architectural Overview
The following sections provide an overview of WebLogic Web Services architecture and three
types of WebLogic Web Service operations:
z “Back-end Component and SOAP Message Handler Chain Operation” on page 2-3
WebLogic Server
1 2
3
SOAP request SOAP
Client Application
Invoke target
back-end
component
Java
Serialize Java return value
to XML
SOAP response
6 over HTTP 5
Here is what happens when a client application invokes this type of WebLogic Web Service
operation:
1. The client application sends a SOAP message request to WebLogic Server over HTTP. Based
on the URI in the request, WebLogic Server identifies the Web Service being invoked.
2. The Web Service reads the SOAP message request and identifies the operation that it needs
to run. The operation corresponds to a method of a stateless session EJB or a Java class, to
be invoked in a later step.
3. The Web Service converts the operation’s parameters in the SOAP message from their
XML representation to their Java representation using the appropriate deserializer class.
The deserializer class is either one provided by WebLogic Server for built-in data types or a
user-created one for non-built-in data types.
4. The Web Service invokes the appropriate back-end component method, passing it the Java
parameters.
5. The Web Service converts the method’s return value from Java to XML using the
appropriate serializer class, and packages it into a SOAP message response.
6. The Web Service sends the SOAP message response back to the client application that
invoked the Web Service.
Figure 2-2 WebLogic Web Service Operation with Back-end Component and SOAP Message Handler Chain
1 WebLogic Server
SOAP Possibly
request modified 4
2 3
over HTTP SOAP
SOAP
Client Application
Invoke target
back-end
component
1. The client application sends a SOAP message request to WebLogic Server over HTTP. Based
on the URI in the request, WebLogic Server identifies the Web Service being invoked.
2. The Web Service reads the SOAP message request and identifies the operation that it needs
to run. The operation in this case corresponds to a SOAP message handler chain followed
by a method of a stateless session EJB or a Java class, to be invoked in later steps.
3. The Web Service invokes the appropriate handler chain. The handler chain accesses the
contents of the SOAP message request, possibly changing it in some way.
4. The Web Service converts the operation’s parameters in the [possibly modified] SOAP
message from their XML representation to their Java representation using the appropriate
deserializer class. The deserializer class is either one provided by WebLogic Server for
built-in data types or a user-created one for non-built-in data types.
5. The Web Service invokes the appropriate back-end component method, passing it the Java
parameters.
6. The Web Service converts the method’s return value from Java to XML using the
appropriate serializer class, and packages it into a SOAP message response.
7. The Web Service invokes the appropriate SOAP message handler chain. The handler chain
accesses the contents of the SOAP message response, possibly changing it in some way.
8. The Web Service sends the [possibly modified] SOAP message response back to the client
application that invoked the Web Service.
Figure 2-3 WebLogic Web Service Operation with SOAP Message Handler Chain Only
WebLogic Server
Client Application
1 2
3
SOAP request SOAP
over HTTP Identify request Invoke
Operation Handler
Chain
Invoke
Handler
Chain
Modified
5
SOAP response 4
over HTTP
Here is what happens when a client application invokes this type of WebLogic Web Service
operation:
1. The client application sends a SOAP message request to WebLogic Server over HTTP. Based
on the URI in the request, WebLogic Server identifies the Web Service being invoked.
2. The Web Service reads the SOAP message request and identifies the operation that it needs
to run. The operation in this case corresponds to an invoke of a SOAP message handler
chain, to be invoked in the next step.
3. The Web Service invokes the appropriate handler chain. The handler chain accesses the
contents of the SOAP message request, possibly changing it in some way.
4. The Web Service invokes the appropriate handler chain. The handler chain creates the
SOAP message response.
5. The Web Service sends the SOAP message response back to the client application that
invoked the Web Service.
The following sections describe how to create a simple WebLogic Web Service:
z “Building and Running the Trader WebLogic Web Service Example” on page 3-2
The example shows how to create a WebLogic Web Service based on a stateless session EJB. The
example uses the Trader EJB, one of the EJB 2.0 examples located in the
WL_HOME/samples/server/examples/src/examples/ejb20/basic/statelessSession
directory.
The Trader EJB defines two methods, buy() and sell(), that take as input a String stock
symbol and an int number of shares to buy or sell. Both methods return a non-built-in data type
called TradeResult.
When the Trader EJB is converted into a Web Service, the two methods become public
operations defined in the WSDL of the Web Service. The Client.java application uses a
JAX-RPC style client API to create SOAP messages that invoke the operations.
3. Change to the
WL_HOME\samples\server\examples\src\examples\webservices\complex\statel
essSession directory.
4. Assemble and compile the example by executing the Java ant utility at the command line:
prompt> ant
The ant utility uses the build.xml build script to perform the following tasks:
– Create an EJB JAR file from the EJB *.java files.
– Execute the servicegen Ant task which automatically generates the serialization class
for the TradeResult non-built-in data type, creates the web-services.xml file, and
packages all these components into a deployable EAR file.
– Deploy the EAR file on WebLogic Server.
– Execute the clientgen Ant task to create a local client JAR file that contains all the
needed classes and interfaces to invoke the Web Service.
– Compile the Client.java client application used to invoke the Web Service.
5. In your development shell, run the Client Java application using the following command:
prompt> ant run
If the example runs successfully, you should see the following output in both the window
from which you ran the client application and the WebLogic Server console window:
[java] Buying 100 shares of BEAS.
[java] Result traded 100 shares of BEAS
[java] Buying 200 shares of MSFT.
[java] Result traded 200 shares of MSFT
[java] Buying 300 shares of AMZN.
[java] Result traded 300 shares of AMZN
[java] Buying 400 shares of HWP.
[java] Result traded 400 shares of HWP
[java] Selling 100 shares of BEAS.
[java] Result traded 100 shares of BEAS
[java] Selling 200 shares of MSFT.
[java] Result traded 200 shares of MSFT
[java] Selling 300 shares of AMZN.
[java] Result traded 300 shares of AMZN
[java] Selling 400 shares of HWP.
[java] Result traded 400 shares of HWP
6. Optionally view the Web Service Home Page by entering the following URL in your
browser:
http://localhost:port/webservice/TraderService
where
– localhost refers to the machine on which WebLogic Server is running.
– port refers to port on which WebLogic Server is listening.
From the Web Service Home Page you can view the generated WSDL, and test the Web
service to make sure it is working correctly.
z “The servicegen Ant Task That Assembles the Web Service” on page 3-11
import java.rmi.RemoteException;
import javax.ejb.EJBObject;
/**
* The methods in this interface are the public face of TraderBean.
* The signatures of the methods are identical to those of the EJBean, except
* that these methods throw a java.rmi.RemoteException.
* Note that the EJBean does not implement this interface. The corresponding
* code-generated EJBObject, TraderBeanE, implements this interface and
* delegates to the bean.
*
* @author Copyright (c) 1999-2003 by BEA Systems, Inc. All Rights Reserved.
*/
public interface Trader extends EJBObject {
/**
* Buys shares of a stock.
*
* @param stockSymbol String Stock symbol
* @param shares int Number of shares to buy
* @return TradeResult Trade Result
* @exception RemoteException if there is
* a communications or systems failure
*/
public TradeResult buy (String stockSymbol, int shares)
throws RemoteException;
/**
* Sells shares of a stock.
*
* @param stockSymbol String Stock symbol
* @param shares int Number of shares to sell
* @return TradeResult Trade Result
* @exception RemoteException if there is
* a communications or systems failure
*/
public TradeResult sell (String stockSymbol, int shares)
throws RemoteException;
}
import javax.ejb.CreateException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
import javax.naming.InitialContext;
import javax.naming.NamingException;
/**
* TraderBean is a stateless Session Bean. This bean illustrates:
* <ul>
* <li> No persistence of state between calls to the Session Bean
* <li> Looking up values from the Environment
* </ul>
*
* @author Copyright (c) 1999-2003 by BEA Systems, Inc. All Rights Reserved.
*/
public class TraderBean implements SessionBean {
/**
* This method is required by the EJB Specification,
* but is not used by this example.
*
*/
public void ejbActivate() {
log("ejbActivate called");
}
/**
* This method is required by the EJB Specification,
* but is not used by this example.
*
*/
public void ejbRemove() {
log("ejbRemove called");
}
/**
* This method is required by the EJB Specification,
* but is not used by this example.
*
*/
public void ejbPassivate() {
log("ejbPassivate called");
}
/**
* Sets the session context.
*
* @param ctx SessionContext Context for session
*/
public void setSessionContext(SessionContext ctx) {
log("setSessionContext called");
this.ctx = ctx;
}
/**
* This method corresponds to the create method in the home interface
* "TraderHome.java".
* The parameter sets of the two methods are identical. When the client calls
/**
* Buys shares of a stock for a named customer.
*
* @param customerName String Customer name
* @param stockSymbol String Stock symbol
* @param shares int Number of shares to buy
* @return TradeResult Trade Result
* if there is an error while buying the shares
*/
public TradeResult buy(String stockSymbol, int shares) {
if (shares > tradeLimit) {
log("Attempt to buy "+shares+" is greater than limit of "+tradeLimit);
shares = tradeLimit;
}
log("Buying "+shares+" shares of "+stockSymbol);
return new TradeResult(shares, stockSymbol);
}
/**
* Sells shares of a stock for a named customer.
*
* @param customerName String Customer name
* @param stockSymbol String Stock symbol
* @param shares int Number of shares to buy
* @return TradeResult Trade Result
* if there is an error while selling the shares
*/
public TradeResult sell(String stockSymbol, int shares) {
if (shares > tradeLimit) {
log("Attempt to sell "+shares+" is greater than limit of "+tradeLimit);
shares = tradeLimit;
}
log("Selling "+shares+" shares of "+stockSymbol);
return new TradeResult(shares, stockSymbol);
}
}
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.EJBHome;
/**
* This interface is the home interface for the TraderBean.java,
* which in WebLogic is implemented by the code-generated container
* class TraderBeanC. A home interface may support one or more create
* methods, which must correspond to methods named "ejbCreate" in the EJBean.
*
* @author Copyright (c) 1998-2003 by BEA Systems, Inc. All Rights Reserved.
*/
public interface TraderHome extends EJBHome {
/**
* This method corresponds to the ejbCreate method in the bean
* "TraderBean.java".
* The parameter sets of the two methods are identical. When the client calls
* <code>TraderHome.create()</code>, the container
* allocates an instance of the EJBean and calls <code>ejbCreate()</code>.
*
* @return Trader
* @exception RemoteException if there is
* a communications or systems failure
* @exception CreateException
* if there is a problem creating the bean
* @see examples.ejb11.basic.statelessSession.TraderBean
*/
Trader create() throws CreateException, RemoteException;
}
package examples.webservices.complex.statelessSession;
import java.io.Serializable;
/**
* This class reflects the results of a buy/sell transaction.
*
* @author Copyright (c) 1999-2003 by BEA Systems, Inc. All Rights Reserved.
*/
public final class TradeResult implements Serializable {
public TradeResult() {}
ejb-jar.xml
<?xml version="1.0"?>
<ejb-jar>
<enterprise-beans>
<session>
<ejb-name>TraderService</ejb-name>
<home>examples.webservices.complex.statelessSession.TraderHome</home>
<remote>examples.webservices.complex.statelessSession.Trader</remote>
<ejb-class>examples.webservices.complex.statelessSession.TraderBean</ejb-class
>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
<env-entry>
<env-entry-name>WEBL</env-entry-name>
<env-entry-type>java.lang.Double </env-entry-type>
<env-entry-value>10.0</env-entry-value>
</env-entry>
<env-entry>
<env-entry-name>INTL</env-entry-name>
<env-entry-type>java.lang.Double </env-entry-type>
<env-entry-value>15.0</env-entry-value>
</env-entry>
<env-entry>
<env-entry-name>tradeLimit</env-entry-name>
<env-entry-type>java.lang.Integer </env-entry-type>
<env-entry-value>500</env-entry-value>
</env-entry>
</session>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>TraderService</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
weblogic-ejb-jar.xml
<?xml version="1.0"?>
<weblogic-ejb-jar>
<weblogic-enterprise-bean>
<ejb-name>TraderService</ejb-name>
<jndi-name>webservices-complex-statelessession</jndi-name>
</weblogic-enterprise-bean>
</weblogic-ejb-jar>
package examples.webservices.complex.statelessSession;
/**
* This class illustrates how to use the JAX-RPC API to invoke the TraderService
The following sections discuss design considerations for implementing WebLogic Web Services:
z “Using SOAP Message Handlers to Intercept the SOAP Message” on page 4-5
EJB or a Java class. All JMS-specific information is in its own chapter: Chapter 16,
“Creating JMS-Implemented WebLogic Web Services.”
z The Web Service can benefit from EJB facilities, such as persistence, security, transactions,
and concurrency.
Examples of this Web Service operation implementation include providing the current weather
conditions in a particular location; returning the current price for a given stock; or checking the
credit rating of a potential trading partner prior to the completion of a business transaction.
implements the operation returns void. Asynchronous one-way means that the client never
receives a SOAP response, even a fault or exception.
You specify this type of behavior with the invocation-style attribute of the <operation>
element in the web-services.xml file.
Web Service operations are typically synchronous request-response, mirroring typical RPC-style
behavior. Sometimes, however, you might want to implement asynchronous behavior if your
client application has no need for a response, even in the case of an error. When designing
asynchronous one-way Web Service operations, keep the following issues in mind:
z The back-end component that implements the operation must explicitly return void.
z You cannot specify out or in-out parameters to the operation, you can only specify in
parameters.
By default, the operations of a WebLogic Web Service are RPC-oriented. If you want to specify
that the operations are document-oriented, use the style="document" or
style="documentwrapped" attribute of the <service> element when assembling a Web
Service using the servicegen Ant task. The generated web-services.xml deployment
descriptor will contain a corresponding style="document" or style="documentwrapped"
attribute for the appropriate <web-service> element.
For information on implementing document-oriented WebLogic Web Services, see
“Implementing a Document-Oriented Web Service” on page 5-6. For details on using the
servicegen Ant task to assemble a document-oriented Web Service, see “Assembling
WebLogic Web Services Using the servicegen Ant Task” on page 6-3 and “servicegen” on
page B-25.
a. Create the serialization class that convert the data between its XML and Java
representation
b. Describe the XML representation of the data type (using XML Schema notation) in the
web-services.xml file
Note: If you are using the autotyping Ant tasks to generate data type information for a Java
class, your class must conform to the guidelines described in “Implementing
Non-Built-In Data Types” on page 5-5.
If your data type is not either built-in or one of the supported non-built-in data types, then you
must create the serialization class, and so on, manually. For details, see Chapter 11, “Using
Non-Built-In Data Types.”
You can, however, mimic a conversational Web Service by using JDBC or entity beans. For
example, you could design a Web Service so that client applications that invoke it pass a unique
ID to identify themselves to the stateless session EJB entry point. This EJB uses the ID to persist
the conversation in persistent storage, using either entity beans or JDBC. The next time the same
client application invokes the Web Service, the stateless session EJB can recover the previous
state of the conversation by selecting the persisted data using the unique ID.
For information on programming entity beans, see Programming WebLogic Enterprise
JavaBeans at http://e-docs.bea.com/wls/docs81/ejb/index.html. For information on JDBC, see
WebLogic jDrivers at http://e-docs.bea.com/wls/docs81/jdrivers.html.
write the business-logic code for the Java implementation class to make the Web Service behave
as you want.
It is assumed that you have read and understood the design issues discussed in Chapter 4,
“Designing WebLogic Web Services,” designed your Web Service and that you know the types
of components you need to create.
Note: BEA recommends that you implement your Web Service operation with only a stateless
session EJB or a Java class, and not with a JMS consumer or producer. In most of the
book, it is assumed that your Web Service is implemented with either an EJB or a Java
class. All JMS-specific information is in its own chapter: Chapter 16, “Creating
JMS-Implemented WebLogic Web Services.”
WL_HOME/samples/server/examples/src/examples/webservices/package-summary.html
1. Write the Java code for the back-end components that make up the Web Service.
See “Writing the Java Code for the Components” on page 5-3.
2. If you need to process information in the SOAP request or response or directly access the
SOAP attachments, create SOAP message handlers and handler chains.
See Chapter 12, “Creating SOAP Message Handlers to Intercept the SOAP Message.”
3. If your back-end components use non-built-in data types as parameters or return values,
generate or create the Java code for the data type as well as the serialization class that
converts the data between XML and Java.
See “Implementing Non-Built-In Data Types” on page 5-5.
4. Compile the Java code into class files. For details, see Compiling Java Code at
http://e-docs.bea.com/wls/docs81/programming/topics.html#Compiling.
z A Java class.
See “Implementing a Web Service By Writing a Java Class” on page 5-4 for information
on writing the Java code. For an example, see the
WL_HOME/samples/server/examples/src/examples/webservices/basic/javaclas
s directory, where WL_HOME refers to the main WebLogic Platform installation directory:
If your Web Service operations use non-built-in data types as parameters or return values, see
“Implementing Non-Built-In Data Types” on page 5-5.
If you are implementing a Web Service that uses document-oriented operations, rather than the
default RPC-oriented, see “Implementing a Document-Oriented Web Service” on page 5-6.
If you are implementing a WebLogic Web Service based on an existing WSDL file, and you want
to implement the Web Service with a Java class, use the WebLogic Server wsdl2Service Ant
task to generate the Web Service interface, and optional implementation, class to use as a starting
point. For details about using this Ant task, see “Generating a Partial Implementation From a
WSDL File” on page 5-6.
For information about using SOAP Attachments, see “Using SOAP Attachments” on page 5-9.
For information on throwing exceptions from your Web Service implementation, see “Throwing
SOAP Fault Exceptions” on page 5-14.
If you want your Web Service operation to return multiple values, see “Implementing Multiple
Return Values” on page 5-10.
z You can specify in the web-services.xml deployment descriptor that a Web Service
operation is one-way, which means that the client application that invokes the Web Service
does not wait for a response. When you write the Java code for the EJB method that
implements this type of operation, you must specify that it return void.
For more information on specifying in the web-services.xml file that a Web Service
operation is one-way, see operation.
z If the data type of the parameters or return value of an EJB method are not part of the set
of built-in data types, then you must generate or create the serialization class that converts
these data types between their XML and Java representations. For the list of built-in data
types, see “Supported Built-In Data Types” on page 5-15.
See “Implementing Non-Built-In Data Types” on page 5-5.
For an example of how to write a stateless session EJB, see “The EJB Java Interfaces and
Implementation Class” on page 3-4. For general information, see Programming WebLogic
Enterprise JavaBeans at http://e-docs.bea.com/wls/docs81/ejb/index.html.
z Do not start any threads. This rule applies to all Java code that runs on WebLogic Server.
z Define as public the methods of the Java class that are going to be exposed as Web Service
operations.
z Write thread-safe Java code, because WebLogic Server maintains only a single instance of
a Java class that implements a Web Service operation, and each invoke of the Web Service
uses this same instance.
Although it is not required, your Java class can extend the JAX-RPC
javax.xml.rpc.server.ServiceLifecycle interface, which defines the life cycle for the
Web Service endpoint. However, because this version of WebLogic Server does not support
servlets as back-end components of WebLogic Web Services, BEA does not provide an
z Use WebLogic Server servicegen or autotype Ant tasks to introspect your EJB and
automatically generate the serialization class. These Ant tasks also create the
corresponding XML Schema to represent your data in XML format and update your
web-services.xml deployment descriptor file with the relevant data type mapping
information. You will run these Ant tasks as part of assembling the Web Service, described
in “Creating the Build File That Specifies the servicegen Ant Task” on page 6-5 and
“Running the autotype Ant Task” on page 6-10.
Warning: The serialization class and Java and XML representations generated by the
autotype and servicegen Ant tasks cannot be round-tripped. For more
information, see “Non-Roundtripping of Generated Data Type Components” on
page 6-22.
z Create the serialization class and XML and Java representations of your data type
manually. This method is more complex and time-consuming than generating them using
the Ant task. For details on handling non-built-in data types manually, see Chapter 11,
“Using Non-Built-In Data Types.”
If you are going to create the XML representation of your Java data type manually, along with
the serialization class, you can code the Java class any way you want, because you will be writing
all the conversion code yourself.
If you are going to use the servicegen or autotype Ant tasks to generate the data type
components automatically, follow these requirements when writing the Java class for your data
type:
z Define both getXXX() and setXXX() methods for each member variable that you want to
expose.
z Make the data type of each exposed member variable one of the built-in data types, or a
non-built-in data type that consists of built-in data types and has the corresponding
serialization class and XML Schema representation.
The servicegen and autotype Ant tasks can generate data type components for most common
XML and Java data types. For the list of supported non-built-in data types, see “Non-Built-In
Data Types Supported by servicegen and autotype Ant Tasks” on page 6-18.
z The methods that implement each operation of the Web Service can have only one
parameter. This single parameter can be of any supported data type; see “Using Built-In
and Non-Built-In Data Types” on page 4-4 for more information.
z The methods that implement each operation cannot use out and in-out parameters.
The wsdl2Service Ant task takes as input an existing WSDL file and generates:
z the Java interface that represents the implementation of your Web Service
If you name your Java implementation class differently, you must manually update
the generated web-services.xml file accordingly.
On UNIX, execute the setEnv.sh command, located in your domain directory. The
default location of WebLogic Server domains is
BEA_HOME/user_projects/domains/domainName, where BEA_HOME is the top-level
installation directory of the BEA products and domainName is the name of your domain.
2. Create a file called build.xml that contains a call to the wsdl2Service Ant task. For
details, see “Sample build.xml Files for the wsdl2Service Ant Task” on page 5-8.
3. Execute the Ant task or tasks specified in the build.xml file by typing ant in the same
directory as the build.xml file:
prompt> ant
In the example, the wsdl2Service Ant task generates a Java interface file for the first
<service> element it finds in the WSDL file wsdls/myService.wsdl. It uses data type
mapping information for any non-built-in data types from the autotype/types.xml file;
typically you have previously run the autotype Ant task to generate this file. The Java interface
file and web-services.xml file are generated into the directory myService/implementation.
Assume that value of the name attribute of the first <service> element in the WSDL file is
SuperDooperService. The wsdl2Service generates a Java interface called
example.ws2j.service.SuperDooperService and assumes that your Java implementation
class will be example.ws2j.service.SuperDooperServiceImpl.
java.awt.Image image/gif or
image/jpeg
java.lang.String text/plain
javax.mail.internet.MimeMultipart multipart/*
javax.xml.transform.Source text/xml or
application/xml
If you code the method of the Java class or EJB to use one of the preceding Java data types as a
parameter or return value and then use servicegen to assemble the Web Service, the generated
web-services.xml deployment descriptor file automatically specifies that the actual data of the
parameter or return value is in the SOAP attachment. In particular, the location attribute of the
<param> or <return-param> is set equal to attachment. When a client application invokes the
Web Service, the WebLogic Web Services runtime automatically looks for the parameter data in
the attachment to the SOAP request, or adds the return value data to the attachment in the SOAP
response, depending on whether it is the parameter or return value or both that is one of the Java
data types listed in the preceding table.
If you want to access and manipulate the SOAP attachment directly, you must create a SOAP
message handler and use the SOAP with Attachments API for Java 1.1 (SAAJ). For details, see
Chapter 12, “Creating SOAP Message Handlers to Intercept the SOAP Message.”
java.lang.String
The Java data type java.lang.String works a little differently than what is described in the
preceding section. By default, if you use java.lang.String in the method that implements a
Web Service operation, the servicegen Ant tasks and the WebLogic Web Services runtime treat
it as a built-in data type. This means that the data will be part of the SOAP body as an XML
Schema string type rather than a text/plain MIME type in a SOAP attachment.
If, however, you want the java.lang.String parameter or return value to be transported as a
text/plain MIME encoded SOAP attachment, you must manually update the
web-services.xml deployment descriptor file and change the value of the location attribute
of the corresponding <param> or <return-value> element from the default Body to
attachment.
For more information on the attributes and elements of the web-services.xml file, see
Appendix A, “WebLogic Web Service Deployment Descriptor Elements.”
javax.activation.DataHandler
You use the javax.activation.DataHandler data type to represent data in a SOAP
attachment that is not listed in the table in “Using SOAP Attachments” on page 5-9.
The DataHandler class provides a consistent interface to data available in many different
sources and formats. It manages simple stream to string conversions and related operations using
javax.activation.DataContentHandlers. The DataHandler class also provides access to
commands that can operate on the data. The commands are found using a
javax.activation.CommandMap class.
DataHandlers are part of the J2EE JavaBeans Activation Framework standard extension. It is
assumed that if you use a DataHandler as a parameter or return type of a WebLogic Web Service
operation, you have implemented all the needed components, such as the DataContentHandler.
For general information about DataHandlers and how to implement them, see JavaBeans
Activation Framework at http://java.sun.com/products/javabeans/glasgow/jaf.html. See the
Javadoc at http://java.sun.com/products/javabeans/glasgow/javadocs/index.html for a
description of the JavaBeans Activation Framework APIs.
z Define the data type of the return value to be a complex non-built-in type, such as an
object with multiple parts or an array. For details about implementing these data types, see
“Implementing Non-Built-In Data Types” on page 5-5.
z Specify that one or more of the parameters of the Web Service operation be out or in-out
parameters. This section describes how to create these types of parameters.
return param1;
}
You invoke the method with two parameters, a String and an integer. The method returns two
values: a String (the standard return value) and an integer (via the IntHolder holder parameter).
Out and in-out parameters must implement the javax.xml.rpc.holders.Holder interface.
Use the Holder.value field to first access the input value of an in-out parameter and then set the
value of out and in-out parameters. In the preceding example, assume the method was invoked
with a value of 40 as the second parameter; when the method completes, the value of intHolder
is now 20.
javax.xml.rpc.holders.ByteHolder byte
javax.xml.rpc.holders.ShortHolder short
javax.xml.rpc.holders.IntHolder int
javax.xml.rpc.holders.LongHolder long
javax.xml.rpc.holders.FloatHolder float
javax.xml.rpc.holders.DoubleHolder double
javax.xml.rpc.holders.BigDecimalHolder java.math.BigDecimal
javax.xml.rpc.holders.BigIntegerHolder java.math.BigInteger
javax.xml.rpc.holders.ByteArrayHolder byte[]
javax.xml.rpc.holders.CalendarHolder java.util.Calendar
javax.xml.rpc.holders.QnameHolder javax.xml.namespace.QName
javax.xml.rpc.holders.StringHolder java.lang.String
If, however, the data type of the parameter is not provided, you must create your own
implementation.
To create your own implementation of the javax.xml.rpc.holders.Holder interface, follow
these guidelines:
z Name your implementation class TypeHolder, where Type is the name of the complex
type. For example, if your complex type is called Person, then your implementation class
is called PersonHolder.
z Create a public field called value, whose data type is the same as that of the parameter.
z Create a default constructor that initializes the value field to a default value.
z Create a constructor that sets the value field to the value of the passed parameter.
The following example shows the outline of a PersonHolder implementation class:
package examples.webservices.holders;
public final class PersonHolder implements
javax.xml.rpc.holders.Holder {
public Person value;
public PersonHolder() {
// set the value variable to a default value
}
public PersonHolder (Person value) {
// set the value variable to the passed in value
}
}
After you have created the Holder implementation class for your out or in-out parameter, update
the Java code for the method that implements your Web Service operation to use this Holder
class. When you later use the servicegen Ant task to assemble your Web Service, the generated
web-services.xml file will automatically specify that the parameter is an in-out parameter, as
shown in the following excerpt:
<param name="inoutparam" style="inout"
type="xsd:Person" />
If you want the parameter to be an out, rather than in-out, parameter, you must update the
generated web-services.xml file manually.
For details about writing a client application that invokes a Web Services that uses out or in-out
parameters, see “Writing a Client That Uses Out or In-Out Parameters” on page 7-10.
import javax.xml.soap.SOAPFactory;
import javax.xml.soap.Detail;
import javax.xml.soap.SOAPException;
import javax.xml.namespace.QName;
import javax.xml.rpc.soap.SOAPFaultException;
try{
detail = SOAPFactory.newInstance().createDetail();
detail.addChildElement( "MyDetails" ).addTextNode( "failed" );
}catch( SOAPException e ){
e.printStackTrace();
}
Warning: If you create and throw your own exception (rather than use SOAPFaultException)
and two or more of the properties of your exception class are of the same data type,
then you must also create setter methods for these properties, even though the
JAX-RPC specification does not require it. This is because when a WebLogic Web
Service receives the exception in a SOAP message and converts the XML into the
Java exception class, there is no way of knowing which XML element maps to which
class property without the corresponding setter methods.
If your data type is not supported, then you must create your serialization class manually. For
details, see Chapter 11, “Using Non-Built-In Data Types.”
Table 5-3 Mapping XML Schema Data Types to Java Data Types
XML Schema Data Type Equivalent Java Data Type
(lower case indicates a primitive data type)
boolean boolean
byte byte
short short
int int
long long
float float
double double
integer java.math.BigInteger
decimal java.math.BigDecimal
string java.lang.String
dateTime java.util.Calendar
base64Binary byte[]
hexBinary byte[]
duration weblogic.xml.schema.binding.util.Duration
time java.util.Calendar
date java.util.Calendar
Table 5-3 Mapping XML Schema Data Types to Java Data Types
XML Schema Data Type Equivalent Java Data Type
(lower case indicates a primitive data type)
gYearMonth java.util.Calendar
The java.util.Calendar Java data type contains more fields than
the gYearMonth data type. This additional information is not
meaningful and is not generated from the actual XML data, but rather
created by the data binding facility.
gYear java.util.Calendar
The java.util.Calendar Java data type contains more fields than
the gYearMonth data type. This additional information is not
meaningful and is not generated from the actual XML data, but rather
created by the data binding facility.
gMonthDay java.util.Calendar
The java.util.Calendar Java data type contains more fields than
the gYearMonth data type. This additional information is not
meaningful and is not generated from the actual XML data, but rather
created by the data binding facility.
gDay java.util.Calendar
The java.util.Calendar Java data type contains more fields than
the gYearMonth data type. This additional information is not
meaningful and is not generated from the actual XML data, but rather
created by the data binding facility.
gMonth java.util.Calendar
The java.util.Calendar Java data type contains more fields than
the gYearMonth data type. This additional information is not
meaningful and is not generated from the actual XML data, but rather
created by the data binding facility.
anyURI java.lang.String
NOTATION java.lang.String
token java.lang.String
normalizedString java.lang.String
language java.lang.String
Table 5-3 Mapping XML Schema Data Types to Java Data Types
XML Schema Data Type Equivalent Java Data Type
(lower case indicates a primitive data type)
Name java.lang.String
NMTOKEN java.lang.String
NCName java.lang.String
NMTOKENS java.lang.String[]
ID java.lang.String
IDREF java.lang.String
ENTITY java.lang.String
IDREFS java.lang.String[]
ENTITIES java.lang.String[]
nonPositiveInteger java.math.BigInteger
nonNegativeInteger java.math.BigInteger
negativeInteger java.math.BigInteger
unsignedLong java.math.BigInteger
positiveInteger java.math.BigInteger
unsignedInt long
unsignedShort int
unsignedByte short
Qname javax.xml.namespace.QName
Table 5-4 Mapping Java Data Types to XML Schema Data Types
Java Data Type (lower case indicates a Equivalent XML Schema Data Type
primitive data type)
int int
short short
long long
float float
double double
byte byte
boolean boolean
java.lang.Integer int
java.lang.Short short
java.lang.Long long
java.lang.Float float
java.lang.Double double
java.lang.Byte byte
java.lang.Boolean boolean
java.lang.String string
java.math.BigInteger integer
java.math.BigDecimal decimal
java.lang.String string
java.util.Calendar dateTime
Table 5-4 Mapping Java Data Types to XML Schema Data Types
Java Data Type (lower case indicates a Equivalent XML Schema Data Type
primitive data type)
java.util.Date dateTime
byte[] base64Binary
weblogic.xml.schema.binding.util.Duration duration
javax.xml.namespace.QName Qname
The following sections describe how to assemble and deploy WebLogic Web Services using a
variety of Ant tasks:
z “Overview of Assembling WebLogic Web Services Using Ant Tasks” on page 6-1
z “Assembling WebLogic Web Services Using the servicegen Ant Task” on page 6-3
z “Assembling WebLogic Web Services Using Individual Ant Tasks” on page 6-6
z “Non-Built-In Data Types Supported by servicegen and autotype Ant Tasks” on page 6-18
z Using the servicegen Ant task, which performs all assembly steps for you.
The servicegen Ant takes as input an EJB JAR file (for EJB-implemented Web Services)
or a list of Java classes (for Java class-implemented Web Services), and based on
information after introspecting the Java code and the attributes of the Ant task, it
automatically generates all the components that make up a WebLogic Web Service and
packages them into an EAR file.
For detailed information, see “Assembling WebLogic Web Services Using the servicegen
Ant Task” on page 6-3.
WL_HOME/samples/server/examples/src/examples/webservices/package-summary.html
z Introspects the Java code, looking for public methods to convert into Web Service
operations and non-built-in data types used as parameters or return values of the methods.
z Optionally creates the serialization class that convert the non-built-in data between its
XML and Java representations. It also creates XML Schema representations of the Java
objects and updates the web-services.xml file accordingly. For the list of supported
non-built-in data types, see “Non-Built-In Data Types Supported by servicegen and
autotype Ant Tasks” on page 6-18.
z Packages all the Web Service components into a Web application WAR file, then packages
the WAR and EJB JAR files into a deployable EAR file.
3. If the Web Service operations are implemented with EJBs, package them, along with any
supporting EJBs, into an EJB JAR file. If the operations are implemented with Java classes,
compile them into class files.
For detailed information, refer to Developing WebLogic Server Applications at
http://e-docs.bea.com/wls/docs81/programming/environment.html.
4. Copy the EJB JAR file and/or Java class files to the staging directory.
5. In the staging directory, create the Ant build file (called build.xml by default) that
contains a call to the servicegen Ant task.
For details about specifying the servicegen Ant task, see “Creating the Build File That
Specifies the servicegen Ant Task” on page 6-5.
For general information about creating Ant build files, see
http://jakarta.apache.org/ant/manual/.
Note: The Apache Jakarta Web site publishes online documentation for only the most
current version of Ant, which might be different from the version of Ant that is
bundled with WebLogic Server. To determine the version of Ant that is bundled with
WebLogic Server, run the following command after setting your WebLogic
environment:
prompt> ant -version
To view the documentation for a specific version of Ant, download the Ant zip file
from http://archive.apache.org/dist/ant/binaries/ and extract the documentation.
6. If you previously used the autotype Ant task to generate non-built-in data type
information from an existing XML Schema file, and then used the typeMappingFile
attribute of the servicegen Ant task to specify the types.xml file generated by autotype
and merge it with any servicegen-generated information, and the original XML Schema
file uses the <include> element to include additional XML Schema files, you must copy
these XML Schema files to the root directory of the Web Service Web application WAR file
of the generated EAR file. You can use the wspackage Ant task do perform this step.
If you are using the servicegen Ant task exclusively to generate non-built-in data type
components, then you do not need to perform this step.
For details, see “Running the wspackage Ant task” on page 6-14.
7. Execute the Ant task or tasks specified in the build.xml file by typing ant in the staging
directory, optionally passing the command a target argument (if you have created the
build.xml file to take arguments):
prompt> ant
The Ant task generates the Web Services EAR file in the staging directory which you can
then deploy on WebLogic Server.
Creating the Build File That Specifies the servicegen Ant Task
The following sample build.xml, file taken from the
examples.webservices.basic.statelessession product example, specifies that you will
run the servicegen Ant task:
Note: BEA recommends that you create an exploded directory, rather than an EAR file, by
specifying a value for the destEar attribute of servicegen that does not have an .ear
suffix. You can later package the exploded directory into an EAR file when you are ready
to deploy the Web Service.
1. Package or compile the Java back-end components that implement the Web Service into their
respective packages. For example, package stateless session EJBs into an EJB JAR file and
Java classes into class files.
For detailed instructions, see Developing WebLogic Server Applications at
http://e-docs.bea.com/wls/docs81/programming/environment.html.
web-services.xml file for you. For details, see “Generating a Partial Implementation
From a WSDL File” on page 5-6.
3. If your Web Service uses non-built-in data types, create all the needed components, such as
the serialization class and the XML Schema, by using the autotype Ant task to generate
these components automatically, as described in “Running the autotype Ant Task” on
page 6-10.
4. Optionally create a client JAR file using the clientgen Ant task.
See “Running the clientgen Ant Task” on page 6-13.
5. Package all components into a deployable EAR file by using the wspackage Ant task, as
described in “Running the wspackage Ant task” on page 6-14.
1. Run the autotype Ant task to generate the Java representations of the non-built-in data types
in the XML Schema file. The Ant task also generates the serialization class used to convert
the data between XML and Java and the data type mapping file. Use the schemaFile attribute
of the autotype Ant task to specify the name of the file that contains your XML Schema.
For details, see “Running the autotype Ant Task” on page 6-10.
2. Write the Java code for the stateless session EJB or Java class back-end component that
implements your Web Service. Use the Java classes generated by the autotype Ant task in
the preceding step for the non-built-in data types (originally described in the XML Schema
file from which you started) used as parameters or return values of the methods.
For details, see “Writing the Java Code for the Components” on page 5-3.
3. If necessary, re-run the autotype Ant task against your EJB or Java class to generate the
non-built-in data type components for any new data types you might have created that are
not included in the original XML Schema file. Use the javaComponents attribute of the
autotype Ant task to specify the back-end component you wrote in Step 2.
Be sure you also use the typeMappingFile attribute to specify the existing data type
mapping file, generated from the first execution of the autotype Ant task in Step 1. The
autotype Ant task merges the existing XML Schema with any generated one, thus
preserving the original XML Schema.
For details, see “Running the autotype Ant Task” on page 6-10.
4. Run the source2wsdd Ant task to generate the web-services.xml deployment descriptor.
If you re-ran the autotype Ant task to create a merged data type mapping file, be sure you
specify this final file with the typesInfo attribute.
For details, see “Running the source2wsdd Ant Task” on page 6-8.
5. Optionally create a client JAR file by running the clientgen Ant task.
For details, see “Running the clientgen Ant Task” on page 6-13.
6. Package all components into a deployable EAR file by using the wspackage Ant task.
If the original XML Schema file from which you originally started uses one or more
<include> elements to include additional XML Schema files, be sure you explicitly copy
these files to the root directory of the Web Service Web application WAR file, located by
default in the root directory of the EAR file and called web-services.war.
For details and examples of a variety of ways to use the wspackage Ant task, see
“Running the wspackage Ant task” on page 6-14.
2. Create a file called build.xml that contains a call to the source2wsdd Ant task. For
details, see the examples later in this section.
3. Execute the Ant task or tasks specified in the build.xml file by typing ant in the same
directory as the build.xml file:
prompt> ant
For reference information about the source2wsdd Ant task, see “source2wsdd” on page B-41.
The following example shows a simple build.xml file.
Listing 6-1 Simple Source2wsdd build.xml File For a Java Source File
When you run the source2wsdd Ant task using the preceding build.xml file, the Ant task
generates a web-services.xml file from the Java source file source/MyService.java. It
uses non-built-in data type information from the autotype/types.xml file; this information
includes the XML Schema representation of non-built-in data types used as parameters or return
values in your Web Service, as well as data type mapping information that specifies the location
of the serialization class, and so on. You typically generate the types.xml file using the
autotype Ant task.
The source2wsdd Ant task outputs the generated deployment descriptor information into the file
ddfiles/web-services.xml. The URI of the Web Service is /MyService, used in the full
URL that invokes the Web Service once it is deployed.
The following example shows how to generate both a web-services.xml file and the WSDL
file (called wsdFiles/Temperature.wsdl) that describes a stateless session EJB-implemented
Web Service. Because the ejbLink attribute is specified, the javaSource attribute must point
to the EJB source file. The source2wsdd Ant task uses the value of the ejbLink attribute as the
value of the <ejb-link> child element of the <stateless-ejb> element in the generated
web-services.xml file.
<source2wsdd
javaSource="source/TemperatureService.java"
ejbLink="TemperatureService.jar#TemperatureServiceEJB"
ddFile="ddfiles/web-services.xml"
typesInfo="autotype/types.xml"
serviceURI="/TemperatureService"
wsdlFile="wsdlFiles/Temperature.wsdl"
/>
2. Create a file called build.xml that contains a call to the autotype Ant task. For details,
see the examples later in this section.
3. Execute the Ant task or tasks specified in the build.xml file by typing ant in the same
directory as the build.xml file:
prompt> ant
For reference information about the autotype Ant task, see “autotype” on page B-7.
The following example shows a simple build.xml file.
When you run the autotype Ant task using the preceding build.xml file, the Ant task creates
the non-built-in data type components for a Java class called mypackage.MyType. The package
name used in the generated serialization class is a.package.name. The serialization Java class
and XML schema information is generated and placed in the output directory. The generated
XML Schema and type-mapping information are in a file called types.xml in this output
directory.
The following excerpt from a sample build.xml file shows another way to use the autotype
task
<autotype wsdl="file:/wsdls/myWSDL"
targetNamespace="http://www.foobar.com/autotyper"
packageName="a.package.name"
destDir="output" />
The preceding example is similar to the first, except that instead of starting with a Java
representation of a data type, the example starts with an XML Schema representation embedded
within the WSDL of a Web Service. In this case, the task generates the corresponding Java
representation.
Similarly, if you want to start from an XML Schema file and generate the corresponding Java
components, use the schemaFile attribute, as shown in the following example.
Listing 6-5 Autotype build.xml File for Starting with XML Schema
<autotype schemaFile="file:/schemas/mySchema.xsd"
targetNamespace="http://www.foobar.com/autotyper"
packageName="a.package.name"
destDir="output" />
In the preceding example, the XML Schema in the mySchema.xsd file is copied, without any
changes, to the output/types.xml file that contains the data type mapping information.
The following example shows how to both generate non-built-in data type components for newly
implemented Java data types, and carry forward already generated components.
Listing 6-6 Autotype build.xml File That Carries Forward Existing Components
<autotype javaComponents="my.superService"
typeMappingFile="file:/mapfiles/types.xml"
targetNamespace="http://www.foobar.com/autotyper"
packageName="a.package.name"
destDir="output" />
In the preceding example, it is assumed that you have previously run the autotype Ant task
against an XML Schema file and generated the corresponding Java data types and data type
mapping file. It is further assumed that you then used these data types to implement a stateless
session EJB back-end component, and during that process, you created additional Java data types
and want to use the autotype Ant task to generate the corresponding XML Schema. However,
you want to preserve the original XML Schema from which you started, and carry it forward into
the newly generated types.xml file. The example uses the javaComponents attribute to specify
the EJB which has the new Java data types and the typeMappingFile attribute to specify the
existing file that contains the XML Schema for data types that you do not want regenerated. The
Ant task merges the existing data type mapping information in the
file:/mapfiles/types.xml file with the generated information, and writes the result to the
output/types.xml file.
2. Create a file called build.xml that contains a call to the clientgen Ant task. For details,
see the examples later in this section.
3. Execute the Ant task or tasks specified in the build.xml file by typing ant in the same
directory as the build.xml file:
prompt> ant
For reference information about the clientgen Ant task, see “clientgen” on page B-14.
The following example shows a simple build.xml file.
Listing 6-7 Clientgen build.xml File For Generating Client From EAR File
useServerTypes="True"
clientJar="myapps/myService_client.jar" />
</target>
</project>
When you run the clientgen Ant task using the preceding build.xml file, the Ant task creates
the myapps/myService_client.jar client JAR file that contains the service-specific client
interfaces and stubs and the serialization class used to invoke the WebLogic Web Service called
myService contained in the EAR file myapps/myapp.ear. It packages the client interface and
stub files into a package called myapp.myservice.client. The useServerTypes attribute
specifies that the clientgen Ant task should get the Java implementation of all non-built-in data
types used in the Web Service from the myapps/myapp.ear file rather than generating Java code
to implement the data types.
The following excerpt from a sample build.xml file shows another way to use the clientgen
task.
Listing 6-8 Clientgen build.xml File For Generating Client From a WSDL File
<clientgen wsdl="http://example.com/myapp/myservice.wsdl"
packageName="myapp.myservice.client"
clientJar="myapps/myService_client.jar"
/>
In the example, the clientgen task creates a client JAR file (called
myapps/myService_client.jar) to invoke the Web Service described in the
http://example.com/myapp/myservice.wsdl WSDL file. It packages the interface and stub
files in the myapp.myservice.client package.
2. Create a file called build.xml that contains a call to the wspackage Ant task. For details,
see the examples later in this section.
3. Execute the Ant task or tasks specified in the build.xml file by typing ant in the same
directory as the build.xml file:
prompt> ant
For reference information about the wspackage Ant task, see “wspackage” on page B-52.
The following example shows a simple build.xml file for creating a new deployable EAR file
for a Java class-implemented Web Service.
</project>
When you run the wspackage Ant task using the preceding build.xml file, the Ant task creates
an EAR file called ears/myWebService.ear. The context URI of the Web Service, used in the
full URL that invokes it, is web_services. The class file that contains the serialization class for
the non-built-in data types is located in the autotype directory. The Java class that implements
the Web Service is called example.ws2j.service.SimpleTest and will be packaged in the
WEB-INF/classes directory of the Web application. Finally, the existing deployment descriptor
file is ddfiles/web-services.xml.
The following example shows another build.xml file for adding additional components to an
existing EAR file.
Listing 6-10 Wspackage build.xml File For Adding Additional Components to EAR File
In the example, the wspackage Ant task adds the file myEJB2.jar to the root directory of the
existing EAR file called ears/myWebService.ear. The overwrite attribute is set to false to
ensure that none of the existing components in the ears/myWebService.ear file are
overwritten; be sure you always do this when using the wspackage Ant task to add additional
files to an EAR file.
The following example is similar to the preceding one in that it adds additional components to an
existing EAR, but in this case it adds XML Schema files to the root directory of the existing WAR
file. You must use the following syntax if you originally used the autotype Ant task to generate
non-built-in data type components from an XML Schema file, and this Schema file contains one
or more <include> elements to include additional XML Schema files. When you package the
final Web Service into an archive, you must manually add both the original and included XML
Schema files to the WAR file.
Listing 6-11 Wspackage build.xml File For Adding Schema Files to the WAR File of an EAR
In the example, the wspackage Ant task adds the XML Schema files original_schema.xsd
and included_schema.xsd to the root directory of the existing WAR file called
myservice.war, located in the root directory of the EAR file called ears/myWebService.ear.
EAR file
WAR file
EJB JAR file (JAR file containing the EJBs that implement the Web Service.)
Warning: The serialization class and Java and XML representations generated by the
autotype, servicegen, and clientgen Ant tasks cannot be round-tripped. For
more information, see “Non-Roundtripping of Generated Data Type Components”
on page 6-22.
For information on the ways that WebLogic Web Services are non-compliant with the JAX-RPC
specification with respect to data types, see “Data Type Non-Compliance with JAX-RPC” on
page 6-21.
Derivation of new simple types by restriction of Equivalent Java data type of simple type.
an existing simple type.
<xsd:anyType> java.lang.Object.
java.lang.Object <xsd:anyType>
z The sequence contains a single element with maxOccurs greater than 1 or unbounded.
The following example shows such an XML Schema data type:
<xsd:complexType name="Response">
<xsd:sequence >
<xsd:element name="code" type="xsd:string" maxOccurs="10" />
</xsd:sequence>
</xsd:complexType>
The autotype Ant task maps this type of XML Schema data type directly to a Java array of the
specified element. In the previous example, the autotype Ant task maps the Response XML
Schema data type to a java.lang.String[] Java type. This is similar to the type of mapping
that .NET does.
The JAX-RPC specification, in turn, states that this type of XML Schema data type should map
to a Java array with a pair of setter and getter methods in a JavaBean class. WebLogic Web
Services do not follow this last part of the specification.
types. However, because clientgen by default generates these components from the WSDL of
the Web Service (and thus from an XML Schema), the clientgen-generated client-side Java
representation might look different from the autotype-generated server-side Java code. This
means that you might not necessarily be able to reuse any server-side code that handles the data
type in your client application. If you want the clientgen Ant task to always use the generated
serialization class and code from the WebLogic Web Service EAR file, specify the
useServerTypes attribute.
z View the SOAP request and response messages from a successful test of an operation.
Note: You cannot use two-way SSL when testing a Web Service from its Home Page.
The following URLs show first how to invoke the Web Service Home page and then the WSDL
in your browser:
[protocol]://[host]:[port]/[contextURI]/[serviceURI]
[protocol]://[host]:[port]/[contextURI]/[serviceURI]?WSDL
where:
z protocol refers to the protocol over which the service is invoked, either HTTP or HTTPS.
This value corresponds to the protocol attribute of the <web-service> element that
describes the Web Service in the web-servicex.xml file. If you used the servicegen
Ant task to assemble your Web Service, this value corresponds to the protocol attribute.
z port refers to the port number on which WebLogic Server is listening (default value is
7001).
z contextURI refers to the context root of the Web application, corresponding to the
<context-root> element in the application.xml deployment descriptor of the EAR
file. If you used the servicegen Ant task to assemble your Web Service, this value
corresponds to the contextURI attribute.
If your application.xml file does not include the <context-root> element, then the
value of contextURI is the name of the Web application archive file or exploded directory.
z serviceURI refers to the URI of the Web Service. This value corresponds to the uri
attribute of the <web-service> element in the web-services.xml file. If you used the
servicegen Ant task to assemble your Web Service, this value corresponds to the
serviceURI attribute.
For example, assume you used the following build.xml file to assemble a WebLogic Web
Service using the servicegen Ant task:
<project name="buildWebservice" default="build-ear">
<target name="build-ear">
<servicegen
destEar="myWebService.ear"
warName="myWAR.war"
contextURI="web_services">
<service
ejbJar="myEJB.jar"
targetNamespace="http://www.bea.com/examples/Trader"
serviceName="TraderService"
serviceURI="/TraderService"
generateTypes="True"
expandMethods="True" >
</service>
</servicegen>
</target>
</project>
The URL to invoke the Web Service Home Page, assuming the service is running on a host called
ariel at the default port number, is:
http://ariel:7001/web_services/TraderService
The URL to get the automatically generated WSDL of the Web Service is:
http://ariel:7001/web_services/TraderService?WSDL
You must redeploy the Web Service after updating its deployment descriptor for the change to
take effect.
The following sections describe how to invoke Web Services, both WebLogic and
non-WebLogic, from client applications and from WebLogic Server:
z “Creating Java Client Applications to Invoke Web Services: Main Steps” on page 7-4
z “Using a Proxy Server with the WebLogic Web Services Client” on page 7-24
Stub Base class of the client proxy used to invoke the operations of a
Web Service.
Note: For information about BEA’s current licensing of client functionality, see the BEA
eLicense Web Site at http://elicense.bea.com/elicense_webapp/index.jsp.
z basic.javaclass: Uses a Java class back-end component with built-in data types as its
parameters and return value.
WL_HOME/samples/server/src/examples/webservices/package-summary.html
1. Generate the Web Service-specific client JAR file by running the clientgen Ant task.
Specify the wsdl attribute to create a client JAR file for a Web Service that is being hosted
by either a WebLogic or a non-WebLogic server, or specify the ear attribute for WebLogic
Web Services packaged in EAR files.
For details and examples of running the clientgen Ant task, see “Generating the Client
JAR File by Running the clientgen Ant Task” on page 7-5. For reference information, see
Appendix B, “Web Service Ant Tasks and Command-Line Utilities.”
2. Get information about the Web Service, such as its name and signature.
For details, see “Getting Information About a Web Service” on page 7-7.
3. Write the Java client application code that includes the invoke of the Web Service.
See “Writing the Java Client Application to Invoke a Web Service” on page 7-8 for an
example of writing a simple client application.
2. Create a file called build.xml that contains a call to the clientgen Ant task. For details,
see the example later in this section.
3. Execute the Ant task or tasks specified in the build.xml file by typing ant in the same
directory as the build.xml file:
prompt> ant
For reference information about the clientgen Ant task, see “clientgen” on page B-14.
The following example shows a simple build.xml file.
Listing 7-1 Sample build.xml File for the clientgen Ant Task
</target>
</project>
When you run the clientgen Ant task using the preceding build.xml file, the Ant task creates
a client JAR file (called myapps/myService_client.jar) that the client application will use to
invoke the Web Service described by the http://example.com/myapp/myservice?WSDL
WSDL. It packages the interface and stub files in the myapp.myservice.client package.
The operations defined for this Web Service are listed under the corresponding <binding>
element. For example, the following WSDL excerpt shows that the TraderService Web
Service has two operations, buy and sell (for clarity, only relevant parts of the WSDL are
shown):
<binding name="TraderServiceSoapBinding" ...>
...
<operation name="sell">
...
</operation>
<operation name="buy">
</operation>
</binding>
z Implementation of the JAX-RPC Service interface for the Web Service you are invoking.
z An implementation of the Stub interface for each SOAP port in the WSDL.
z Serialization class for non-built-in data types and their Java representations.
The following code shows an example of writing a client application that invokes the sample
TraderService Web Service; in the example, TraderService is the stub factory and
TraderServicePort is the stub itself:
package examples.webservices.complex.statelessSession;
}
String [] stocks = {"BEAS", "MSFT", "AMZN", "HWP" };
}
In the preceding example:
z The following code shows how to invoke the buy operation of the TraderService Web
Service:
TradeResult result = trader.buy(stocks[i], shares);
The trader Web Service has two operations: buy() and sell(). Both operations return a
non-built-in data type called TradeResult.
The following client application shows one way to invoke the echoStructAsSimpleTypes()
Web Service operation.
package websvc;
org.tempuri.x4s4c.x1.x3.wsdl.types.SOAPStruct inputStruct =
new org.tempuri.x4s4c.x1.x3.wsdl.types.SOAPStruct();
inputStruct.setVarInt(10);
inputStruct.setVarFloat(10.1f);
inputStruct.setVarString("hi there");
javax.xml.rpc.holders.StringHolder outputString =
new javax.xml.rpc.holders.StringHolder();
javax.xml.rpc.holders.IntHolder outputInteger =
new javax.xml.rpc.holders.IntHolder();
javax.xml.rpc.holders.FloatHolder outputFloat =
new javax.xml.rpc.holders.FloatHolder();
Warning: This section applies only to static client application that use the Web
Service-specific client JAR files generated by the clientgen Ant task. You cannot
use the procedure specified in this section in dynamic proxy and DII-based client
applications.
To write an asynchronous client, follow these steps:
1. Generate the Web Service-specific client JAR file by running the clientgen Ant task. Be
sure to specify the generateAsyncMethods="True" attribute, as shown in the following
example:
<clientgen
wsdl="http://www.mssoapinterop.org/asmx/simple.asmx?WSDL"
clientJar="echoservice.jar"
packageName="examples.async"
generateAsyncMethods="true" />
The clientgen Ant task generates special asynchronous methods in the JAX-RPC stubs to
invoke the operations of the Web Service. See “Description of the Generated
Asynchronous Web Service Client Stub” on page 7-12 for more details.
For general details and examples of running the clientgen Ant task, see “Generating the
Client JAR File by Running the clientgen Ant Task” on page 7-5. For reference
information, see Appendix B, “Web Service Ant Tasks and Command-Line Utilities.”
2. Write the Java code using the special asynchronous methods. For examples, see “Writing
the Asynchronous Client Java Code” on page 7-13.
z Method is the name of the synchronous method used to invoke the Web Service operation.
Note: If the operations of the Web Service are document-oriented (rather than RPC-oriented),
the clientgen Ant task also generates the following end() method, in addition to the
methods listed above:
result endConvenienceMethod (FutureResult futureResult);
There are two steps involved in invoking an asynchronous operation: the first starts the invocation
and the second optionally retrieves the results of the completed operation.
Assume that your client application uses the following Java code to get an instance of the
SimpleTest stub implementation:
SimpleTest echoService = new SimpleTest_Impl();
SimpleTestSoap echoPort = echoService.getSimpleTestSoap();
Further assume that you want to invoke the echoString operation of the Web Service. The
following paragraphs show a variety of ways you can invoke this operation asynchronously.
The simplest way is to simply execute the startEchoString() client method, do some other
task, then execute the endEchoString() client method:
The endMethod() method, in this case endEchoString(), blocks until the result is ready.
You can also use the FutureResult.isCompleted() method to test whether the results have
returned from the Web Service, as shown in the following excerpt:
while( !futureResult.isCompleted() ){
// do something ;
}
try{
String result = source.endEchoString ( event.getFutureResult() );
} catch ( RemoteException e ){
e.printStackTrace ( System.out );
}
}
});
weblogic.webservice.transport.http.full-url Specifies that the full URL, rather than the Boolean.
relative URL, of the Web Service that the
client application is invoking be specified in
the Request-URI field of HTTP request.
Valid values are True and False. Default
value is False.
The following table lists the standard JDK 1.4 system properties you can set in your client
applications.
For additional information about these properties, see Sun’s Network Properties at
http://java.sun.com/j2se/1.4/docs/guide/net/properties.html.
http.proxyHost If you use a proxy server to make HTTP connections, specifies the
host name of the proxy server in your client applications.
http.proxyPort If you use a proxy server to make HTTP connections, specifies the port
of the proxy server in your client applications.
http.nonProxyHosts If you use a proxy server to make HTTP connections, specifies the
hosts which should be connected to directly and not through the proxy
server.
z You do not need the runtime client JAR files, because all the needed classes are already
included in the WebLogic Server runtime.
z You must add the Web Service-specific client JAR file to the appropriate directory of the
deployed component.
z If you are invoking a Web Service deployed on WebLogic Server Version 8.1 from a
Version 7.0 instance of WebLogic Server, and it is necessary for the Version 7.0 WebLogic
Server instance to use a Web Service-specific client JAR file generated from the
clientgen Ant task included in Version 8.1 of WebLogic Server, then you must use
portable stubs. For details, see “Creating and Using Portable Stubs” on page 7-22.
The following table summarizes the location of the various client JAR files depending on the type
of client application from which you are invoking the Web Service.
Table 7-4 Location of Client JAR Files For Various Client Applications
Type of Client Location of Runtime Client JAR Files Location of Web Service-Specific
Application Client JAR File
Servlet or Java Not needed, because the runtime WEB-INF/lib directory of the
class client classes are part of the WAR file.
WebLogic Server runtime.
runs in WebLogic Server, you might find that the Java classes in the JAR file collide with the
classes of WebLogic Server itself. This happens when the WebLogic Server instance in which
the client JAR file is deployed is a different version from that which the client JAR file was
generated. To solve this problem, use portable stubs.
Note: Always try to use the clientgen Ant task of the WebLogic Server instance that is
invoking the Web service to create the Web Service-specific client JAR file rather than
that of the WebLogic Server that is hosting the Web Service. If this is not possible, then
use portable stubs.
You need to use portable stubs only if your client application is deployed and running on
WebLogic Server, not if your client application is standalone.
To enable your client application to use portable stubs:
1. Use the WebLogic Server release-specific client JAR file called wsclient81.jar
(distributed with WebLogic Server in the WL_HOME/server/lib directory) with your client
application rather than the generic webserviceclient.jar client JAR file. The
wsclient81.jar file contains the same class files as the standard client JAR file, but they
are renamed weblogic81.*. Because these class files are version-specific, they will not
collide with any weblogic.* WebLogic Server classes.
2. Run the Web-service specific client JAR file you generated with the clientgen Ant task,
as well as any supporting client JAR files, through the VersionMaker utility. This utility
makes the following changes to the classes in these client JAR files:
– Renames all weblogic.* classes as weblogic81.*
– All references to weblogic.* classes are changed to reference weblogic81.* instead.
Use these new version-specific client JAR files with your client application.
For details on using VersionMaker, see “Using the VersionMaker Utility to Update Client
JAR Files” on page 7-23.
z http.proxyHost
z http.proxyPort
z weblogic.webservice.transport.http.proxy.host
z weblogic.webservice.transport.http.proxy.port
Note: If you are using HTTPS as the transport when invoking the Web Service, replace the
http in the preceding properties with https. For example, use https.proxyHost
instead of http.proxyHost.
For more information on these, and other, WebLogic system properties you can set in your client
application, see “Using Web Services System Properties” on page 7-14.
Additionally, if you have set up your proxy server to use proxy authentication, then you must also
set the property weblogic.net.proxyAuthenticatorClassName in your client application to
the name of the Java class that implements the weblogic.common.ProxyAuthentication
interface, as shown in the following excerpt from a client application:
System.setProperty("weblogic.net.proxyAuthenticatorClassName",
"my.ProxyAuthenticator");
In the example, my.ProxyAuthenticator is a class in the client application’s CLASSPATH
that implements the weblogic.common.ProxyAuthentication interface.
The weblogic.common.ProxyAuthentication interface allows a client application to provide
user authentication information required when tunneling WebLogic HTTP and SSL protocols
through a proxy server that requires user authentication. For details on implementing this
interface, see the weblogic.common.ProxyAuthentication Javadocs.
z “Writing a Dynamic Client That Does Not Use WSDL” on page 7-27
z “Writing a Dynamic Client That Uses Non-Built-In Data Types” on page 7-29
2. Create a Service object from the factory and pass it the WSDL and the name of the Web
Service you are going to invoke.
3. Create a Call object from the Service, passing it the name of the port and the operation
you want to execute
4. Use the Call.invoke() method to actually invoke the Web Service operation.
Note: If the Web Service you are invoking from your dynamic client application uses
non-built-in data types, see “Writing a Dynamic Client That Uses Non-Built-In Data
Types” on page 7-29.
The following Java code shows an example of writing a dynamic client application:
import java.net.URL;
import javax.xml.rpc.ServiceFactory;
import javax.xml.rpc.Service;
import javax.xml.rpc.Call;
import javax.xml.rpc.ParameterMode;
import javax.xml.namespace.QName;
// define qnames
String targetNamespace =
"http://www.themindelectric.com/"
+ "wsdl/net.xmethods.services.stockquote.StockQuote/";
QName serviceName =
new QName(targetNamespace,
"net.xmethods.services.stockquote.StockQuoteService");
QName portName =
new QName(targetNamespace,
"net.xmethods.services.stockquote.StockQuotePort");
URL wsdlLocation =
new
URL("http://services.xmethods.net/soap/urn:xmethods-delayed-quotes.wsdl");
// create service
Service service = factory.createService(wsdlLocation, serviceName);
// create call
Call call = service.createCall(portName, operationName);
System.out.println("\n");
System.out.println("This example shows how to create a dynamic client
application that invokes a non-WebLogic Web Service.");
System.out.println("The webservice used was:
http://services.xmethods.net/soap/urn:xmethods-delayed-quotes.wsdl");
System.out.println("The quote for BEAS is: ");
System.out.println(result);
}
}
Note: When you use the javax.xml.rpc.Call API to create a dynamic client that uses
WSDL, you cannot use the following methods in your client application:
z getParameterTypeByName()
z getReturnType()
import javax.xml.rpc.ServiceFactory;
import javax.xml.rpc.Service;
import javax.xml.rpc.Call;
import javax.xml.rpc.ParameterMode;
import javax.xml.namespace.QName;
// define qnames
String targetNamespace =
"http://www.themindelectric.com/"
+ "wsdl/net.xmethods.services.stockquote.StockQuote/";
QName serviceName =
new QName(targetNamespace,
"net.xmethods.services.stockquote.StockQuoteService");
QName portName =
new QName(targetNamespace,
"net.xmethods.services.stockquote.StockQuotePort");
// create service
Service service = factory.createService(serviceName);
// create call
Call call = service.createCall();
"BEAS"
});
System.out.println("\n");
System.out.println("This example shows how to create a dynamic client
application that invokes a non-WebLogic Web Service.");
System.out.println("The webservice used was:
http://www.themindelectric.com/wsdl/net.xmethods.services.stockquote.StockQuot
e");
System.out.println("The quote for BEAS is:");
System.out.println(result);
}
}
Note: In dynamic clients that do not use WSDL, the getPorts() method always returns null.
This behavior is different from dynamic clients that do use WSDL in which the method
actually returns the ports.
z Code the serialization class that converts the non-built-in data type between its Java and
XML Schema representations. To create the serialization class, use the autotype Ant task
(see “autotype” on page B-7) or create one manually (see “Writing the Serialization Class”
on page 11-5.)
import javax.xml.soap.SOAPConstants;
import javax.xml.rpc.ServiceFactory;
import javax.xml.rpc.Service;
import javax.xml.rpc.Call;
import javax.xml.rpc.ParameterMode;
import javax.xml.namespace.QName;
import javax.xml.rpc.encoding.TypeMapping;
import javax.xml.rpc.encoding.TypeMappingRegistry;
import org.soapinterop.xsd.SOAPStructCodec;
import org.soapinterop.xsd.SOAPStruct;
//define qnames
String targetNamespace = "http://soapinterop.org/";
//create service
Service service = factory.createService( serviceName );
mapping.register( SOAPStruct.class,
new QName( "http://soapinterop.org/xsd", "SOAPStruct" ),
new SOAPStructCodec(),
new SOAPStructCodec() );
//create call
Call call = service.createCall();
call.addParameter( "inputStruct",
new QName( "http://soapinterop.org/xsd", "SOAPStruct" ),
ParameterMode.IN);
call.setReturnType(
new QName( "http://soapinterop.org/xsd", "SOAPStruct" ) );
System.out.println( res );
}
}
z When you run the clientgen Ant task to generate the Web Service-specific client JAR
file, be sure you specify the j2me="True" attribute, as shown in the following example:
<clientgen wsdl="http://example.com/myapp/myservice.wsdl"
packageName="myapp.myservice.client"
clientJar="myapps/myService_clients.jar"
j2me="True"
/>
Note: The J2ME Web Service-specific client JAR file generated by clientgen is not
compliant with the JAX-RPC specification in the following ways:
z When you write, compile, and run your Java client application, be sure you use the J2ME
virtual machine and APIs.
For more information about J2ME, see http://java.sun.com/j2me/.
z If your client application uses the WSDL file to invoke a Web Service, you must use a
local copy of the WSDL file stored on your client computer; you cannot access the WSDL
file using a URLConnection object.
The following sections provide information about using the WebLogic Web Services APIs:
weblogic.webservice.binding Used in a client application to set verbose mode and the character
set programmatically.
See “Setting Verbose Mode Programatically” on page 20-5 and
“Setting the Character Set When Invoking a Web Service” on
page 14-4.
writing a dynamic client to invoke the Web Service, then you must handle the data type mapping
registration yourself because dynamic clients do not use the clientgen-generated stubs.
The standard way to register a data type mapping is to use the JAX-RPC TypeMappingRegistry
class. However, using this class can be cumbersome because you must register the serialization
classes manually, and some of these serialization classes might be internal WebLogic classes.
The following example shows how to use the TypeMappingRegistry class, with the relevant
code in bold:
package examples.jaxrpc.call3;
import javax.xml.soap.SOAPConstants;
import javax.xml.rpc.ServiceFactory;
import javax.xml.rpc.Service;
import javax.xml.rpc.Call;
import javax.xml.rpc.ParameterMode;
import javax.xml.namespace.QName;
import javax.xml.rpc.encoding.TypeMapping;
import javax.xml.rpc.encoding.TypeMappingRegistry;
import org.soapinterop.xsd.SOAPStructCodec;
import org.soapinterop.xsd.SOAPStruct;
//define qnames
String targetNamespace = "http://soapinterop.org/";
//create service
Service service = factory.createService( serviceName );
mapping.register( SOAPStruct.class,
new QName( "http://soapinterop.org/xsd", "SOAPStruct" ),
new SOAPStructCodec(),
new SOAPStructCodec() );
//create call
Call call = service.createCall();
call.addParameter( "inputStruct",
new QName( "http://soapinterop.org/xsd", "SOAPStruct" ),
ParameterMode.IN);
call.setReturnType(
new QName( "http://soapinterop.org/xsd", "SOAPStruct" ) );
System.out.println( res );
}
}
The WebLogic Web Services weblogic.webservice.encoding package facilitates the
mapping registration of non-built-in data types in a dynamic client. The API defines the
following two main classes:
z DefaultTypeMapping: Used to register XML data types and associate them with a
corresponding Java data type.
z GenericTypeMapping: Used to associate all non-built-in XML data types to the generic
Java data type SOAPElement
The following procedure describes how to use the DefaultTypeMapping class in your dynamic
client application:
1. Execute the autotype Ant task to create the serialization class, Java class, XML Schema, and
types.xml file for the non-built-in data types used in your Web Service. Assume for this
example that the types.xml file is generated in the mydir directory.
For details, see “Running the autotype Ant Task” on page 6-10.
2. In your client application, import the needed WebLogic Web Service API packages:
import weblogic.webservice.encoding.GenericTypeMapping;
import weblogic.webservice.encoding.DefaultTypeMapping;
4. Use the DefaultTypeMapping class to register the types.xml file generated by the
autotype Ant task, as shown in the following code excerpt:
registry.registerDefault(
new DefaultTypeMapping( "mydir/types.xml" ) );
import weblogic.webservice.context.WebServiceContext;
import weblogic.webservice.context.ContextNotFoundException;
import weblogic.webservice.context.WebServiceSession;
....
/*
* Shows how to use HTTP Session to maintain session state between
* invokes
*/
public int maintainSessionState(){
try{
WebServiceContext wsContext = WebServiceContext.currentContext();
WebServiceSession session = (WebServiceSession)wsContext.getSession();
count = (count==null) ?
new Integer( 0 ) : new Integer( count.intValue() + 1 );
z Get the names of all parameters of the operation you are invoking
import java.io.IOException;
import java.net.URL;
import java.util.Iterator;
import java.rmi.RemoteException;
import javax.xml.namespace.QName;
import javax.xml.rpc.Service;
import javax.xml.rpc.ServiceFactory;
import javax.xml.rpc.ServiceException;
import javax.xml.rpc.Call;
import javax.xml.rpc.encoding.TypeMapping;
import javax.xml.rpc.encoding.TypeMappingRegistry;
import weblogic.webservice.encoding.GenericTypeMapping;
import weblogic.webservice.extensions.WLCall;
System.setProperty( "javax.xml.rpc.ServiceFactory",
"weblogic.webservice.core.rpc.ServiceFactoryImpl" );
System.setProperty( "weblogic.webservice.servicenamechecking",
"false" );
System.out.println( "" );
}
}
The following sections provide information about using JMS transport to invoke a WebLogic
Web Service:
z “Specifying JMS Transport for a WebLogic Web Service: Main Steps” on page 9-2
z The generated WSDL of the Web Service contains two port definitions: one with an
HTTP/S binding and one with a JMS binding. When you invoke the Web Service in your
client application, you can choose which port, and thus which type of transport, you want
to use.
Warning: Non-WebLogic client applications, such as a .NET client, will not be able to
invoke the Web Service using the JMS binding.
z The clientgen Ant task creates a Service implementation that contains two
getPortXXX() methods, one for HTTP/S and one for JMS.
Note: You can configure any WebLogic Web Service to include a JMS binding in its WSDL.
This feature is independent of JMS-implemented WebLogic Web Services.
2. Use the Administration Console to create (if they do not already exist) and configure the
following JMS components of WebLogic Server:
– JMS Template
– JMS Connection factory
– JMS Server
When creating the JMS Server, or configuring an existing one, be sure that you specify
the JMS Template you already created for the Temporary Template attribute.
Note: Do not target this JMS Server to a Migratable Target.
– JMS Queue (associated with the preceding JMS Server).
For details about creating all these components, see JMS: Configuring at
http://e-docs.bea.com/wls/docs81/ConsoleHelp/jms_config.html#jms_queue_create.
3. Update the web-services.xml file of your WebLogic Web Service to specify that the
generated WSDL include a port that uses a JMS binding.
See “Updating the web-services.xml File to Specify JMS Transport” on page 9-3.
2. Add the jmsUri attribute to the <web-service> element that describes your Web Service
and set the attribute to the following value:
connection-factory-name/queue-name
where connection-factory-name and queue-name are the JNDI names of the JMS
connection factory and JMS queues, respectively, that you previously created. For
example:
<web-service
name="myJMSTransportWebService"
jmsUri="JMSTransportFactory/JMSTransportQueue"
...>
...
</web-service>
2. Update the CLASSPATH of your client application to include the standard JMS client JAR
files:
WL_HOME/server/lib/wlclient.jar
WL_HOME/server/lib/wljmsclient.jar
3. Update your client application to use the new getPortXXX() method of the JAX-RPC
Service class generated by the clientgen Ant task. The standard getPortXXX() method
for HTTP/S is called getServiceNamePort(); the new method to use the JMS transport is
called getServiceNamePortJMS(), where ServiceName refers to the name of your Web
Service. These two gerPortXXX() methods correspond to the two port definitions in the
generated WSDL of the Web Service, as described in “Overview of Using JMS Transport”
on page 9-1.
The following example of a simple client application shows how to invoke the postWorld
operation of the MyService Web Service using both the HTTP/S transport (via the
getMyservicePort() method) and the JMS transport (via the getMyServicePortJMS()
method):
package examples.jms.client;
import java.io.IOException;
public class Main{
public static void main( String[] args ) throws Exception{
MyService service = new MyService_Impl();
{ //using HTTP transport
MyServicePort port = service.getMyServicePort();
port.postWorld( "using HTTP" );
}
{ //using JMS transport
MyServicePort port = service.getMyServicePortJMS();
port.postWorld( "using JMS" );
}
}
}
The following sections describe how to use reliable SOAP messaging, both as a sender and a
receiver of a SOAP message, between WebLogic Server instances:
operation has been invoked, but it has the guarantee that it will get one of two possible
notifications:
z sender: The WebLogic Server instance that sends the reliable SOAP message.
z sender application: The user application running in the sender that reliably invokes a Web
Service operation running on the receiver.
z sender runtime: The WebLogic Server code running on the sender that handles reliable
SOAP messaging.
z receiver: The WebLogic Server instance that receives a reliable SOAP message.
z receiver Web Service: The Web Service running on the receiver that contains the operation
configured to be invoked reliably.
z receiver runtime: The WebLogic Server code running on the receiver that handles reliable
SOAP messaging.
The following diagram and corresponding steps describe the architecture of the reliable SOAP
messaging feature.
Sender Receiver
Store Store
1 2
3 4
Sender Sender Receiver Receiver
Application Runtime Web
Runtime
6 5 Service
1. The sender application invokes a reliable operation running on the receiver WebLogic Server.
2. The sender runtime saves the message in its persistent JMS store. The store can be either a
JMS File or JDBC store.
The sender runtime sends the SOAP message to the receiver WebLogic Server.
3. The receiver runtime receives the message, checks for duplicates in its persistent JMS store,
and if none are found, saves the message ID in its store. If it finds a duplicate, the receiver
runtime acknowledges the message, but does not deliver it to the receiver Web Service.
Note: Only the message ID, and not the entire message itself, is persisted in the receiver’s
store.
The actions performed by the receiver execute within the context of a transaction. See
“Receiver Transactional Context” on page 10-4.
4. The receiver runtime invokes the reliable operation and sends an acknowledgement back to
the sender in the SOAP header.
Because only void operations can be invoked reliably, the receiver does not return any
values to the sender. If the invoked operation throws an application exception, the
exception is, however, sent back to the sender. System exceptions (from EJBs, but not from
Java classes) roll back the transaction started by a receiver. For details, see “Receiver
Transactional Context” on page 10-4.
5. The sender runtime removes the message from its persistent store so that the message does
not get sent again.
The sender is configured to retry sending the message if it does not receive notification of
receipt. You configure the number of retries, and amount of time between retries, of the
sender using the Administration Console. Once sender runtime has resent the message the
maximum number of retries, it removes the message from its store.
6. The sender runtime sends notification to the sender application (either via callbacks or
polling) that either the message was received and the operation invoked or that it was never
successfully delivered.
2. Starts a transaction.
4. If duplicates are found, the receiver sends an acknowledgement back to the sender and rolls
back the transaction.
z The EJB container or EJB application method that implements the operation issues a
rollback.
z The Java class method that implements the operation issues a rollback.
z The EJB container or EJB application method throws a system exception, such as a
RemoteException.
The following events do not cause a rollback of the transaction:
z The EJB must use only container-managed transactions; bean-managed transactions are not
supported.
z The transactional attribute of the EJB method that implements the reliable operation must
be set to one of the following values:
– Required (recommended)
– Supports
– Mandatory
Set the transactional attribute of an EJB method with the <trans-attribute> element in
the ejb-jar.xml deployment descriptor.
z If you want to explicitly roll back the transaction from the EJB application method, use the
EJBContext.setRollbackOnly() method.
z Be aware that system exceptions (such as RemoteException) thrown by the EJB container
or the EJB application method will roll back the transaction. Application exceptions (such
as WithdrawalErrorException thrown by the EJB when a user tries to withdraw too
much money from an account) do not roll back the transaction.
Guidelines for Programming the Java Class That Implements a Reliable Web
Service Operation
When creating a Java class-implemented Web Service whose operations can be invoked reliably,
follow these guidelines when programming the Java class:
z If you want to roll back the transaction from the Java method, use the Java Transaction
API (JTA) to get the transaction object and then explicitly roll back the transaction.
z Be aware exceptions thrown by the Java class never roll back the transaction.
For more information, see Programming WebLogic JTA at
http://e-docs.bea.com/wls/docs81/jta/index.html.
Note: It is assumed that you have already implemented and assembled a WebLogic Web
Service and you want to enable one or more of its operations to be invoked reliably.
Additionally, it is assumed that you have already coded a server-side application (such
as a servlet in a Web application) that invokes the Web Service in a non-reliable way and
you want to update the application to invoke the Web Service reliably.
For details about these tasks, see Chapter 5, “Implementing WebLogic Web Services,”
Chapter 6, “Assembling WebLogic Web Services Using Ant Tasks,” and Chapter 7,
“Invoking Web Services from Client Applications and WebLogic Server.”
1. Configure the reliable SOAP messaging attributes for the sender WebLogic Server instance.
See “Configuring the Sender WebLogic Server” on page 10-8.
2. Configure the reliable SOAP messaging attributes for the receiver WebLogic Server
instance.
See “Configuring the Receiver WebLogic Server” on page 10-10.
3. Update the build.xml file that contains the call to the servicegen Ant task, adding the
<reliability> child element to the <service> element that builds your Web Service on
the receiver WebLogic Server, as shown in the following example:
<servicegen
destEar="ears/myWebService.ear"
warName="myWAR.war"
contextURI="web_services" >
<service
ejbJar="jars/myEJB.jar"
targetNamespace="http://www.bea.com/examples/Trader"
serviceName="TraderService"
serviceURI="/TraderService"
generateTypes="True"
expandMethods="True" >
<reliability duplicateElimination="True"
persistDuration="60"
/>
</service>
</servicegen>
In the example, the Web Service ignores duplicate invokes from the same sender
application and persists messages for at least 60 seconds. For more information on the
attributes of the <reliability> element, see “servicegen” on page B-25.
Note: When you regenerate your Web Service using this build.xml file, every operation
that returns void will be enabled for reliable invocation. If you want only certain
operations to be invoked reliably, or you prefer not to regenerate your Web Service
using servicegen, you can update the web-services.xml file of your WebLogic
Web Service manually. For details, see “Updating the web-services.xml File
Manually for Reliable SOAP Messaging” on page 10-15.
4. Re-run the servicegen Ant task to regenerate your receiver Web Service.
6. On the client application running on the sender WebLogic Server, update the Java code that
invokes the Web Service to invoke it reliably.
For an example, see “Writing the Java Code to Invoke an Operation Reliably” on
page 10-11.
Table 10-1 Reliable SOAP Messaging Attributes for a Sender WebLogic Server
Attribute Description
Table 10-1 Reliable SOAP Messaging Attributes for a Sender WebLogic Server
Attribute Description
Default Retry Count The default maximum number of times that the sender
runtime should attempt to re-deliver a message that the
receiver WebLogic Server has not yet acknowledged.
Default value is 10.
Default Retry Interval The default minimum number of seconds that the sender
runtime should wait between retries if the receiver does
not send an acknowledgement of receiving the message,
or if the sender runtime detects a communications error
while attempting to send a message.
Default value is 600.
2. Create, if one does not already exist, a JMS store. This can be either a JMS File store or a
JMS JDBC store. See JMS File Store Tasks at
http://e-docs.bea.com/wls/docs81/ConsoleHelp/jms_config.html#configure_jms_file_stores
and JMS JDBC Store Tasks at
http://e-docs.bea.com/wls/docs81/ConsoleHelp/jms_config.html#configure_jms_jdbc_stores
.
Warning: The JMS Store is not migratable.
4. Select the WebLogic Server for which you want to configure reliable SOAP messaging in
its role as a sender.
6. Select the JMS store from the Store drop-down list that will contain WebLogic Server’s
reliable SOAP messages when acting as a sender.
7. Enter the default maximum number of times the sender WebLogic Server should attempt to
resend a message in the Default Retry Count field.
8. Enter the default minimum number of seconds that the sender WebLogic Server should wait
between retries in the Default Retry Interval field.
9. Enter the default minimum number of seconds that the receiver of the reliable SOAP
message should persist the history of the message in its JMS store in the Default Time to
Live field
Warning: This value should be larger than the corresponding value of any Web Service
operation being invoked reliably. Later sections describe how to configure his
value in the Web Service’s web-services.xml file by updating the
persist-duration attribute of the <reliable-delivery> subelement of the
invoked <operation>.
Table 10-2 Reliable SOAP Messaging Attributes for a Receiver WebLogic Server
Attribute Description
Default Time To Live The default number of seconds that the receiver of the
reliable SOAP message should persist the history of the
message in its store.
If the Default Time to Live number of seconds have
passed since the message was first sent, the sender will not
resend a message with the same message ID.
If a sender cannot send a message successfully before the
Default Time To Live number of seconds has passed, the
sender reports a delivery failure.
2. Create, if one does not already exist, a JMS store. This can be either a JMS File store or a
JMS JDBC store. See JMS File Store Tasks at
http://e-docs.bea.com/wls/docs81/ConsoleHelp/jms_config.html#configure_jms_file_stores
and JMS JDBC Store Tasks at
http://e-docs.bea.com/wls/docs81/ConsoleHelp/jms_config.html#configure_jms_jdbc_stores
.
Warning: The JMS Store is not migratable.
4. Select the WebLogic Server for which you want to configure reliable SOAP messaging in
its role as a receiver.
6. Select the JMS store from the Store drop-down list that will be used for duplicate
elimination by the receiver.
8. Click Apply.
This method also checks for correct JMS configuration and throws an exception if it finds
any errors in the configuration.
z Optionally create and set a listener to listen for the results of a reliable operation invocation
with the AsyncInfo.setResultListener(listener) method. The listener class
implements the ResultListener interface, which in turn defines the onCompletion()
listener callback method in which you define what happens when the asynchronous reliable
operation invocation completes.
The following example shows the simplest way to invoke the processOrder() operation
asynchronously and reliably by specifying the setReliableDeliver(true) method and using
the asynchronous API to split the operation into two invocations: startProcessOrder() and
endProcessOrder(). You tell the clientgen Ant task to generate these two methods in the
stubs by specifying the generateAsyncMethods attribute.
import weblogic.utils.Debug;
import weblogic.webservice.async.AsyncInfo;
import weblogic.webservice.async.FutureResult;
} catch (Exception e) {
Debug.say("Exception in ReliableSender: " + e);
}
}
}
The following more complex example builds on the previous by setting a result listener to listen
for the completion of the asynchronous and reliable operation invoke. The implementation of the
onCompletion() method specifies what happens when the invoke completes; in the example, a
message is printed if the invoke failed.
import java.io.Serializable;
import weblogic.webservice.async.AsyncInfo;
import weblogic.webservice.async.FutureResult;
import weblogic.webservice.async.InvokeCompletedEvent;
import weblogic.webservice.async.ResultListener;
import weblogic.webservice.async.ReliableDeliveryFailureEvent;
import weblogic.utils.Debug;
while ( !futureResult.isCompleted()) {
Debug.say("async polling ..."); // do something else
Thread.sleep(3000);
}
marketPort.endProcessOrder(futureResult);
} catch (Exception e) {
Debug.say("Exception in ReliableSender: " + e);
}
}
}
z Create a class that implements the ResultListener interface. This class listens for the
completion of the reliable operation invoke. See the second example “Writing the Java
Code to Invoke an Operation Reliably” on page 10-11 for a sample of writing this class.
z Code the class that implements the ResultListener interface to also implement the
Serializable interface to ensure that, in case of a sender server crash, the class will be
serialized and stored on disk. Then, once the sender server restarts, the result listener class
will also be invoked and will handle subsequent acknowledgment messages from the
receiver.
z Be sure to also serialize any information needed by the result listener class so that once the
class is instantiated after a sender server crash it can return to its previous state and
correctly handle acknowledgments from the receiver.
The web-services.xml file is located in the WEB-INF directory of the Web application of the
Web Services EAR file. See “The Web Service EAR File Package” on page 6-17 for more
information on locating the file.
To update the web-services.xml file to enable reliable SOAP messaging for one or more
operations:
2. For each operation for which you want to enable reliable SOAP messaging, add a
<reliable-delivery> subelement and specify the following optional attributes:
The following sections describe how to use non-built-in data types in WebLogic Web Services:
z Serialization class that converts between the XML and Java representation of the data.
back-end component for your Web Service. These Ant tasks can handle many non-built-in data
types, so most programmers will not ever have to create the components manually.
Sometimes, however, you may need to create the non-built-in data type components manually.
Your data type may be so complex that the Ant task cannot correctly generate the components.
Or maybe you want more control over how the data is converted between its XML and Java
representations rather than relying on the default conversion procedure used by WebLogic
Server.
For a full list of the supported non-built-in data types, see “Non-Built-In Data Types Supported
by servicegen and autotype Ant Tasks” on page 6-18.
For procedural instructions on using servicegen and autotype, see Chapter 6, “Assembling
WebLogic Web Services Using Ant Tasks.” For reference information, see Appendix B, “Web
Service Ant Tasks and Command-Line Utilities.”
1. Write the XML Schema representation of your data type. See “Writing the XML Schema Data
Type Representation” on page 11-3.
2. Write a Java class that represents your data type. See “Writing the Java Data Type
Representation” on page 11-4.
3. Write a serialization class that converts the data between its XML and Java representations.
See “Writing the Serialization Class” on page 11-5.
4. Compile your Java code into classes. Ensure that your CLASSPATH variable can locate the
classes.
5. Create a text file that contains the data type mapping information about your non-built-in
data type. See “Creating the Data Type Mapping File” on page 11-10.
6. Assemble your Web Service using the servicegen Ant task as described in “Assembling
WebLogic Web Services Using the servicegen Ant Task” on page 6-3, with the following
addition: when creating the build.xml file that calls the servicegen Ant task, be sure
you specify the typeMappingFile attribute of servicegen, setting it equal to the name of
the data type mapping file you created in the preceding step.
BEA recommends that you create an exploded directory, rather than an EAR file, by
specifying a value for the destEar attribute of servicegen that does not have an .ear
suffix. You can later package the exploded directory into an EAR file when you are ready
to deploy the Web Service.
7. Update the web-services.xml file (which was generated by the servicegen Ant task),
adding the XML Schema representation of your data type that you created in the first step
of this procedure. See “Updating the web-services.xml File With XML Schema
Information” on page 11-11.
8. Either deploy the exploded directory as your Web Service, or package the directory into an
EAR file and deploy it on WebLogic Server.
9. If you want to use the clientgen Ant task to generate a Java client, follow the procedure
described in “Running the clientgen Ant Task” on page 6-13 with the following additions to
the build.xml file that calls clientgen:
– Specify the ear attribute and set it to the full name of your Web Service EAR file. Do
not specify the wsdl attribute.
– Specify the useServerTypes attribute and set it to True.
Warning: XML Schema is a powerful and complex data description language, and its use is
not recommended for the faint of heart.
The following example shows the XML Schema that describes a non-built-in data type called
EmployBean:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:stns="java:examples.newTypes"
attributeFormDefault="qualified"
elementFormDefault="qualified"
targetNamespace="java:examples.newTypes">
<xsd:complexType name="EmployeeBean">
<xsd:sequence>
<xsd:element name="name"
type="xsd:string"
nillable="true"
minOccurs="1"
maxOccurs="1">
</xsd:element>
<xsd:element name="id"
type="xsd:int"
minOccurs="1"
maxOccurs="1">
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
For detailed information about using XML Schema notation to describe your non-built-in data
type, see the XML Schema specification at http://www.w3.org/TR/xmlschema-0/.
package examples.newTypes;
/**
* @author Copyright (c) 2002 by BEA Systems. All Rights Reserved.
*/
public EmployeeBean() {
}
package examples.newTypes;
import weblogic.webservice.encoding.AbstractCodec;
import weblogic.xml.schema.binding.DeserializationContext;
import weblogic.xml.schema.binding.DeserializationException;
import weblogic.xml.schema.binding.Deserializer;
import weblogic.xml.schema.binding.SerializationContext;
import weblogic.xml.schema.binding.SerializationException;
import weblogic.xml.schema.binding.Serializer;
import weblogic.xml.stream.Attribute;
import weblogic.xml.stream.CharacterData;
import weblogic.xml.stream.ElementFactory;
import weblogic.xml.stream.EndElement;
import weblogic.xml.stream.StartElement;
import weblogic.xml.stream.XMLEvent;
import weblogic.xml.stream.XMLInputStream;
import weblogic.xml.stream.XMLName;
import weblogic.xml.stream.XMLOutputStream;
import weblogic.xml.stream.XMLStreamException;
try {
//employee id element
writer.add(ElementFactory.createStartElement("id"));
String id_string = Integer.toString(emp.getId());
writer.add(ElementFactory.createCharacterData(id_string));
writer.add(ElementFactory.createEndElement("id"));
} catch(XMLStreamException xse) {
throw new SerializationException("stream error", xse);
}
}
try {
if (reader.skip(name, XMLEvent.START_ELEMENT)) {
StartElement top = (StartElement)reader.next();
}
} else {
throw new DeserializationException("expected start element not found");
}
} catch (XMLStreamException xse) {
throw new DeserializationException("stream error", xse);
}
return employee;
}
1. Import the following classes, which are implemented by the abstract class that your
serialization class will extend:
import weblogic.webservice.encoding.AbstractCodec;
import weblogic.xml.schema.binding.DeserializationContext;
import weblogic.xml.schema.binding.DeserializationException;
import weblogic.xml.schema.binding.Deserializer;
import weblogic.xml.schema.binding.SerializationContext;
import weblogic.xml.schema.binding.SerializationException;
import weblogic.xml.schema.binding.Serializer;
2. Import the WebLogic XML Streaming API classes as needed. The preceding example
imports the following classes:
import weblogic.xml.stream.Attribute;
import weblogic.xml.stream.CharacterData;
import weblogic.xml.stream.ElementFactory;
import weblogic.xml.stream.EndElement;
import weblogic.xml.stream.StartElement;
import weblogic.xml.stream.XMLEvent;
import weblogic.xml.stream.XMLInputStream;
import weblogic.xml.stream.XMLName;
import weblogic.xml.stream.XMLOutputStream;
import weblogic.xml.stream.XMLStreamException;
4. Implement the serialize() method, used to convert the data from Java to XML. The
signature of this method is as follows:
void serialize(Object obj,
XMLName name,
XMLOutputStream writer,
SerializationContext context)
throws SerializationException;
Your Java object will be contained in the Object parameter. Use the XML Streaming API
to write the Java object to the XMLOutputStream parameter. Use the XMLName parameter
as the name of the resulting element.
Warning: Do not update the SerializationContext parameter; it is used internally by
WebLogic Server.
5. Implement the deserialize() method, used to convert the data from XML to Java. The
signature of this method is as follows:
Object deserialize(XMLName name,
XMLInputStream reader,
DeserializationContext context)
throws DeserializationException;
The XML that you want to deserialize is contained in the XMLInputStream parameter.
Use the WebLogic XML Streaming API to parse the XML and convert it into the returned
Object. The XMLName parameter contains the expected name of the XML element.
6. If the data type for which you are creating a serialization class is used as an attribute value
in your XML files, implement the following variation of the deserialize() method:
Object deserialize(XMLName name,
Attribute att,
DeserializationContext context)
throws DeserializationException;
The Attribute parameter contains the attribute value to deserialize. The XMLName
attribute contains the expected name of the XML element.
Warning: Do not update the DeserializationContext parameter; it is used internally by
WebLogic Server.
3. For each non-built-in data type for which you have created a serialization class, add a
<type-mapping-entry> child element of the <type-mapping> element. Include the
following attributes:
– xmlns:name —Declares a namespace.
– class-name—Specifies the fully qualified name of the Java class.
– type—Specifies the name of XML Schema type for which this data type mapping
entry applies.
– serializer—The fully qualified name of the serialization class that converts the data
from its Java to its XML representation. For details on creating this class, see “Writing
the Serialization Class” on page 11-5.
– deserializer—The fully qualified name of the serialization class that converts the
data from its XML to its Java representation. For details on creating this class, see
“Writing the Serialization Class” on page 11-5.
The following example shows a possible data type mapping file with one
<type-mapping> entry for the XML Schema data type shown in “Updating the
web-services.xml File With XML Schema Information” on page 11-11:
<type-mapping>
<type-mapping-entry
xmlns:p2="java:examples.newTypes"
class-name="examples.newTypes.EmployeeBean"
type="p2:EmployeeBean"
serializer="examples.newTypes.EmployeeBeanCodec">
deserializer="examples.newTypes.EmployeeBeanCodec"
</type-mapping-entry>
</type-mapping>
1. In the existing web-services.xml file generated by the servicegen Ant task, find the
<types> child element of the <web-service> element:
<types>
...
</types>
2. Merge your XML Schema representation of your non-built-in data type that you created in
“Writing the XML Schema Data Type Representation” on page 11-3 with the any existing
information within the <types> element, as shown in the following example:
<types>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:stns="java:examples.newTypes"
attributeFormDefault="qualified"
elementFormDefault="qualified"
targetNamespace="java:examples.newTypes">
<xsd:complexType name="EmployeeBean">
<xsd:sequence>
<xsd:element name="name"
type="xsd:string"
nillable="true"
minOccurs="1"
maxOccurs="1">
</xsd:element>
<xsd:element name="id"
type="xsd:int"
minOccurs="1"
maxOccurs="1">
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
</types>
The following sections discuss how to use SOAP message handlers to intercept the request and
response SOAP messages when developing a WebLogic Web Service:
z “Designing the SOAP Message Handlers and Handler Chains” on page 12-4
The following table describes the main classes and interfaces of the javax.xml.rpc.handler
API; later sections in this chapter describe how to use them to create handlers.
1. Design the handlers and handler chains. See “Designing the SOAP Message Handlers and
Handler Chains” on page 12-4.
2. For each handler in the handler chain, create a Java class that implements the
javax.xml.rpc.handler.Handler interface. See “Implementing the Handler Interface”
on page 12-6.
WebLogic Server includes an extension to the JAX-RPC handler API which you can use to
simplify the coding of your handler class: an abstract class called
4. Update the build.xml file that contains the call to the servicegen Ant task, adding the
<handlerChain> child element to the <service> element that builds your Web Service, as
shown in the following example:
<servicegen
destEar="ears/myWebService.ear"
warName="myWAR.war"
contextURI="web_services" >
<service
ejbJar="jars/myEJB.jar"
targetNamespace="http://www.bea.com/examples/Trader"
serviceName="TraderService"
serviceURI="/TraderService"
generateTypes="True"
expandMethods="True" >
<handlerChain
name="myChain"
handlers="myHandlers.handlerOne,
myHandlers.handlerTwo,
myHandlers.handlerThree"
/>
</service>
</servicegen>
For more information on the attributes of the <handlerChain> element, see “servicegen”
on page B-25.
Note: When you regenerate your Web Service using this build.xml file, every operation
will be associated with the handler chain. Additionally, there is no way to specify
input parameters for a handler using servicegen. If you want only certain operations
to be associated with this handler chain, or you prefer not to regenerate your Web
Service using servicegen, you can update the web-services.xml file of your
WebLogic Web Service manually. For details, see “Updating the web-services.xml
File with SOAP Message Handler Information” on page 12-19.
For information about creating client-side SOAP message handlers and handler chains, see
“Using SOAP Message Handlers and Handler Chains in a Client Application” on page 12-21.
z Whether to invoke a back-end component or whether the Web Service consists of only a
handler chain.
Each handler in a handler chain has one method for handling the request SOAP message and
another method for handling the response SOAP message. You specify the handlers in the
web-services.xml deployment descriptor file. An ordered group of handlers is referred to as a
handler chain.
When invoking a Web Service, WebLogic Server executes handlers as follows:
1. The handleRequest() methods of the handlers in the handler chain are all executed, in the
order specified in the web-services.xml file. Any of these handleRequest() methods
might change the SOAP message request.
2. When the handleRequest() method of the last handler in the handler chain executes,
WebLogic Server invokes the back-end component that implements the Web Service,
passing it the final SOAP message request.
Note: This step only occurs if a back-end component has actually been defined for the Web
Service; it is possible to develop a Web Service that consists of only a handler chain.
3. When the back-end component has finished executing, the handleResponse() methods of
the handlers in the handler chain are executed in the reverse order specified in the
web-services.xml file. Any of these handleResponse() methods might change the
SOAP message response.
4. When the handleResponse() method of the first handler in the handler chain executes,
WebLogic server returns the final SOAP message response to the client application that
invoked the Web Service.
For example, assume that you have specified a handler chain called myChain that contains three
handlers in the web-services.xml deployment descriptor, as shown in the following excerpt:
<handler-chains>
<handler-chain name="myChain">
<handler class-name="myHandlers.handlerOne" />
<handler class-name="myHandlers.handlerTwo" />
<handler class-name="myHandlers.handlerThree" />
</handler-chain>
</handler-chains>
The following graphic shows the order in which WebLogic Server executes the
handleRequest() and handleResponse() methods of each handler:
Each SOAP message handler has a separate method to process the request and response SOAP
message because the same type of processing typically must happen in both places. For example,
you might design an Encryption handler whose handleRequest() method decrypts secure data
in the SOAP request and handleResponse() method encrypts the SOAP response.
You can, however, design a handler that process only the SOAP request and does no equivalent
processing of the response.
You can also choose not to invoke the next handler in the handler chain and send an immediate
response to the client application at any point. The way to do this is discussed in later sections.
Finally, you can design a Web Service that contains only handlers in a handler chain, and no
back-end component at all. In this case, when the handleRequest() method in the last handler
has executed, the chain of handleResponse() methods is automatically invoked. See “Updating
the web-services.xml File with SOAP Message Handler Information” on page 12-19 for an
example of using the web-services.xml file to specify that only a handler chain, and no
back-end component, implements a Web Service.
package examples.webservices.handler.log;
import java.util.Map;
import javax.xml.rpc.handler.Handler;
import javax.xml.rpc.handler.HandlerInfo;
import javax.xml.rpc.handler.MessageContext;
import javax.xml.rpc.handler.soap.SOAPMessageContext;
import javax.xml.rpc.JAXRPCException;
import javax.xml.namespace.QName;
import weblogic.logging.NonCatalogLogger;
/**
* Class that implements a handler in the handler chain, used to access the SOAP
* request and response message.
* <p>
* The class implements the <code>javax.xml.rpc.handler.Handler</code>
* interface. The class simply prints the SOAP request and response messages
* to a log file before the messages are processed by the backend component.
*
* @author Copyright (c) 2003 by BEA Systems. All Rights Reserved.
*/
/**
* Initializes the instance of the handler. Creates a nonCatalogLogger to
* log messages to.
*/
public void init(HandlerInfo hi) {
log = new NonCatalogLogger("WebService-LogHandler");
handlerInfo = hi;
}
/**
* Destroys the Handler instance.
*/
public void destroy() {}
/**
* Specifies that the SOAP request message be logged to a log file before the
* message is sent to the Java class backend component
*/
public boolean handleRequest(MessageContext mc) {
SOAPMessageContext messageContext = (SOAPMessageContext) mc;
/**
* Specifies that the SOAP response message be logged to a log file before the
* message is sent back to the client application that invoked the Web service.
*/
public boolean handleResponse(MessageContext mc) {
/**
* Specifies that a message be logged to the log file if a SOAP fault is
* thrown by the Handler instance.
*/
public boolean handleFault(MessageContext mc) {
SOAPMessageContext messageContext = (SOAPMessageContext) mc;
Implement the destroy() method to release any resources acquired throughout the handler’s
lifecycle.
z Invoke the next handler on the handler request chain by returning true.
The next handler on the request chain is specified as the next <handler> subelement of
the <handler-chain> element in the web-services.xml deployment descriptor. If there
are no more handlers in the chain, the method either invokes the back-end component,
passing it the final SOAP message request, or invokes the handleResponse() method of
the last handler, depending on how you have configured your Web Service.
z Invoke the next handler on the handler response chain by returning true.
The next response on the handler chain is specified as the preceding <handler>
subelement of the <handler-chain> element in the web-services.xml deployment
descriptor. (Remember that responses on the handler chain execute in the reverse order that
they are specified in the web-services.xml file. See “Designing the SOAP Message
Handlers and Handler Chains” on page 12-4 for more information.)
If there are no more handlers in the chain, the method sends the final SOAP message
response to the client application that invoked the Web Service.
Implement this method to handle processing of any SOAP faults generated by the
handleResponse() and handleRequest() methods, as well as faults generated by the
back-end component.
The MessageContext object abstracts the message context processed by the SOAP message
handler. The MessageContext properties allow the handlers in a handler chain to share
processing state.
Use the SOAPMessageContext sub-interface of MessageContext to get at or update the
contents of the SOAP message. The SOAP message itself is stored in a
javax.xml.soap.SOAPMessage object. See “Directly Manipulating the SOAP Request and
Response Message Using SAAJ” on page 12-12.
The SOAPMessageContext class defines the following two methods for processing the SOAP
message:
z Invoke the handleFault() method on the next handler in the handler chain by returning
true.
A SOAPMessage object consists of a SOAPPart object (which contains the actual SOAP XML
document) and zero or more attachments.
Refer to the SAAJ Javadocs for the full description of the SOAPMessage class. For more
information on SAAJ, go to http://java.sun.com/xml/saaj/index.html.
Warning: If you are going to access a java.awt.Image attachment from your SOAP message
handler, see “Manipulating Image Attachments in a SOAP Message Handler” on
page 12-15 for important information.
Use the following methods of the SOAPMessage class to manipulate the attachments:
import java.util.Iterator;
import javax.xml.rpc.handler.MessageContext;
import javax.xml.rpc.handler.soap.SOAPMessageContext;
import javax.xml.rpc.JAXRPCException;
import javax.xml.soap.AttachmentPart;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPMessage;
import weblogic.webservice.GenericHandler;
import weblogic.utils.Debug;
if (request.countAttachments() == 0) {
throw new JAXRPCException("** Expected attachments");
}
Iterator it = request.getAttachments();
try {
while(it.hasNext()) {
AttachmentPart part = (AttachmentPart) it.next();
Debug.say("** Received attachment: "+
part.getContent());
}
} catch (SOAPException e) {
e.printStackTrace();
throw new JAXRPCException(e);
}
return true;
if (response.countAttachments() != 0) {
throw new JAXRPCException("** Expected no attachments");
}
part.setContent("<weblogic>RESPONSE</weblogic>", "text/xml");
response.addAttachmentPart(part);
return true;
}
}
// get the input stream from the attachment and read the bytes into a
byte[]
DataHandler dh = part.getDataHandler();
InputStream is = dh.getInputStream();
int size = is.available();
byte[] bytes = new byte[size];
is.read( bytes, 0, size);
return true;
}
package weblogic.webservice;
import javax.xml.rpc.handler.Handler;
import javax.xml.rpc.handler.HandlerInfo;
import javax.xml.rpc.handler.MessageContext;
import javax.xml.namespace.QName;
/**
* @author Copyright (c) 2002 by BEA Systems. All Rights Reserved.
*/
}
The following sample code, taken from the examples.webservices.handler.nocomponent
product example, shows how to use the GenericHandler abstract class to create your own
handler. The example implements only the handleRequest() and handleResponse()
methods. It does not implement (and thus does not include in the code) the init(), destroy(),
getHeaders(), and handleFault() methods.
package examples.webservices.handler.nocomponent;
import java.util.Map;
import javax.xml.rpc.JAXRPCException;
import javax.xml.rpc.handler.MessageContext;
import javax.xml.rpc.handler.soap.SOAPMessageContext;
import javax.xml.soap.*;
import weblogic.webservice.GenericHandler;
import weblogic.utils.Debug;
/**
* @author Copyright (c) 2002 by BEA Systems. All Rights Reserved.
*/
try {
MessageFactory messageFactory = MessageFactory.newInstance();
SOAPMessage m = messageFactory.createMessage();
SOAPElement fResponse =
body.addBodyElement(env.createName("echoResponse"));
fResponse.addAttribute(env.createName("encodingStyle"),
"http://schemas.xmlsoap.org/soap/encoding/");
SOAPElement result =
fResponse.addChildElement(env.createName("result"));
result.addTextNode("Hello World");
((SOAPMessageContext)messageContext).setMessage(m);
return true;
} catch (SOAPException e) {
e.printStackTrace();
throw new JAXRPCException(e);
}
}
}
1. Create a <handler-chains> child element of the <web-services> root element that will
contain a list of all handler chains defined for the Web Service.
The following sample excerpt shows a handler chain called myChain that contains three
handlers, the first of which has an initialization parameter:
<web-services>
<handler-chains>
<handler-chain name="myChain">
<handler class-name="myHandlers.handlerOne" >
<init-params>
<init-param name="debug" value="on" />
</init-params>
</handler>
<handler class-name="myHandlers.handlerTwo" />
<handler class-name="myHandlers.handlerThree" />
</handler-chain>
</handler-chains>
...
</web-services>
3. Use the <operation> child element of the <operations> element (which itself is a child
of the <web-service> element) to specify that the handler chain is an operation of the Web
Service. Follow one of the next two scenarios:
– The handler chain executes together with a back-end component, such as a stateless
session EJB.
In this case use the component, method, and handler-chain attributes of the
<operation> element, as shown in the following partial excerpt of a
web-services.xml file:
<web-service>
<components>
<stateless-ejb name="myEJB">
...
</stateless-ejb>
</components>
<operations>
<operation name="getQuote"
method="getQuote"
component="myEJB"
handler-chain="myChain" />
</operations>
</web-service>
In the example, the request chain of the myChain handler chain executes first, then the
getQuote() method of the myEJB stateless session EJB component, and finally the
response chain of myChain.
– The handler chain executes on its own, without a back-end component.
In this case use only the handler-chain attribute of the <operation> element and
explicitly do not specify the component or method attributes, as shown in the following
excerpt:
<web-service>
<operations>
<operation name="chainService"
handler-chain="myChain" />
</operations>
</web-service>
In the example, the Web Service consists solely of the myChain handler chain.
directly before the client application sends the SOAP request to the Web Service
directly after the client application receives the SOAP response from the Web Service
You create a client-side handler in the same way you create a server-side handler: write a Java
class that implements the javax.rpc.xml.handler.Handler interface. In many cases you can
use the exact same handler class on both the Web Service running on WebLogic Server and the
client applications that invoke the Web Service. For example, you can write a generic logging
handler class that logs all sent and received SOAP messages, both for the server and for the client.
For details about writing the handler Java class, see “Implementing the Handler Interface” on
page 12-6.
After you have created your client-side handler class, the process for registering the handler on
the client application is different from that of the server. Because client applications do not have
deployment descriptors, you must register the handler programmatically using the
javax.xml.rpc.handler.HandlerInfo and javax.xml.rpc.handler.HandlerRegistry
classes. The following sample client application shows how to do this, with relevant sections in
bold discussed after the example:
import java.util.ArrayList;
import java.io.IOException;
import javax.xml.namespace.QName;
import javax.xml.rpc.ServiceException;
import javax.xml.rpc.handler.HandlerInfo;
import javax.xml.rpc.handler.HandlerRegistry;
if( args.length == 1 ){
new Main( args[0] );
}else{
throw new IllegalArgumentException( "URL of the service not specified" );
}
}
System.out.println( port.helloWorld() );
}catch( IOException e ){
System.out.println( "Failed to create web service client:" + e );
}catch( ServiceException e ){
System.out.println( "Failed to create web service client:" + e );
}
}
}
Import the JAX-RPC HandlerInfo and HandlerRegistry classes which will be used to
register the client-side handler class:
import javax.xml.rpc.handler.HandlerInfo;
import javax.xml.rpc.handler.HandlerRegistry;
Create a QName object that contains the qualified name of the Web Service port:
QName portName = new QName( "http://tutorial/sample4/",
"HelloWorldServicePort");
Refer to the WSDL of the Web Service you are invoking for the name of the port and its
namespace.
Create a List object that contains a list of the handlers you want to register. This list
becomes the client-side handler chain. Use the HandlerInfo class to specify the name of
your Java handler class:
List handlerList = new ArrayList();
handlerList.add( new HandlerInfo( ClientHandler.class, null, null ) );
In the example, the handler chain consists of just one handler: ClientHandler.class.
You can, however, create a handler chain of as many handlers as you want.
Warning: The order in which you add the handlers to the List object specifies the order in
which the handlers are executed in the client application. For example, if you want
HandlerA.class to execute first and then HandlerB.class, be sure you add
HandlerA.class to the list before HandlerB.class.
Register the handler chain with the client application using the
HandlerRegistry.setHandlerChain() method:
registry.setHandlerChain( portName, handlerList );
import javax.xml.rpc.handler.MessageContext;
...
return true;
}
The following sample code from the Java class that implements the backend component shows
how to access the TransID property using the
weblogic.webservice.context.WebServiceContext API:
import javax.xml.rpc.handler.soap.SOAPMessageContext;
import javax.xml.rpc.handler.MessageContext;
import weblogic.webservice.context.WebServiceContext;
...
}
catch(Exception ex) {
System.out.println("exception from service: " + ex.getLocalizedMessage());
}
return s;
}
Configuring Security
The following sections describe how to configure security for WebLogic Web Services:
z “Testing a Secure WebLogic Web Service From Its Home Page” on page 13-46
z Transport-level security, in which SSL is used to secure the connection between a client
application and the Web Service.
See “Configuring Transport-Level Security (SSL): Main Steps” on page 13-31.
z Access control security, which specifies which users, groups, and roles are allowed to
access Web Services.
See “Configuring Access Control Security: Main Steps” on page 13-41.
z “Unimplemented Features of the Web Services Security Core Specification” on page 13-4
z Use an X.509 certificate to encrypt and sign a SOAP message, starting from the client
application that invokes the message-secured Web Service, to the WebLogic Server
instance that is hosting the Web Service and back to the client application. The SOAP
message itself contains all the security information, so intermediaries between the client
application and Web Service can also play a part without compromising any security of the
message.
z Provide flexibility over what parts of the SOAP message are signed and encrypted. By
default, when you enable WebLogic Web Service message-level security, the entire SOAP
message body is encrypted and signed. You can, however, specify that all occurrences of a
specific element in the SOAP message be signed, encrypted, or both.
z Include an encrypted and signed username and password in the SOAP message (rather than
in the HTTP header, as is true for SSL and access control security) for further downstream
processing.
z The specification allows for any type of security token to be passed in the SOAP message.
WebLogic Web Services, however, supports only two types of tokens:
– UsernameToken
– BinarySecurityToken
Additionally, the only supported value for the ValueType attribute of the
BinarySecurityToken element is wsse:X509v3.
WebLogic Web Services do not support (among others) custom, SAML, Kerberos, and
XrML tokens.
z WebLogic Web Services uses the default Identity Asserter to map certificates to valid
users. The default Identity Asserter, however, does not verify that a client application’s
digital certificate used to sign or encrypt a SOAP message was issued by a trusted
certificate authority (CA). If you require this type of validation, you must write a custom
Identity Assertion provider for X.509 that validates the digital certificate as part of the
mapping of a user to a Subject.
For more information, see the Identity Assertion Providers section of the Developing
Security Providers for WebLogic Server guide.
z WebLogic Web Services do not support the XML Decryption Transformation algorithm
when signing a SOAP message. WebLogic Web Services support only the Exclusive XML
Canonicalization algorithm.
z A message-secured WebLogic Web Service first signs and then encrypts the out-going
SOAP response. You cannot change this order.
z WebLogic Web Services do not support secret key encryption; they support only public key
encryption.
Terminology
Note the following terms:
z keystore: file that stores key pairs and digital certificates securely.
z For a particular message-secured operation, what parts of the SOAP request and response
should be encrypted or digitally signed.
z The encryption and signature key pairs that WebLogic Server uses from its identity
keystore to sign, verify, encrypt, and decrypt the SOAP messages.
HTTP/S
A.2
WLS C.7
Client Web Services D
WebLogic
Server
Application Client
Runtime SOAP over HTTP/S
A.1
Private Key
and Certificate
Client Keystore Private Key
and Certificate
WebLogic Server
Identity Keystore
A. WebLogic Server
1. Loads the key pairs and certificates from WebLogic Server’s identity keystore.
3. Updates the WSDL of the Web service with security information so that client applications
that invoke the Web Service know what security processing needs to occur on the SOAP
request. This security information includes the certificate for WebLogic Server’s encryption
key pair, used by the client application to encrypt the SOAP request. WebLogic Server uses
the information in the <security> element of the web-services.xml deployment
descriptor file to determine how it should update the WSDL.
B. Client Application
The client application loads the signature key pair and certificate from its client keystore and uses
the weblogic.webservice.context.WebServiceContext API to add the public key and
certificate as attributes to the Web Service session.
Note: The client application uses the key pair and certificate loaded from its client keystore to
digitally sign the SOAP request. WebLogic Server later uses the key pair and certificate
to encrypt the SOAP response.
C. WebLogic Web Services Client Runtime Environment
When the client application is executed, the Web Services client runtime environment, packaged
in the client runtime JAR files, performs the following tasks:
Note: The client runtime performs all encryption and signature tasks directly before it sends the
request to WebLogic Server and after all client handlers have executed.
1. Reads the WSDL of the Web Service being invoked to determine what parts of the SOAP
request should be digitally signed or encrypted. The client runtime also gets the certificate for
the server encryption key from the WSDL.
3. Creates a <Security> element in the header of the SOAP request that will contain the
security information.
4. If required by the WSDL, inserts a username token with the client’s username and password
into the <Security> header of the SOAP request.
5. If the WSDL requires that the SOAP request be digitally signed, the Web Services client
runtime environment:
a. Generates a digital signature, according to the WSDL requirements, using the private key
from the client’s WebServiceContext.
b. Adds the digital signature to the <Security> header of the SOAP request.
c. Adds the certificate from the client’s WebServiceContext to the <Security> header of
the SOAP request. WebLogic Server later uses this certificate to verify the signature.
6. If the WSDL requires that the SOAP request be encrypted, the Web Services client runtime
environment:
a. Gets WebLogic Server’s public encryption key from the certificate published in the
WSDL.
b. Encrypts the SOAP request according to the requirements in the WSDL using WebLogic
Server’s public encryption key. The WSDL specifies what part of the SOAP message
should be encrypted.
c. Adds a description of the encryption to the <Security> header of the SOAP request.
WebLogic Server later uses this description to decrypt the SOAP request.
7. The Web Services client runtime sends the encrypted and signed SOAP request to
WebLogic Server.
D. WebLogic Server
a. Reads the description of the encryption and decrypts the SOAP request using WebLogic
Server’s private encryption key from its identity keystore.
3. If the SOAP request has been digitally signed, WebLogic Server performs the following
tasks to verify the signature:
a. Extracts the client’s certificate from the <Security> header of the SOAP request.
c. Verifies the signature using the client’s public key, obtained from the client’s certificate.
d. Asserts the identity of the client certificate to ensure that it maps to a valid WebLogic
Server user.
5. Asserts the identity of the user and verifies their password. The rest of the invocation of the
Web Service operation is run as this user.
7. Saves the client certificate that was included in the SOAP request for encrypting the SOAP
response, if required.
8. Verifies that the specifications in the <Security> header matched the requirements in the
WSDL.
9. Sends the post-processed SOAP request to the Web Services runtime for standard
invocation.
When WebLogic Server sends the SOAP response back to the client, and it is required to digitally
sign or encrypt the SOAP response, it follows the same steps as the WebLogic Web Services
client runtime environment did when it initially sent its SOAP request (see “C. WebLogic Web
Services Client Runtime Environment”), but with the following differences:
z WebLogic Server uses the public key from the saved client certificate to encrypt the SOAP
response. The client application in turn uses the private key from its
WebServiceContext (originally loaded from the client keystore) to decrypt the response.
z WebLogic Server uses the signature key pair and certificate from its identity keystore to
digitally sign the SOAP response. WebLogic Server includes this certificate in the response
so that the client application can verify the signature.
z WebLogic Server includes a username token in the SOAP response only if explicitly
specified in the web-services.xml deployment descriptor file. Typically this is not
needed because the client application does not need to assert the identity.
1. Obtain two sets of key pair and digital certificates to be used by WebLogic Web Services.
Although not required, BEA recommends that you obtain key pairs and certificates that will
be used only by WebLogic Web Services.
Warning: BEA requires that the key length be 1024 bits or larger.
For clarity, it is assumed that the key pair/certificate used for digital signatures has a name
digSigKey and password digSigKeyPassword and the one used for encryption has a
name encryptKey and password encryptKeyPassword.
You can use the Cert Gen utility or Sun Microsystem's keytool utility to perform this
step. For development purposes, the keytool utility is the easiest way to get started.
2. Create, if one does not currently exist, a custom identity keystore for WebLogic Server and
load the key pairs and digital certificates you obtained in the preceding step into the identity
keystore.
If you have already configured WebLogic Server for SSL, then you have already created a
identity keystore which you can also use for WebLogic Web Services data security
purposes.
You can use WebLogic’s ImportPrivateKey utility and Sun Microsystem’s keytool
utility to perform this step. For development purposes, the keytool utility is the easiest
way to get started.
For details, see Creating a Keystore and Loading Key Pairs Into the Keystore at
http://e-docs.bea.com/wls/docs81/secmanage/ssl.html#keystore_creating.
3. Using the Administration Console, configure WebLogic Server to locate the keystore you
created in the preceding step. If you are using a keystore that has already been configured
for WebLogic Server, you do not need to perform this step.
For details, see Configuring Keystores at
http://e-docs.bea.com/wls/docs81/secmanage/ssl.html#ConfiguringKeystores.
4. Create a keystore used by the client application. BEA recommends that you create one
client keystore per application user.
You can use the Cert Gen utility or Sun Microsystem's keytool utility to perform this
step. For development purposes, the keytool utility is the easiest way to get started.
Later sections of this document assume you created a client keystore called
client_keystore with password client_keystore_password.
5. Create a key pair and a digital certificate, and load them into the client keystore. The same
key pair will be used to digitally sign the SOAP request and encrypt the SOAP responses.
The digital certificate will be mapped to a user of WebLogic Server, created in a later step.
Warning: BEA requires that the key length be 1024 bits or larger.
You can use Sun Microsystem's keytool utility to perform this step.
Later sections of this document assume you created a key pair called client_key with
password client_key_password.
6. Using the Administration Console, configure an Identity Asserter provider for your
WebLogic Server security realm.
WebLogic Server provides a default security realm, called myrealm, which is configured
with a default Identity Asserter provider. Use this default security realm if you do not want
to configure your own Identity Asserter provider. You must, however, perform additional
configuration tasks to ensure that the default Identity Asserter Provider works correctly
with message-secured WebLogic Web Services.
For details, see “Configuring The Identity Asserter Provider for the myrealm Security
Realm” on page 13-12.
7. Using the Administration Console, create users for authentication in your security realm.
For details, see Creating Users at
http://e-docs.bea.com/wls/docs81/secwlres/usrs_grps.html.
Later sections of this guide assume you created a user auth_user with password
auth_user_password.
8. Update the build.xml file that contains the call to the servicegen Ant task by adding the
<security> child element to the <service> element that builds your Web Service.
Specify information such as the encryption key pair, the digital signature key pair, and their
corresponding passwords.
Note: The servicegen Ant task offers only course-grained control of the encryption and
digital signature configuration for a Web Service. For more fine-grained control of
the data in the SOAP message that is encrypted or digitally signed, you must update
the web-services.xml file manually. For details, see “Updating Security
Information in the web-services.xml File” on page 13-14.
For details about using servicegen, see “Updating the servicegen build.xml File” on
page 13-12.
9. Re-run the servicegen Ant task to re-assemble your Web Service and regenerate the
web-services.xml deployment descriptor.
10. Optionally encrypt the various passwords in the web-services.xml file of the EAR for
your domain before deploying the EAR file to WebLogic Server. Typically you perform this
step only when you deploy your Web Service in production mode.
For details, see “Encrypting Passwords in the web-services.xml File” on page 13-21.
11. Update your client application to invoke the message-secured Web Service.
For details, see “Updating a Java Client to Invoke a Data-Secured Web Service” on
page 13-23.
Configuring The Identity Asserter Provider for the myrealm Security Realm
You can use the default Identity Asserter provider, configured for the default myrealm security
realm, with message-secured WebLogic Web Services. You must, however, perform some
additional configuration tasks:
2. Click DefaultIdentityAsserter under the Authentication folder. The page to configure the
default Identity Asserter appears in the right pane, open to the General tab.
5. Click Apply.
8. Select the Default User Name Mapper Attribute Type used when mapping the X.509 digital
certificate to a user name.
digitally signed or encrypted, rather than specific elements. Later sections describe how to
digitally sign or encrypt specific elements.
Note: For clarity, the following excerpt of servicegen’s build.xml file contains passwords
in clear text. However, for security reasons, BEA recommends that you update your
build.xml file to prompt for the passwords, using the <input> Ant task, rather than
actually store the passwords in the file. For details on using the <input> Ant task, see
Apache Ant User Manual at http://ant.apache.org/manual/.
<servicegen
destEar="ears/myWebService.ear"
warName="myWAR.war"
contextURI="web_services" >
<service
ejbJar="jars/myEJB.jar"
targetNamespace="http://www.bea.com/examples/Trader"
serviceName="TraderService"
serviceURI="/TraderService"
generateTypes="True"
expandMethods="True" >
<security
signKeyName="digSigKey"
signKeyPass="digSigKeyPassword"
encryptKeyName="encryptKey"
encryptKeyPass="encryptKeyPassword"
/>
</service>
</servicegen>
The preceding build.xml file specifies that servicegen assemble a Web Service that includes
the following message-level security information in the web-services.xml deployment
descriptor file:
z The signKeyName and signKeyPass attributes specify that the body of the SOAP request
and response must be digitally signed. WebLogic Server uses the key pair and certificate,
accessed using the name digSigKey and password digSigKeyPassword, from its
keystore to digitally sign the SOAP response. The key pair and certificate are those that
you added in step 1 of “Configuring Message-Level Security: Main Steps” on page 13-9.
z The encryptKeyName and encryptKeyPass attributes specify that the body of the SOAP
request and response must be encrypted. WebLogic Server uses the key pair and certificate,
accessed using the name encryptKey and password encryptKeyPassword, from its
keystore to encrypt and decrypt the SOAP request. The key pair and certificate are those
that you added in step 1 of “Configuring Message-Level Security: Main Steps” on
page 13-9.
Note: Always encrypt the passwords in the web-services.xml file with the
weblogic.webservice.encryptpass utility, described in “Encrypting Passwords in
the web-services.xml File” on page 13-21.
If you use the <security> element of the servicegen Ant task to add security to your Web
Service, the entire SOAP body is encrypted and digitally signed for all operations of the Web
Service. The encryption and digital signatures occur for both the request and response SOAP
messages.
If you want more fine-grained control, such as specifying particular elements of the SOAP
message to be digitally signed or encrypted, a subset of operations that have message-level
security, and so on, update the web-services.xml file of your WebLogic Web Service
manually. For details, see “Updating Security Information in the web-services.xml File” on
page 13-14.
<web-service>
...
<security>
<signatureKey>
<name>digSigKey</name>
<password>digSigKeyPassword</password>
</signatureKey>
<encryptionKey>
<name>encryptKey</name>
<password>encryptKeyPassword</password>
</encryptionKey>
<spec:SecuritySpec xmlns:spec="http://www.openuri.org/2002/11/wsse/spec"
Namespace="http://schemas.xmlsoap.org/ws/2002/07/secext"
Id="default-spec">
<spec:BinarySecurityTokenSpec
xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/07/secext"
EncodingType="wsse:Base64Binary"
ValueType="wsse:X509v3">
</spec:BinarySecurityTokenSpec>
<spec:SignatureSpec
SignatureMethod="http://www.w3.org/2000/09/xmldsig#rsa-sha1"
SignBody="true"
CanonicalizationMethod="http://www.w3.org/2001/10/xml-exc-c14n#">
</spec:SignatureSpec>
<spec:EncryptionSpec
EncryptBody="true"
EncryptionMethod="http://www.w3.org/2001/04/xmlenc#tripledes-cbc">
</spec:EncryptionSpec>
</spec:SecuritySpec>
</security>
...
<operations>
<operation
name="myOperation" method="myMethod" component="ejbComp"
in-security-spec="default-spec" out-security-spec="default-spec">
...
</operation>
</operations>
...
</web-service>
Note: The spec prefix in the preceding example is a namespace prefix that is required for the
security information in the web-services.xml deployment descriptor file. For more
information about XML namespaces, see Namespaces in XML at
http://www.w3.org/TR/REC-xml-names/.
For example, assume that, in addition to the entire SOAP body, you want to digitally sign an
element in the SOAP header whose local name is Timestamp. To specify this configuration, add
a <spec:ElementIdentifier> child element to the <spec:SignatureSpec> element as
shown:
<spec:SignatureSpec
SignatureMethod="http://www.w3.org/2000/09/xmldsig#rsa-sha1"
SignBody="true"
CanonicalizationMethod="http://www.w3.org/2001/10/xml-exc-c14n#">
<spec:ElementIdentifier
LocalPart="Timestamp"
Namespace="http://www.bea.com/examples/security" />
</spec:SignatureSpec>
The example shows how to identify that the Timestamp element of the SOAP message be
digitally signed by using the LocalPart and Namespace attributes of the
<spec:ElementIdentifier> element. Set the LocalPart attribute equal to the name of the
element in the SOAP message you want to encrypt and the Namespace attribute to its namespace.
To get the exact name and namespace of the element, you can:
z Look at the WSDL of the Web Service. To get the WSDL of a WebLogic Web Service, use
the wsdlgen Ant task on the existing non-secure Web Service. For details, see “wsdlgen”
on page B-50.
z View the actual SOAP messages generated from an invoke of the operation when deployed
as a non-secure Web Service. For details, see “Using the Web Service Home Page to Test
Your Web Service” on page 20-2.
Specifying a particular element to be encrypted is very similar. For example, to encrypt just the
element CreditCardNumber, wherever it appears in the SOAP message (rather than the entire
SOAP body), update the <spec:EncryptionSpec> element as shown:
<spec:EncryptionSpec
EncryptionMethod="http://www.w3.org/2001/04/xmlenc#tripledes-cbc" >
<spec:ElementIdentifier
LocalPart="CreditCardNumber"
Namespace="http://www.bea.com/examples/security" />
</spec:EncryptionSpec>
For details about the <security> element, and all its child elements discussed in this section, see
Appendix A, “WebLogic Web Service Deployment Descriptor Elements.”
<web-service>
...
<security>
...
<spec:SecuritySpec xmlns:spec="http://www.openuri.org/2002/11/wsse/spec"
Namespace="http://schemas.xmlsoap.org/ws/2002/07/secext"
Id="encrypt-only">
<spec:EncryptionSpec
...
</spec:EncryptionSpec>
</spec:SecuritySpec>
<spec:SecuritySpec xmlns:spec="http://www.openuri.org/2002/11/wsse/spec"
Namespace="http://schemas.xmlsoap.org/ws/2002/07/secext"
Id="sign-only">
<spec:SignatureSpec
...
</spec:SignatureSpec>
</security>
...
</web-service>
In the example, the encrypt-only security specification requires only encryption and the
sign-only security specification requires only digital signatures. You can mix and match these
security specifications for particular operations by using the in-security-spec and
out-security-spec attributes of the relevant <operation> element, as shown in the following
example:
<operations>
<operation
name="operationOne" method="methodOne" component="ejbComp"
in-security-spec="encrypt-only"
out-security-spec="encrypt-only">
...
</operation>
<operation
name="operationTwo" method="methodTwo" component="ejbComp"
in-security-spec="sign-only">
...
</operation>
</operations>
The preceding excerpt shows that both the SOAP request and response of the operationOne
operation must be encrypted, but not digitally signed. The SOAP request for operationTwo must
be digitally signed (although not encrypted), but the SOAP response requires no security at all.
For details about the <security> and <operation> elements, see Appendix A, “WebLogic
Web Service Deployment Descriptor Elements.”
Using Timestamps
When a client application invokes a WebLogic Web Service that has been configured for
message-level security, WebLogic Server may also require and add timestamp information in the
SOAP request and response. By default, WebLogic Server:
z Requires that digitally signed SOAP requests include a timestamp and rejects any that do
not. The timestamp itself must be digitally signed.
z Assumes that its clock and the client application’s clock are not synchronized. This means
that if the SOAP request from a client application includes a timestamp with an expiration,
WebLogic Server rejects the message. This is because WebLogic Server is unable to ensure
that the message has not already expired.
z Adds a timestamp to the SOAP response. The timestamp contains only the creation date of
the SOAP response; it does not contain an expiration date.
You can change the default timestamp behavior of your WebLogic Web Service by adding a
<timestamp> child element to the <security> element in the web-services.xml deployment
descriptor.
The following web-services.xml excerpt shows an example of configuring timestamp
behavior:
<web-service>
...
<security>
<timestamp>
<clocks-synchronized>true</clocks-synchronized>
<clock-precision>30000</clock-precision>
<require-signature-timestamp>false</require-signature-timestamp>
<generate-signature-timestamp>true</generate-signature-timestamp>
<inbound-expiry>120000</inbound-expiry>
<outbound-expiry>30000</outbound-expiry>
</timestamp>
...
</security>
...
</web-service>
The preceding <timestamp> element specifies the following timestamp behavior when the
relevant Web Service operation is invoked:
z WebLogic Server’s and the client application’s clocks are synchronized, and are accurate
within 30000 milliseconds (30 seconds) of each other. This implies that if WebLogic
Server receives a digitally signed SOAP request whose expiration period is less than 30
seconds, WebLogic Server automatically rejects the request because it cannot accurately
determine if the message has expired.
z WebLogic Server does not require that digitally signed SOAP requests include a
timestamp, although it always includes a timestamp in its digitally signed SOAP responses.
z WebLogic Server has its own expiration period for digitally signed SOAP requests of
120000 milliseconds (2 minutes). This means that, independent of any client-specified
expiration, WebLogic Server rejects the request if it receives it more than 2 minutes after it
was created (adjusting for clock precision.)
z WebLogic Server includes an expiration of 30000 milliseconds (30 seconds) in the SOAP
response.
The value specified for the <clock-precision> element is a reflection of how accurately the
clocks are synchronized between WebLogic Server and the client applications that invoke the
Web Service operation. WebLogic Server uses the value to round all timestamps in a consistent
manner. For example, assume that the clock precision is 30000 milliseconds, or 30 seconds. This
means that all timestamps are rounded to the closest 30 second increment. This means that, in this
example, WebLogic Server rounds the times 12:00:10 and 11:59:50 to the same time
(12:00:00) and thus treats the two timestamps equally.
The weblogic.webservice.encryptpass utility updates the specified EAR file (or exploded
directory) by editing the <security> element of the web-services.xml file, replacing any
plain text passwords with their encrypted equivalents.
Only the WebLogic Server domain you specify to the utility is able to decrypt the passwords. This
means that if, for example, you want to deploy the EAR file on a WebLogic Server domain
different from the one you specified in the encryptpass utility, you must rerun the utility against
the EAR file that contains plain text passwords, specifying the new domain.
To encrypt the passwords:
2. Change to the domain directory of the WebLogic Server domain which will be deploying
your EAR file. The domain directory contains the config.xml file for the WebLogic
Server.
Warning: Only this WebLogic Server domain will be able to decrypt the encrypted
passwords in the web-services.xml file.
where
– options refers to one or more of the options described in Table 13-1.
– ear_or_dir refers to the full path name of the EAR file (or exploded directory) for
which you want to encrypt the passwords in the web-services.xml file.
The following example shows how to encrypt the passwords for the Hello Web Service
packaged in the ears/myService.ear file:
java weblogic.webservice.encryptpass -serviceName Hello -verbose
ears/myService.ear
-warName name Specifies the name of the Web application WAR file,
packaged inside the EAR file, that contains the
web-services.xml file.
Default value is web-services.war.
-serviceName name Specifies the name of the Web Service for which you want
to encrypt passwords. The name corresponds to the name
attribute of the Web Service’s <web-service> element
in the web-services.xml file.
Default value is the first Web Service in the
web-services.xml file.
2. Update your Java code to load a key pair and digital certificate from the client’s keystore
and pass this information, along with a username and password for user authentication, to
the secure WebLogic Web Service being invoked.
For details, see “Writing the Java Code to Invoke a Secure WebLogic Web Service” on
page 13-23.
For an example of invoking a secure non-WebLogic Web Service, see “Writing the Java
Code to Invoke a Secure Non-WebLogic Web Service” on page 13-26
import java.io.IOException;
import java.io.FileInputStream;
import javax.xml.rpc.ServiceException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import java.security.UnrecoverableKeyException;
import java.security.Key;
import java.security.KeyStore;
import java.security.PrivateKey;
import java.security.cert.X509Certificate;
import weblogic.webservice.context.WebServiceContext;
import weblogic.webservice.context.WebServiceSession;
import weblogic.webservice.core.handler.WSSEClientHandler;
import weblogic.xml.security.UserInfo;
if( args.length == 1 ){
new Main( args[0] );
}else{
throw new IllegalArgumentException( "URL of the service not specified" );
}
}
try{
HelloWorldService service = new HelloWorldService_Impl( wsdlUrl );
HelloWorldServicePort port = service.getHelloWorldServicePort();
session.setAttribute(WSSEClientHandler.CERT_ATTRIBUTE, clientcert);
session.setAttribute(WSSEClientHandler.KEY_ATTRIBUTE, clientprivate);
System.out.println( world );
}catch( IOException e ){
System.out.println( "Failed to create web service client:" + e );
}catch( ServiceException e ){
System.out.println( "Failed to create web service client:" + e );
}catch( KeyStoreException e ){
System.out.println( "Failed to create web service client:" + e );
}catch( CertificateException e ){
System.out.println( "Failed to create web service client:" + e );
}catch( UnrecoverableKeyException e ){
System.out.println( "Failed to create web service client:" + e );
}catch( NoSuchAlgorithmException e ){
System.out.println( "Failed to create web service client:" + e );
}
}
KeyStore ks = KeyStore.getInstance("JKS");
ks.load(new FileInputStream(keystore), KEYSTORE_PASS.toCharArray());
Key result = ks.getKey(keyname, password.toCharArray());
return result;
}
KeyStore ks = KeyStore.getInstance("JKS");
ks.load(new FileInputStream(keystore), KEYSTORE_PASS.toCharArray());
X509Certificate result = (X509Certificate) ks.getCertificate(keyname);
return result;
}
}
The main points to note about the preceding code are:
z Once you create the JAX-RPC Service object, get the WebLogic Web Service context:
WebServiceContext context = service.context();
Note: The weblogic.webservice.context.WebServiceContext class is a proprietary
WebLogic Web Service client API.
z Load the needed key pairs and X.509 digital certificates from a client keystore:
X509Certificate clientcert =
getCertificate(CLIENT_KEYNAME, CLIENT_KEYSTORE);
PrivateKey clientprivate =
(PrivateKey)getPrivateKey(CLIENT_KEYNAME,
CLIENT_KEYPASS,CLIENT_KEYSTORE);
z From the WebLogic Web Service context, get the session information:
WebServiceSession session = context.getSession();
z Use WebServiceSession attributes to pass the private key and digital certificates to the
WebLogic Web Service being invoked:
session.setAttribute(WSSEClientHandler.CERT_ATTRIBUTE, clientcert);
session.setAttribute(WSSEClientHandler.KEY_ATTRIBUTE,
clientprivate);
z Create a UserInfo object that contains the authentication username and password, and use
an attribute of the WebServiceSession to pass the information to the WebLogic Web
Service being invoked:
UserInfo ui = new UserInfo(AUTHENTICATION_USER,
AUTHENTICATION_USER_PASS);
session.setAttribute(WSSEClientHandler.REQUEST_USERINFO, ui);
Note: The weblogic.xml.security.UserInfo class is a WebLogic Web Service client
API.
import java.io.IOException;
import java.io.FileInputStream;
import java.util.List;
import java.util.ArrayList;
import java.security.KeyStore;
import java.security.PrivateKey;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.X509Certificate;
import java.security.cert.CertificateException;
import javax.xml.rpc.ServiceException;
import javax.xml.namespace.QName;
import javax.xml.rpc.handler.HandlerInfo;
import javax.xml.rpc.handler.HandlerRegistry;
import weblogic.webservice.context.WebServiceContext;
import weblogic.webservice.core.handler.WSSEClientHandler;
import weblogic.xml.security.wsse.Security;
import weblogic.xml.security.wsse.Token;
import weblogic.xml.security.wsse.SecurityElementFactory;
import weblogic.xml.security.specs.EncryptionSpec;
import weblogic.xml.security.specs.SignatureSpec;
import weblogic.xml.security.SecurityAssertion;
import examples.security.basicclient.BasicPort;
import examples.security.basicclient.Basic_Impl;
import examples.security.basicclient.Basic;
{
final KeyStore keystore = loadKeystore(CLIENT_KEYSTORE, KEYSTORE_PASS);
// add WSSE Client Handler to the handler chain for the service.
HandlerRegistry registry = service.getHandlerRegistry();
PrivateKey clientprivate;
clientprivate = getPrivateKey(KEY_ALIAS, KEY_PASSWORD, keystore);
security.addSignature(x509token, sigSpec);
security.addEncryption(serverToken, encSpec);
System.out.println(result);
context.getSession().getAttribute("weblogic.webservice.security.assertions.res
ponse");
for (int i = 0; i < assertions.length; i++) {
return result;
}
z Once you have the security object and tokens, create optional EncryptionSpec and
SignatureSpec objects that specify the elements of the SOAP message that you want to
encrypt or digitally sign, respectively.
EncryptionSpec encSpec = EncryptionSpec.getDefaultSpec();
SignatureSpec sigSpec = SignatureSpec.getDefaultSpec();
z Use the addTimestamp() method to to add a timestamp, and optional expiration date, to
the security element in the SOAP message. Use one of the following four flavors of the
Security.addTimestamp() method:
z Add the security element to the SOAP request by setting it as an attribute to the session
using the weblogic.webservice.security.request attribute:
context.getSession().setAttribute("weblogic.webservice.security.request",
security);
Keep the following points in mind when using the WebLogic Web Services Security APIs to
invoke a secure non-WebLogic Web Service:
z When you use the addXXX() methods to add tokens and encryption and signature
information to the <wsse:Security> element of the SOAP message, they are applied to
the message in the order you specify. They appear, however, in reverse order in the
resulting SOAP message.
z If you specify that you want the SOAP message to be digitally signed, in your Java code
add the X.509 token used for the signature after you have added the signature using the
appropriate addXXX() method. This is because the X.509 token, which specifies the actual
certificate and optional private key, should be read by the recipient of the message before it
processes the signature.
z You cannot encrypt or sign the contents of the <wsse:Security> element itself.
2. Optionally update the web-services.xml file to specify that the Web Service can be
accessed only by HTTPS.
See “Specifying the HTTPS Protocol” on page 13-44.
Warning: If you use two-way SSL to secure the connection when invoking a WebLogic Web
Service, WebLogic Server uses anonymous identity to authorize access to the Web
Service. If this authorization fails, WebLogic Server first asserts the identity of the
certificate to ensure that it maps to a valid WebLogic Server user and then uses that
user identity to invoke the Web Service, even if the Web Service or the stateless EJB
back-end component does not require any special privileges.
To use the user credentials mapped to the client certificate instead of using the
anonymous user identity, you need to disable anonymous access for the Web Service
WebLogic Server does not assert the identity of the certification in one-way SSL,
however, because in that case the client application does not send its certificate.
z Implement your Web Service client as an EJB, either stateless session or message-driven.
Then, if you want to use a single weblogic.webservice.core.rpc.StubImpl object for
all operation invocations, the EJB container will prevent more that one WebLogic execute
thread from running at a time. To do this, create an instance variable in the EJB to store the
object that extends StubImpl, as shown in the following code snippet:
1. Set the filename of the file containing trusted Certificate Authority (CA) certificates. Do this
by either:
– Setting the System property weblogic.webservice.client.ssl.trustedcertfile
to the name of the file that contains a collection of PEM-encoded certificates.
– Executing the BaseWLSSLAdapter.setTrustedCertificatesFile(String
ca_filename) method in your client application.
2. Run your Java client application, either as a standalone client or on WebLogic Server.
If you are creating a standalone client application:
– Add the WL_HOME/server/lib/webserviceclient+ssl.jar runtime Java client
JAR file to you CLASSPATH, where WL_HOME refers to the top-level directory of
WebLogic Platform. This client JAR file contains the client runtime implementation of
JAX-RPC as well as the implementation of SSL.
If your client application is running on WebLogic Server, you do not need this runtime
client JAR file.
– Set the following System properties on the command line:
z bea.home=license_file_directory
z java.protocol.handler.pkgs=com.certicom.net.ssl
where license_file_directory refers to the directory that contains the BEA license
file license.bea, as shown in the following example:
java -Dbea.home=/bea_home \
-Djava.protocol.handler.pkgs=com.certicom.net.ssl my_app
Note: If your client application is running on a computer different from the computer
hosting WebLogic Server (which is typically the case), copy the BEA license file
from the server computer to a directory on the client computer, and then point the
bea.home System property to this client-side directory.
3. If you are not using a certificate issued by a CA in your trusted CA file, then disable strict
certificate validation by either setting the
weblogic.webservice.client.ssl.strictcertchecking System property to false
at the command line when you run the standalone application, or programmatically use the
BaseWLSSLAdapter.setStrictCheckingDefault() method. Use the second way if your
client application is running on WebLogic Server.
By default, client applications that use the WebLogic SSL implementation do not share sockets.
If you want to change this behavior, see “Using SSL Socket Sharing When Using the WebLogic
SSL Implementation” on page 13-36.
// instantiate an adapter...
WLSSLAdapter adapter = new WLSSLAdapter();
adapter.setTrustedCertifcatesFile("mytrustedcerts.pem");
//create service
Service service = factory.createService( serviceName );
//create call
Call call = service.createCall();
call.setProperty("weblogic.webservice.client.ssladapter",
adapter);
try {
The example then shows how to set WLSSLAdapter as the default adapter of the adapter factory
and configures the factory to always return this default.
Note: This step is optional; it allows all Web Services to share the same adapter class along with
its associated configuration.
You can also set the adapter for a particular Web Service port or call. The preceding example
shows how to do this when using the Call class to invoke a Web Service dynamically:
call.setProperty("weblogic.webservice.client.ssladapter", adapter);
Set the property to an object that implements the weblogic.webservice.client.SSLAdapter
interface (which in this case is the WebLogic Server-provided WLSSLAdapter class.)
The following excerpt shows how to set the adapter when using the Stub interface to statically
invoke a Web Service:
((javax.xml.rpc.Stub)stubClass)._setProperty("weblogic.webservice.client.sslad
apter", adapterInstance);
You can get the adapter for a specific instance of a Web Service call or port by using the following
method for dynamic invocations:
call.getProperty("weblogic.webservice.client.ssladapter");
((javax.xml.rpc.Stub)stubClass)._getProperty("weblogic.webservice.client.sslad
apter");
For detailed information, see the Web Service security Javadocs at
http://e-docs.bea.com/wls/docs81/javadocs/weblogic/webservice/client/package-summary.html.
Using SSL Socket Sharing When Using the WebLogic SSL Implementation
By default, socket sharing is disabled for SSL client applications that connect to a WebLogic Web
Service using the WebLogic Server-provided SSL implemenation.
However, to improve the performance of your client application, you can enable socket sharing
for multiple serial invokes of a Web Service. This socket sharing mechanism provides the
improved performance of SSL connection reuse, while giving you the ability to enforce any
necessary security.
constructor specifies that the client application is using the WLSSSLAdapter subclass of the
SSLAdapter class.
To enable socket sharing in your client application with the API, use the
HttpsBindingInfo.setSocketSharing(boolean) setter method on the HttpsBindingInfo
object, passing it a value of true. To disable socket sharting, pass the method a value of false.
The default value, if you do not call this method in your application, is false (no socket sharing).
You can also specify the timeout value for shared sockets by using the
HttpsBindingInfo.setSharedSocketTimeout(long) method on the HttpsBindingInfo
object, passing it the number of seconds that shared sockets live. The default value, if you do not
set this method, is 15 seconds.
Note: This timeout value does nothing to the actual transport layer controlling the socket. The
value is used to determine if the SSL socket has not been referenced in the given
timeframe and if not, then on this reference, if the time has expired, then the socket is
closed and the protocol handshake is restarted.
To close the shared SSL socket in your client application, use the
HttpsBindingInfo.closeSharedSocket() method on the HttpsBindingInfo object. This
method takes no parameters. Typically you close the shared socket in the cleanup method of the
object from which you created the HttpsBindingInfo object.
import java.net.URL;
import java.net.Socket;
import java.net.URLConnection;
import java.io.IOException;
javax.net.SocketFactory factory =
javax.net.ssl.SSLSocketFactory.getDefault();
4. When you run your client application, set the following System property to the fully
qualified name of your adapter class:
weblogic.webservice.client.ssl.adapterclass
The default SSLAdapterFactory class loads your adapter class and creates an instance of
the class using the default no-argument constructor.
5. Configure your custom adapter class as shown in “Configuring the WebLogic SSL
Implementation Programatically” on page 13-35, substituting your class for WLSSLAdapter
and using the configuration methods defined for your adapter.
3. In your client application, create an instance of your factory and set it as the default factory
by executing the following method:
SSLAdapterFactory.setDefaultFactory(factoryInstance);
For detailed information, see the Web Service security Javadocs at
http://e-docs.bea.com/wls/docs81/javadocs/weblogic/webservice/client/package-summary.html.
...
if (argv.length > 1 ) {
System.out.println("loading client certs from "+argv[1]);
adapter.loadLocalIdentity(clientCredentialFile, pwd.toCharArray());
factory.setDefaultAdapter(adapter);
factory.setUseDefaultAdapter(true);
...
z weblogic.webservice.transport.https.proxy.host
z weblogic.webservice.transport.https.proxy.port
For more information on these System properties, see “Using Web Services System Properties”
on page 7-14.
1. Control access to either the entire Web Service or some of its components by creating roles,
mapping the roles to principals in your realm, then specifying which components are secured
and accessible only by the principals in the role.
See “Controlling Access to WebLogic Web Services” on page 13-42.
2. Optionally update the web-services.xml file to specify that the Web Service can be
accessed only by HTTPS.
3. Code your client to authenticate itself using HTTP when invoking a WebLogic Web
Service.
See “Coding a Client Application to Authenticate Itself to a Web Service” on page 13-45.
A security policy is created when you define an association between a WebLogic resource and a
user, group, or role. A WebLogic resource has no protection until you assign it a security policy.
You assign security policies to an individual resource or to attributes or operations of a resource.
If you assign a security policy to a type of resource, all new instances of that resource inherit that
security policy. Security policies assigned to individual resources or attributes override security
policies assigned to a type of resource.
To use a user or group to create a security policy, the user or group must be defined in the
Authentication provider configured in the default security realm. To use a role to create a security
policy, the role must be defined in the Role Mapping provider configured in the default security
realm. By default, the WebLogic Authentication and Role Mapping providers are configured.
For more information and procedures about setting protections for a WebLogic Web Service or
a subset of its operations using the Administration Console, see Securing WebLogic Resources at
http://e-docs.bea.com/wls/docs81/secwlres/intro.html.
For more information and procedures about securing EJBs and individual methods of an EJB
using the Administration Console, see Securing WebLogic Resources at
http://e-docs.bea.com/wls/docs81/secwlres/intro.html.
3. Re-deploy your Web Service for the change to take affect. The WSDL and Home Page of
the Web Service will be inaccessible to all users.
protocol="https" >
...
</web-service>
</web-services>
Note: If you configure SSL for WebLogic Server and you do not specify the HTTPS protocol
in the web-services.xml file, client applications can access the Web Service using
both HTTP and HTTPS. However, if you specify HTTPS access in the
web-services.xml file, client applications cannot use HTTP to access the Web
Service.
If you use the servicegen Ant task to assemble the Web Service, use the protocol attribute of
the <service> element to specify the HTTPS protocol, as shown in the following sample
build.xml file:
The following example, taken from the JAX-RPC specification, shows how to use these
properties when using the javax.xml.rpc.Stub interfaces to invoke a secure Web Service:
2. Add the following flags to the script that starts up this instance of WebLogic Server:
-Dweblogic.webservice.client.ssl.strictcertchecking=false
-Dweblogic.security.SSL.ignoreHostnameVerification=true
3. Create a trusted certificate authority (CA) file called trusted-ca.pem by following these
steps:
4. Move the trusted-ca.pem file you created in the preceding step to the domain directory
of WebLogic Server.
6. Invoke the secure WebLogic Web Service’s Home Page in your browser. The browser will
return a message saying the certificate is not trusted.
7. Load the trusted certificate in your browser. You may need to restart your browser for it to
take effect.
8. Invoke the secure WebLogic Web Service’s Home Page again in your browser. You should
now be able to test your secure Web Service as described in “Deploying and Testing
WebLogic Web Services” on page 6-23.
Internationalization
Overview of Internationalization
Internationalization refers to the preparation of software so that it behaves properly in multiple
locations. Internationalization of WebLogic Web Services primarily involves specifying the
character set of the SOAP request and response. You then specify the character set of the SOAP
request inside the client application that invokes the Web Service. There are a variety of ways to
specify the character set that WebLogic Server uses in its SOAP response, as outlined in later
sections. WebLogic Server can also accept many character sets in a SOAP request used to invoke
a deployed WebLogic Web Service.
Often the default character sets used by WebLogic Server are adequate and you do not need to
explicitly specify a character set for a Web Service. For example, if a client application specifies
its preferred character set, and there is no character set specified for a Web Service, then
WebLogic Server responds by using the client’s preferred character set. Also,
non-internationalized WebLogic Server instances use the US-ASCII character set by default, and
internationalized WebLogic Server instances use the UTF-8 character set by default, and both of
these character sets are compatible when one WebLogic Server instance is communicating with
the other. This also means that a Web Service running on a non-internationalized WebLogic
Server instance can handle multi-byte characters correctly.
However, if the default character sets are not adequate for your application, use the information
here to specify the character set that you need.
1. The value of the charset attribute in the corresponding <web-service> element of the
web-services.xml deployment descriptor.
2. The character set preferred by the client application that invoked the Web Service operation.
If your client application uses the WebLogic Web Services client APIS, the character set is
specified using the
weblogic.webservice.binding.BindingInfo.setAcceptCharset() method.
4. The character set specified for the JVM. Specifically, if the JVM property user.language
is set to en, then WebLogic Web Services use the US-ASCII character set. If the
user.language property is set to anything else, WebLogic Web Services use the UTF-8
character set.
import weblogic.webservice.binding.BindingInfo;
...
BindingInfo info =
(BindingInfo)stub._getProperty("weblogic.webservice.bindinginfo" );
For more information about the weblogic.webservice.binding package, see the Javadocs at
http://e-docs.bea.com/wls/docs81/javadocs/index.html.
z WebLogic Web Services always honor the charset attribute of the Content-Type HTTP
header, which specifies the character set of the SOAP request.
z WebLogic Web Services sometimes honor the Accept-Charset HTTP header. This header
specifies the character set of the SOAP response preferred by the application that invoked
the Web Service operation. If the WebLogic Web Service has not been configured with a
specific character set (see “Specifying the Character Set for a WebLogic Web Service” on
page 14-2), the SOAP response uses the character set specified by the Accept-Charset
HTTP header. If, however, the WebLogic Web Service is configured to use a specific
character set, that character set is always used in the SOAP response.
z WebLogic Web Services never honor the encoding attribute of the optional <?xml?>
element that starts the SOAP 1.1 envelope.
Note: This is true only for SOAP 1.1. For SOAP 1.2, if the ContentType HTTP Header is
missing, then the encoding attribute of the <?xml?> element is honored.
The following excerpt of a SOAP envelope, including the HTTP headers, shows the three ways
of specifying characters sets in bold:
POST /StockQuote HTTP/1.1
Host: www.sample.com
Content-Type: text/xml; charset="US-ASCII"
Content-Length: nnnn
SOAPAction: "Some-URI"
Accept-Charset: UTF-8
<?xml version="1.0" encoding="UTF-16"?>
<SOAP-ENV:Envelope
...
</SOAP-ENV:Envelope>
The following sections provide information about using SOAP 1.2 as the message format:
z “Specifying SOAP 1.2 for a WebLogic Web Service: Main Steps” on page 15-2
Warning: BEA’s SOAP 1.2 implementation is based on the W3C Working Draft specification
(June 26, 2002). Because this specification is not yet a W3C Recommendation,
BEA’s current implementation is subject to change. BEA highly recommends that
you use the SOAP 1.2 feature included in this version of WebLogic Server in a
development environment only.
When a WebLogic Web Service is configured to use SOAP 1.2 as the message format:
z The generated WSDL of the Web Service contains two port definitions: one with a SOAP
1.1 binding, and another with a SOAP 1.2 binding.
z The clientgen Ant task, when generating the Web-service specific client JAR file for the
Web Service, creates a Service implementation that contains two getPort() methods,
one for SOAP 1.1 and another for SOAP 1.2.
1. Update the build.xml file that contains the call to the servicegen Ant task, adding the
attribute useSOAP12="True" to the <service> element that builds your Web Service, as
shown in the following example:
<servicegen
destEar="ears/myWebService.ear"
warName="myWAR.war"
contextURI="web_services" >
<service
ejbJar="jars/myEJB.jar"
targetNamespace="http://www.bea.com/examples/Trader"
serviceName="TraderService"
serviceURI="/TraderService"
generateTypes="True"
expandMethods="True"
useSOAP12="True" >
</service>
</servicegen>
Note: If you are not using servicegen, you can update the web-services.xml file of
your WebLogic Web Service manually. For details, see “Updating the
web-services.xml File Manually” on page 15-3.
2. Re-run the servicegen Ant task to regenerate your Web Service to use SOAP 1.2.
For general details about the servicegen Ant task, see “Creating the Build File That
Specifies the servicegen Ant Task” on page 6-5.
Because the WSDL of the Web Service has been updated to include an additional port with
a SOAP 1.2 binding, the clientgen Ant task automatically creates new stubs that contains
these SOAP 1.2-specific getPort() methods.
For details, see “Generating the Client JAR File by Running the clientgen Ant Task” on
page 7-5.
See “Invoking a Web Service Using SOAP 1.2” on page 15-3 for details about writing a Java
client application that invokes your Web Service.
2. Add the useSOAP12="True" attribute to the <web-service> element that describes your
Web Service. For example:
<web-service
name="myWebService"
useSOAP12="True"
...>
...
</web-service>
import java.io.IOException;
port = service.getMyServicePortSoap12();
System.out.println( port.helloWorld() );
}
}
The following sections describe how to create JMS-implemented WebLogic Web Services:
You implement this type of operation with a JMS message producer. The message producer
puts a message on the specified JMS queue and a client invoking this message-style Web
Service component polls and receives the message.
When a client application sends data to a JMS-implemented Web Service operation, WebLogic
Server first converts the XML data to its Java representation using either the built-in or custom
serializers, depending on whether the data type of the data is built-in or not. WebLogic Server
then wraps the resulting Java object in a javax.jms.ObjectMessage object and puts it on the
JMS destination. You can then write a JMS listener, such as a message-driven bean, to take the
ObjectMessage and process it. Similar steps happen in reverse when a client application invokes
a Web Service to receive data from a JMS queue.
If you are using non-built-in data types, you must update the web-services.xml deployment
descriptor file with the correct data type mapping information. If the Web Service cannot find
data type mapping information for the data, then it converts the data to a
javax.xml.soap.SOAPElement data type, defined by the SOAP With Attachments API For
Java (SAAJ) specification.
Note: Input and return parameters to a Web Service operation implemented with a JMS
consumer or producer must implement the java.io.Serializable interface.
For detailed information about programming message-driven beans, see Programming WebLogic
Enterprise JavaBeans at http://e-docs.bea.com/wls/docs81/ejb/index.html.
message-driven bean that processed the message puts the response on the JMS destination
corresponding to the receiving Web Service operation.
Figure 16-1 Data Flow Between JMS-Implemented Web Service Operations and JMS
WebLogic Server
Client
Message-Driven Bean
1. Write the Java code for the J2EE component (typically a message-driven bean) that will
consume or produce the message from or on the JMS destination.
2. Use the Administration Console to configure the following JMS components of WebLogic
Server:
– The JMS queue that will either receive the XML data from a client or send XML data
to a client. Later, when you assemble the Web Service as described in Chapter 6,
“Assembling WebLogic Web Services Using Ant Tasks,” you will use the name of this
JMS destination.
– The JMS Connection factory that the WebLogic Web Service uses to create JMS
connections.
For more information on this step, see “Configuring JMS Components for Message-Style
Web Services” on page 16-4.
1. Invoke the Administration Console in your browser. For details, see “Overview of
Administering WebLogic Web Services” on page 17-1.
5. Enter the JNDI name of the Connection Factory in the JNDIName field.
6. Enter values in the remaining fields as appropriate. For information on these fields, see
JMS: Configuring at http://e-docs.bea.com/wls/docs81/ConsoleHelp/jms_config.html.
7. Click Create.
8. Select the servers or clusters on which you would like to deploy this JMS connection
factory.
9. Click Apply.
11. Select the JMS server for which you want to create a JMS destination.
12. Right-click the Destinations node and choose from the drop-down list Configure a new
JMSQueue to create a queue.
13. Enter the name of the JMS destination in the Name text field.
14. Enter the JNDI name of the destination in the JNDIName text field.
15. Enter values in the remaining fields as appropriate. For information on these fields, see
JMS: Configuring at http://e-docs.bea.com/wls/docs81/ConsoleHelp/jms_config.html.
2. Package your JMS message consumers and producers (such as message-driven beans) into a
JAR file.
For detailed information on this step, refer to Developing WebLogic Server Applications at
http://e-docs.bea.com/wls/docs81/programming/environment.html.
On UNIX, execute the setEnv.sh command, located in your domain directory. The
default location of WebLogic Server domains is
BEA_HOME/user_projects/domains/domainName, where BEA_HOME is the top-level
installation directory of the BEA products and domainName is the name of your domain.
5. In the staging directory, create the Ant build file (called build.xml by default) that
contains a call to the servicegen Ant task.
For details about specifying the servicegen Ant task, see Listing 16-1.
For general information about creating Ant build files, see
http://jakarta.apache.org/ant/manual/.
Note: The Apache Jakarta Web site publishes online documentation for only the most
current version of Ant, which might be different from the version of Ant that is
bundled with WebLogic Server. To determine the version of Ant that is bundled with
WebLogic Server, run the following command after setting your WebLogic
environment:
prompt> ant -version
To view the documentation for a specific version of Ant, download the Ant zip file
from http://archive.apache.org/dist/ant/binaries/ and extract the documentation.
6. Execute the Ant task or tasks specified in the build.xml file by typing ant in the staging
directory, optionally passing the command a target argument:
prompt> ant
The Ant task generates the Web Services EAR file in the staging directory which you can
then deploy on WebLogic Server.
The following sample build.xml file contains a call to the servicegen Ant task.
JMSDestinationType="queue"
JMSConnectionFactory="jms.connectionFactory.queue"
JMSOperationName="sendName"
JMSMessageType="types.myType"
generateTypes="True"
targetNamespace="http://tempuri.org"
serviceName="jmsSendQueueService"
serviceURI="/jmsSendQueue"
expandMethods="True">
</service>
</servicegen>
</target>
</project>
When you run the servicegen Ant task using the preceding build.xml file, the Ant task creates
a single Web Service called jmsSendQueueService. The URI to identify this Web Service is
/jmsSendQueue; the full URL to access the Web Service is
http://host:port/WebServices/jmsSendQueue
The servicegen Ant task packages the Web Service in an EAR file called
jms_send_queue.ear. The EAR file contains a WAR file called web-services.war (default
name) that contains all the Web Service components, such as the web-services.xml
deployment descriptor file.
The Web Service exposes a single operation called sendName. Client applications that invoke this
Web Service operation send messages to a JMS queue whose JNDI name is
jms.destination.queue1. The JMS ConnectionFactory used to create the connection to
this queue is jms.connectionFactory.queue. The data type of the single parameter of the
sendName operation is types.myType. Because the generateTypes attribute is set to True, the
servicegen Ant task generates the non-built-in data type components for this data type, such as
the serialization class.
Note: The types.myType Java class must be in servicegen’s CLASSPATH so that
servicegen can generate appropriate components.
1. Package the JMS message consumers and producers into a JAR file. See “Packaging the JMS
Message Consumers and Producers” on page 16-8.
2. Update the web-services.xml file with component information. See “Updating the
web-services.xml File With Component Information” on page 16-8.
3. Follow the steps described in “Assembling WebLogic Web Services Using Individual Ant
Tasks” on page 6-6, using the JMS-specific information where appropriate.
The following sections describe JMS-specific information about assembling Web Services
manually.
This element describes a JMS back-end component to which client applications send data.
The component puts the sent data on to a JMS destination. Use the connection-factory
attribute of this element to specify the JMS Connection factory that WebLogic Server uses
to create a JMS Connection object. Use the <jndi-name> child element to specify the
JNDI name of the destination, as shown in the following example:
<components>
<jms-send-destination name="inqueue"
connection-factory="myapp.myqueueCF">
<jndi-name path="myapp.myqueueIN" />
</jms-send-destination>
</components>
z <jms-receive-queue>
This element describes the JMS back-end component in which client applications receive
data, in particular from a JMS queue. Use the connection-factory attribute to specify
the JMS Connection factory that WebLogic Server users to create a JMS Connection
object. Use the <jndi-name> child element to specify the JNDI name of the queue, as
shown in the following example:
<components>
<jms-receive-queue name="outqueue"
connection-factory="myapp.myqueueCF">
<jndi-name path="myapp.myqueueOUT" />
</jms-receive-queue>
</components>
<web-services>
<web-service targetNamespace="http://example.com"
name="myMessageService" uri="MessageService">
<components>
<jms-send-destination name="inqueue"
connection-factory="myapp.myqueuecf">
<jndi-name path="myapp.myinputqueue" />
</jms-send-destination>
<jms-receive-queue name="outqueue"
connection-factory="myapp.myqueuecf">
<jndi-name path="myapp.myoutputqueue" />
</jms-receive-queue>
</components>
<operations xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<operation invocation-style="one-way" name="enqueue"
component="inqueue" />
<params>
<param name="input_payload" style="in" type="xsd:anyType" />
</params>
</operation>
<operation invocation-style="request-response" name="dequeue"
component="outqueue" >
<params>
<return-param name="output_payload" type="xsd:anyType"/>
</params>
</operation>
</operations>
</web-service>
</web-services>
The example shows two JMS back-end components, one called inqueue in which a client
application sends data to a JMS destination, and one called outqueue in which a client
application receives data from a JMS queue.
Two corresponding Web Service operations, enqueue and dequeue, are implemented with these
back-end components.
The enqueue operation is implemented with the inqueue component. This operation is defined
to be asynchronous one-way, which means that the client application, after sending the data to the
JMS destination, does not receive a SOAP response (not even an exception.) The data sent by the
client is contained in the input_payload parameter.
The dequeue operation is implemented with the outqueue component. The dequeue operation
is defined as synchronous request-response because the client application invokes the operation
to receive data from the JMS queue. The response data is contained in the output parameter
output_payload.
receives data from another operation within the same Web Service. The first operation is
implemented with a JMS destination, the second with a JMS queue, as shown in the following
web-services.xml file that describes the Web Service:
<web-service
name="BounceService"
targetNamespace="http://www.foobar.com/echo"
uri="/BounceService">
<components>
<jms-send-destination name="inqueue"
connection-factory="weblogic.jms.ConnectionFactory">
<jndi-name path="weblogic.jms.inqueue" />
</jms-send-destination>
<jms-receive-queue name="outqueue"
connection-factory="weblogic.jms.ConnectionFactory">
<jndi-name path="weblogic.jms.outqueue" />
</jms-receive-queue>
</components>
<operations xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<operation invocation-style="one-way" name="submit" component="inqueue" >
</operation>
<operation invocation-style="request-response"
name="query" component="outqueue" >
<params>
<return-param name="output_payload" type="xsd:string"/>
</params>
</operation>
</operations>
</web-service>
</web-services>
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import javax.xml.rpc.ServiceFactory;
import javax.xml.rpc.Service;
import javax.xml.rpc.Call;
import javax.xml.rpc.ParameterMode;
import javax.xml.namespace.QName;
/**
* @author Copyright (c) 2002 by BEA Systems, Inc. All Rights Reserved.
*/
/**
* send2WS - this module sends to a specific Web Service connected JMS queue
* If the message is 'quit' then the module exits.
*
* @returns
* @throws Exception
*/
//define qnames
String targetNamespace = "http://www.foobar.com/echo";
//create service
Service service = factory.createService( serviceName );
//add parameters
Ws2JmsCall.addParameter( "param",
);
//set end point address
Ws2JmsCall.setTargetEndpointAddress(
"http://localhost:7001/BounceBean/BounceService" );
import javax.xml.rpc.ServiceFactory;
import javax.xml.rpc.Service;
import javax.xml.rpc.Call;
import javax.xml.rpc.ParameterMode;
import javax.xml.namespace.QName;
/**
* @author Copyright (c) 2002 by BEA Systems, Inc. All Rights Reserved.
*/
/**
* fromWS - this module receives from a Web Service associated JMS queue
* If the message is 'quit' then the module exits.
*
* @returns
* @throws Exception
*/
//define qnames
String targetNamespace = "http://www.foobar.com/echo";
//create service
Service service = factory.createService( serviceName );
//add parameters
Ws2JmsCall.addParameter( "output_payload",
new QName( "http://www.w3.org/2001/XMLSchema", "string" ),
ParameterMode.OUT );
//set end point address
Ws2JmsCall.setTargetEndpointAddress(
"http://localhost:7001/BounceBean/BounceService" );
while (!quit) {
String result = (String)Ws2JmsCall.invoke( new Object[] {} );
if(result != null) {
System.out.println("TextMessage:" + result);
if (result.equalsIgnoreCase("quit")) {
quit = true;
System.out.println("Done!");
}
continue;
}
try {Thread.sleep(2000);} catch (Exception ignore) {}
}
}
}
The following sections describe tasks for administering WebLogic Web Services:
the icon to indicate that the WAR file is in fact a Web Service.
To invoke the Administration Console in your browser, enter the following URL:
http://host:port/console
where
z port refers to the port number where the Administration Server is listening for connection
requests. The default port number for the Administration server is 7001.
The following figure shows the main Administration Console window.
The following sections provide information about publishing and finding Web Services using
UDDI:
Overview of UDDI
UDDI stands for Universal Description, Discovery and Integration. The UDDI Project is an
industry initiative that is working to enable businesses to quickly, easily, and dynamically find
and carry out transactions with one another.
A populated UDDI registry contains cataloged information about businesses, the services that
they offer and communication standards and interfaces they use to conduct transactions.
Built on the Simple Object Access Protocol (SOAP) data communication standard, UDDI creates
a global, platform-independent, open architecture space that will benefit businesses.
The UDDI registry can be broadly divided into two categories:
2. To seek the updated value of the invocation point (i.e., access point) of a known binding
template ID.
businessService A logical group of one or several Web A group of services may reside in a single
Services. businessEntity.
API(s) with a single name stored as a child • Multiple names and descriptions
element, contained by the business entity • Categories
named above.
• Indicators of compliancy with
standards
z Pluggable tModel
Warning: If your WebLogic Server domain was created by a user different from the user that
installed WebLogic Server, the WebLogic Server administrator must change the
permissions on the uddi.properties file to give access to all users.
To restore your configuration to its default, remove the uddi.properties file from the
WL_HOME/server/lib directory. BEA strongly recommends that you move this file to a backup
location, because a new uddi.properties file will be created and with its successful startup the
uddi.properties.booted file will also be overwritten. After removing the properties file, start
the server. Minimal default properties will be loaded and written to a newly created
uddi.properties file.
The following section describes the UDDI Server properties that you can include in the
uddi.properites file. The list of properties has been divided according to component, usage
and functionality. At any given time, you do not need all these properties to be present.
2. Update the 51acumen.ldif file with the content described in “51acumen.ldif File
Contents” on page 18-6.
4. Update the uddi.properties file of the WebLogic UDDI 2.0 Server, adding the following
properties:
datasource.ldap.manager.password
datasource.ldap.manager.uid
datasource.ldap.server.root
datasource.ldap.server.url
The value of the properties depends on the configuration of your SunOne Directory Server.
The following example shows a possible configuration that uses default values:
datasource.ldap.manager.password=password
datasource.ldap.manager.uid=cn=Directory Manager
datasource.ldap.server.root=dc=beasys,dc=com
datasource.ldap.server.url=ldap://host:port
See Table 18-11, “LDAP Security Configuration,” on page 18-20 for information about
these properties.
dn: cn=schema
#
# attribute types:
#
attributeTypes: ( 11827.0001.1.0 NAME 'uddi-Business-Key' DESC
'Business Key' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{41} SINGLE-VALUE X-ORIGIN
'acumen defined' )
attributeTypes: ( 11827.0001.1.1 NAME 'uddi-Authorized-Name' DESC
'Authorized Name for publisher of data' SYNTAX
1.3.6.1.4.1.1466.115.121.1.15{255} X-ORIGIN 'acumen defined' )
attributeTypes: ( 11827.0001.1.2 NAME 'uddi-Operator' DESC
'Name of UDDI Registry Operator' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{255}
X-ORIGIN 'acumen defined' )
attributeTypes: ( 11827.0001.1.3 NAME 'uddi-Name' DESC
'Business Entity Name' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{258} X-ORIGIN
'acumen defined' )
attributeTypes: ( 11827.0001.1.4 NAME 'uddi-Description' DESC
'Description of Business Entity' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{255}
X-ORIGIN 'acumen defined' )
attributeTypes: ( 11827.0001.1.7 NAME 'uddi-Use-Type' DESC
'Name of convention that the referenced document follows' SYNTAX
1.3.6.1.4.1.1466.115.121.1.15{255} X-ORIGIN 'acumen defined' )
attributeTypes: ( 11827.0001.1.8 NAME 'uddi-URL' DESC
'URL' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{255} X-ORIGIN 'acumen defined' )
attributeTypes: ( 11827.0001.1.9 NAME 'uddi-Person-Name' DESC
'Name of Contact Person' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{255} X-ORIGIN
'acumen defined' )
attributeTypes: ( 11827.0001.1.10 NAME 'uddi-Phone' DESC
'Telephone Number' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{50} X-ORIGIN 'acumen
defined' )
attributeTypes: ( 11827.0001.1.11 NAME 'uddi-Email' DESC
'Email address' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{255} X-ORIGIN 'acumen
defined' )
attributeTypes: ( 11827.0001.1.12 NAME 'uddi-Sort-Code' DESC
'Code to sort addresses' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{10} X-ORIGIN
'acumen defined' )
attributeTypes: ( 11827.0001.1.13 NAME 'uddi-tModel-Key' DESC
'Key to reference a tModel entry' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{255}
SINGLE-VALUE X-ORIGIN 'acumen defined' )
attributeTypes: ( 11827.0001.1.14 NAME 'uddi-Address-Line' DESC
'Actual address lines in free form text' SYNTAX
1.3.6.1.4.1.1466.115.121.1.15{80} X-ORIGIN 'acumen defined' )
attributeTypes: ( 11827.0001.1.15 NAME 'uddi-Service-Key' DESC
'Service Key' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{41} SINGLE-VALUE X-ORIGIN
'acumen defined' )
attributeTypes: ( 11827.0001.1.16 NAME 'uddi-Service-Name' DESC
'Service Name' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{255} X-ORIGIN 'acumen
defined' )
attributeTypes: ( 11827.0001.1.17 NAME 'uddi-Binding-Key' DESC
'Binding Key' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{41} SINGLE-VALUE X-ORIGIN
'acumen defined' )
attributeTypes: ( 11827.0001.1.18 NAME 'uddi-Access-Point' DESC 'A
text field to convey the entry point address for calling a web service' SYNTAX
1.3.6.1.4.1.1466.115.121.1.15{255} X-ORIGIN 'acumen defined' )
attributeTypes: ( 11827.0001.1.19 NAME 'uddi-Hosting-Redirector' DESC
'Provides a Binding Key attribute to redirect reference to a different binding
template' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{41} SINGLE-VALUE X-ORIGIN
'acumen defined' )
attributeTypes: ( 11827.0001.1.20 NAME 'uddi-Instance-Parms' DESC
'Parameters to use a specific facet of a bindingTemplate description' SYNTAX
1.3.6.1.4.1.1466.115.121.1.15{255} X-ORIGIN 'acumen defined' )
attributeTypes: ( 11827.0001.1.21 NAME 'uddi-Overview-URL' DESC
'URL reference to a long form of an overview document' SYNTAX
1.3.6.1.4.1.1466.115.121.1.15{255} X-ORIGIN 'acumen defined' )
attributeTypes: ( 11827.0001.1.22 NAME 'uddi-From-Key' DESC
'Unique key reference to first businessEntity assertion is made for' SYNTAX
1.3.6.1.4.1.1466.115.121.1.15{41} SINGLE-VALUE X-ORIGIN 'acumen defined' )
attributeTypes: ( 11827.0001.1.23 NAME 'uddi-To-Key' DESC
'Unique key reference to second businessEntity assertion is made for' SYNTAX
1.3.6.1.4.1.1466.115.121.1.15{41} SINGLE-VALUE X-ORIGIN 'acumen defined' )
attributeTypes: ( 11827.0001.1.24 NAME 'uddi-Key-Name' DESC
'An attribute of the KeyedReference structure' SYNTAX
1.3.6.1.4.1.1466.115.121.1.15{255} X-ORIGIN 'acumen defined' )
attributeTypes: ( 11827.0001.1.25 NAME 'uddi-Key-Value' DESC
'An attribute of the KeyedReference structure' SYNTAX
1.3.6.1.4.1.1466.115.121.1.15{255} X-ORIGIN 'acumen defined' )
attributeTypes: ( 11827.0001.1.26 NAME 'uddi-Auth-Info' DESC
'Authorization information' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{4096} X-ORIGIN
'acumen defined' )
attributeTypes: ( 11827.0001.1.27 NAME 'uddi-Key-Type' DESC
'The key for all UDDI entries' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{16} X-ORIGIN
'acumen defined' )
attributeTypes: ( 11827.0001.1.28 NAME 'uddi-Upload-Register' DESC
'The upload register' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{255} X-ORIGIN 'acumen
defined' )
attributeTypes: ( 11827.0001.1.29 NAME 'uddi-URL-Type' DESC
'The type for the URL' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{16} X-ORIGIN 'acumen
defined' )
attributeTypes: ( 11827.0001.1.30 NAME 'uddi-Ref-Keyed-Reference' DESC
'reference to a keyedReference entry' SYNTAX 1.3.6.1.4.1.1466.115.121.1.12{255}
X-ORIGIN 'acumen defined' )
attributeTypes: ( 11827.0001.1.31 NAME 'uddi-Ref-Category-Bag' DESC
'reference to a categoryBag entry' SYNTAX 1.3.6.1.4.1.1466.115.121.1.12{255}
X-ORIGIN 'acumen defined' )
attributeTypes: ( 11827.0001.1.32 NAME 'uddi-Ref-Identifier-Bag' DESC
'reference to a identifierBag entry' SYNTAX 1.3.6.1.4.1.1466.115.121.1.12{255}
X-ORIGIN 'acumen defined' )
attributeTypes: ( 11827.0001.1.33 NAME 'uddi-Ref-TModel' DESC
'reference to a TModel entry' SYNTAX 1.3.6.1.4.1.1466.115.121.1.12{255}
SINGLE-VALUE X-ORIGIN 'acumen defined' )
# id names for each entry
z Logger Configuration
z Connection Pools
auddi.discoveryurl Specifies the DiscoveryURL prefix that is set for each saved
business entity. This will typically be the full URL to the
uddilistener servlet, so that the full DiscoveryURL results in the
display of the stored BusinessEntity data.
auddi.inquiry.secure Permissible values are true and false. When set to true,
inquiry calls to UDDI Server will be limited to secure https
connections only. Any UDDI inquiry calls through a regular http
URL will be rejected.
auddi.publish.secure Permissible values are true and false. When set to true,
publish calls to UDDI Server will be limited to secure https
connections only. Any UDDI publish calls through a regular
http URL will be rejected.
auddi.search.timeout The value of this property specifies a timeout value for search
operations. The value is indicated in milliseconds.
auddi.siteoperator This property determines the name of the UDDI registry site
operator. The specified value will be used as the operator
attribute, saved in all future BusinessEntity registrations. This
attribute will later be returned in responses, and indicates which
UDDI registry has generated the response.
auddi.license.dir The value of this property specifies the location of the UDDI
Server license file. In the absence of this property, the
WL_HOME/server/lib directory is assumed to be the default
license directory, where WL_HOME is the main WebLogic
Platform installation directory. Some WebLogic users are
exempt from requiring an UDDI Server license for the basic
UDDI Server components, while they may need a license for
additional components (e.g., UDDI Server Browser).
auddi.license.file The value of this property specifies the name of the license file.
In the absence of this property, uddilicense.xml is
presumed to be the default license filename. Some WebLogic
users are exempt from requiring an UDDI Server license for the
basic UDDI Server components, while they may need a license
for additional components (e.g., UDDI Server Browser).
logger.file.maxsize The value of this property specifies the maximum size of logger
output files (if output is sent to file), in Kilobytes. Once an
output file reaches maximum size, it is closed and a new log file
is created.
logger.indent.enabled Permissible values are true and false. When set to true, log
messages beginning with "+" and "-", typically TRACE level
logs, cause an increase or decrease of indentation in the output.
logger.indent.size The value of this property, an integer, specifies the size of each
indentation (how many spaces for each indent).
logger.log.file.stem The value of this property specifies a string that is prefixed to all
log file names.
logger.log.type The value of this property determines whether log messages are
sent to the screen, to a file or to both destinations. Permissible
values for this property, respectively are: LOG_TYPE_SCREEN,
LOG_TYPE_FILE, and LOG_TYPE_SCREEN_FILE.
logger.quiet The value of this property determines whether the logger itself
displays information messages or not. Permissible values are
true and false.
datasource.ldap.pool.increment When all connections in the pool are busy, the value of this
property specifies the number of new connections to create and
add to the pool.
datasource.ldap.manager.password The value of this property is the password for the above user ID,
and is used to establish connections with the LDAP directory
used for data storage.
datasource.ldap.server.root The value of this property is the root entry of the LDAP
directory used for data storage (e.g., dc=acumenat, dc=com).
Note: In a replicated LDAP environment, there are "m" LDAP masters and "n" LDAP replicas,
respectively numbered from 0 to (m-1) and from 0 to (n-1). The fifth part of the property
keys below, quoted as "i", refers to this number and differs for each LDAP server
instance defined.
datasource.file.directory The value of this property specifies the directory where UDDI
data is stored in the file system.
security.custom.ldap.manager.password The value of this property is the password for the above user
ID, and is used to establish connections with the LDAP
directory used for security.
security.custom.ldap.root The value of this property is the root entry of the LDAP
directory used for security (e.g., dc=acumenat, dc=com).
security.custom.ldap.userroot The value of this property specifies the users root entry on
the security LDAP server. For example, ou=People.
security.custom.ldap.group.root The value of this property specifies the operator entry on the
security LDAP server. For example, "cn=UDDI
Administrators, ou=Groups". This entry contains IDs of all
UDDI administrators.
security.custom.file.userdir The value of this property specifies the directory where UDDI
security information (users and groups) is stored in the file
system.
z port refers to the port number where WebLogic Server is listening for connection
requests. The default port number is 7001.
You can perform the following tasks with the UDDI Directory Explorer:
Pluggable tModel
A taxonomy is basically a tModel used as reference by a categoryBag or identifierBag. A major
distinction is that in contrast to a simple tModel, references to a taxonomy are typically checked
and validated. WebLogic Server’s UDDI Server takes advantage of this concept and extends this
capability by introducing custom taxonomies, called "pluggable tModels". Pluggable tModels
allow users (UDDI administrators) to add their own checked taxonomies to the UDDI registry,
or overwrite standard taxonomies.
To add a pluggable tModel:
1. Create an XML file conforming to the specified format described in “XML Schema for
Pluggable tModels” on page 18-24, for each tModelKey/categorization.
See “Configuring the UDDI 2.0 Server” on page 18-5 for details about the uddi.properties
file.
categories Required if
checked is set to
true.
keyName Required
keyValue Required
<simpleType name="checked">
<restriction base="NMTOKEN">
<enumeration value="true"/>
<enumeration value="false"/>
</restriction>
</simpleType>
</sequence>
<attribute name = "keyName" use = "required" type="string"/>
<attribute name = "keyValue" use = "required" type="string"/>
</complexType>
<complexType name="Taxonomy">
<sequence>
<element ref = "uddi:applicability" minOccurs = "0" maxOccurs = "1"/>
<element ref = "uddi:tModel" minOccurs = "1" maxOccurs = "1"/>
<element ref = "uddi:categories" minOccurs = "0" maxOccurs = "1"/>
</sequence>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
Interoperability
The following sections provide an overview of what it means for Web Services to be
interoperable and tips on creating Web Services that interoperate with each other as much as
possible:
Overview of Interoperability
A fundamental characteristic of Web Services is that they are interoperable. This means that a
client can invoke a Web Service regardless of the client’s hardware or software. In particular,
interoperability demands that the functionality of a Web Service application be the same across
differing:
Warning: BEA’s participation in these interoperability tests does not imply that BEA officially
certifies its Web Services implementation against the other platforms participating
in the tests.
You can also use the vendor implementations listed in these Web sites to exhaustively test your
Web service for interoperability.
For the test results, see http://webservice.bea.com/index.html#qz41; for the source code of the
tests, see http://webservice.bea.com/index.html#qz40.
Warning: BEA’s participation in these interoperability tests does not imply that BEA officially
certifies its Web Services implementation against the other platforms participating
in the tests.
To invoke a deployed WebLogic Web Service from a .NET client application, use Microsoft
Visual Studio .NET to create an application, then add a Web Reference, specifying the WSDL of
the deployed WebLogic Web Service, as described in the following example. In Microsoft Visual
Studio, adding a Web Reference is equivalent to executing the WebLogic clientgen Ant task.
Warning: The following example describes one way to invoke a WebLogic Web Service from
a .NET client application. For the most current and detailed information about using
Microsoft Visual Studio .NET to invoke WebLogic (and other) Web Services,
consult the Microsoft documentation at
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsintro7/html/vxc
onATourOfVisualStudio.asp.
1. Start and use Microsoft Visual Studio .NET to create your application as usual.
2. In the Solution Explorer in the right pane, right-click your application and chose Add Web
Reference. The Solution Explorer Browser appears.
3. Enter the WSDL of the deployed WebLogic Web Service in the Solution Explorer Browser.
As soon as the browser accepts the WSDL, the Add Reference button becomes active.
See “WebLogic Web Services Home Page and WSDL URLs” on page 6-23 for information
on getting the WSDL of a deployed WebLogic Web Service.
4. Click the Add Reference button. The WebLogic Web Service appears in the Solution
Explorer.
5. In your application component that will be used to invoke the Web Service, such as a
button, add Visual C# or Visual Basic code to invoke a particular operation of the Web
Service. Visual Studio .NET uses statement completion to help you write this code. The
following Visual C# code excerpt shows a simple example of invoking the echoString
operation of the SoapInteropBaseService Web Service:
WebReference1.SoapInteropBaseService s = new SoapInteropBaseService();
string s = s.echoString("Hi there!");
In the example, WebReference1 is the name of the Web Reference you added in preceding
steps.
Troubleshooting
z “Using the Web Service Home Page to Test Your Web Service” on page 20-2
z “Client Error When Using the WebLogic Web Service Client to Connect to a Third-Party
SSL Server” on page 20-13
z “Client Error When Invoking Operation That Returns an Abstract Type” on page 20-14
z “SSLKeyException When Trying to Invoke a Web Service Using HTTPS” on page 20-17
z “Autotype Ant Task Not Generating Serialization Classes for All Specified Java Types” on
page 20-17
z “Client Gets HTTP 401 Error When Invoking a Non-Secure Web Service” on page 20-18
z “Asynchronous Web Service Client Using JMS Transport Not Receiving Response
Messages From WebLogic Server” on page 20-19
z “Error When Trying to Log Onto the UDDI Explorer” on page 20-20
Using the Web Service Home Page to Test Your Web Service
Every Web Service deployed on WebLogic Server has a Home Page. From the Home page you
can:
z Test each operation with sample parameter values to ensure that it is working correctly.
z View the SOAP request and response messages from a successful execution of an
operation.
z protocol refers to the protocol over which the service is invoked, either http or https.
This value corresponds to the protocol attribute of the <web-service> element that
describes the Web Service in the web-services.xml file. If you used the servicegen
Ant task to assemble your Web Service, this value corresponds to the protocol attribute.
z port refers to the port number on which WebLogic Server is listening (default value is
7001).
z contextURI refers to the context root of the Web application, corresponding to the
<context-root> element in the application.xml deployment descriptor of the EAR
file. If you used the servicegen Ant task to assemble your Web Service, this value
corresponds to the contextURI attribute.
If your application.xml file does not include the <context-root> element, then the
value of contextURI is the name of the Web application archive file or exploded directory.
z serviceURI refers to the URI of the Web Service. This value corresponds to the uri
attribute of the <web-service> element in the web-services.xml file. If you used the
servicegen Ant task to assemble your Web Service, this value corresponds to the
serviceURI attribute.
For example, assume you used the following build.xml file to assemble a WebLogic Web
Service using the servicegen Ant task:
<project name="buildWebservice" default="build-ear">
<target name="build-ear">
<servicegen
destEar="myWebService.ear"
warName="myWAR.war"
contextURI="web_services">
<service
ejbJar="myEJB.jar"
targetNamespace="http://www.bea.com/examples/Trader"
serviceName="TraderService"
serviceURI="/TraderService"
generateTypes="True"
expandMethods="True" >
</service>
</servicegen>
</target>
</project>
The URL to invoke the Web Service Home Page, assuming the service is running on a host called
ariel at the default port number, is:
http://ariel:7001/web_services/TraderService
2. Enter sample values for the parameters in the table. The first two columns of the table list
the name and Java data type of the operation.
3. Click Invoke.
The SOAP request and response messages and the value returned by the operation are
displayed in a new browser window.
The main Web Service Home Page also displays an example of the Java code to invoke one of
the operations and a sample build.xml file for executing the clientgen Ant task to generate
the Web Service-specific client JAR file.
<java classname="my.app.RunService">
<sysproperty key="weblogic.webservice.verbose" value="true"/>
</java>
You can also configure WebLogic Server to print the SOAP request and response messages each
time a deployed WebLogic Web Service is invoked by specifying the
-Dweblogic.webservice.verbose=true flag when you start WebLogic Server. The SOAP
messages are printed to the command window from which you started WebLogic Server.
Note: Because of possible decrease in performance due to the extra output, BEA recommends
you set this WebLogic Server flag only during the development phase.
import weblogic.webservice.binding.BindingInfo;
...
BindingInfo info =
(BindingInfo)stub._getProperty("weblogic.webservice.bindinginfo" );
info.setVerbose( true );
port.helloWorld();
In the example, stub is the instance of the JAX-RPC Stub class for your Web Service. When the
helloWorld() operation executes, the SOAP request and response messages will be printed in
the command window from which you executed the client application.
To turn off verbose mode, invoke the setVerbose(false) method.
For more information about the weblogic.webservice.binding package, see the Javadocs at
http://e-docs.bea.com/wls/docs81/javadocs/index.html.
Note: The weblogic.webservice.binding package is a proprietary WebLogic API.
Note: It is assumed that you understand the structure of a SOAP message; if you need more
detailed information about the SOAP XML Schema, see SOAP 1.1 at
http://www.w3.org/TR/SOAP.
To post a SOAP request to a SOAP server directly:
1. Create a text file that contains an HTTP SOAP request; the request should include both the
HTTP headers and SOAP envelope. See “Composing the SOAP Request” on page 20-7 for
more information on creating this file. The following example shows an HTTP SOAP request:
POST /asmx/simple.asmx HTTP/1.1
Host: www.stock.org:7001
Content-Type: text/xml; charset=utf-8
Connection: close
SOAPAction: "http://soapinterop.org/"
3. The SOAP server sends back the raw HTTP SOAP response which you can examine for
clues about your problem.
1. Copy into a file the generated SOAP request for the invocation of a Web Service by either
using the weblogic.webservice.verbose property, as described in “Viewing SOAP
Messages” on page 20-4, or cutting and pasting the SOAP message generated from testing the
WebLogic Web Service from its Home Page, as described in “Using the Web Service Home
Page to Test Your Web Service” on page 20-2.
The following SOAP request was generated f rom an invocation of the sample
examples.webservices.complex.statelessSession Web Service , and was cut and
pasted from the Web Services Home Page:
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<env:Header>
</env:Header>
<env:Body
env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<m:sell xmlns:m="http://www.bea.com/examples/Trader">
<string xsi:type="xsd:string">sample string</string>
<intVal xsi:type="xsd:int">100</intVal>
</m:sell>
</env:Body>
</env:Envelope>
2. By default, the generated SOAP request does not include the standard XML declaration, so
add the following line, shown in bold, to the beginning of the file:
<?xml version="1.0" encoding="utf-8"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
...
3. Ensure that the XML is well-formed by opening it in an XML editor, such as XMLSpy, and
editing where necessary. XMLSpy is a product that is installed with BEA WebLogic
Platform.
4. Add the needed HTTP headers to the beginning of the file, with the appropriate Host and
POST header values, as shown in bold in the following example:
POST /filetransferAtResponse/FTService HTTP/1.1
Host: localhost:7001
z An invalid URL for the Web Service endpoint. This URL is listed in the <service>
element of the WSDL, as shown in the following excerpt:
<service name="myservice>
<port name="myport" binding="tns:mybinding">
<soap address="http://a_host:4321/service" />
</port>
</service>
In this case, ensure that the URL http://a_host:4321/service is indeed the Web
Service endpoint.
z The WSDL may contain XML data types that are not compatible with WebLogic Web
Services.
If the clientgen Ant task completes with no errors, then the WSDL is compatible and
well-formed.
z A missing import statement for the namespace associated with a data type.
z Using unsupported XML Schema data types. See “Non-Built-In Data Types Supported by
servicegen and autotype Ant Tasks” on page 6-18 and “Unsupported Features” on
page 1-11 for more information.
z The Java class does not have both get and set methods for all private fields. In this case,
the autotyping feature of the Web Services Ant tasks will ignore these private fields when
generating the serialization class and corresponding XML Schema.
If you use public fields in your Java class, you do not have to create get and set methods
for each field.
z Using unsupported Java data types. For the full list of the non-built-in Java data types that
the autotyping feature supports, see “Non-Built-In Data Types Supported by servicegen
and autotype Ant Tasks” on page 6-18
z Not being able to roundtrip generated Java/XML data types. For more information, see
“Non-Roundtripping of Generated Data Type Components” on page 6-22.
z If you are using security, the process of encrypting and decrypting the SOAP message
1. Create a servlet which simply receives the SOAP message that is used to invoke your Web
Service and returns the SOAP response message. Your servlet should do no other processing,
such as converting data between XML and Java. For details on getting the SOAP request and
response, see “Viewing SOAP Messages” on page 20-4.
2. Time how long it takes to invoke the Web Service in the standard way.
3. Time how long it takes to send the SOAP request to the servlet and for your client to receive
the response.
4. Invoking the Web Service in the standard way should take only a little longer than sending
the SOAP messages to the servlet. If this is true for your Web Service, then there is not
much more you can do to speed up the invoke because HTTP is the main factor. However,
if it takes a lot more time (such as twice as long) to invoke the Web Service than it does to
use the servlet, then you might be running into one of the other factors. See “Performance
Hints” on page 20-12 for information on how to increase the performance of your Web
Service.
Performance Hints
The following list describes performance issues you should be aware of as you program your
WebLogic Web Service.
z Use the us-ascii character set whenever you can, because it is the most efficient and fast.
For details, see “Specifying the Character Set for a WebLogic Web Service” on page 14-2.
z Use literal encoding rather than SOAP encoding by specifying that your Web Service be
document-oriented. For details, see “Choosing RPC-Oriented or Document-Oriented Web
Services” on page 4-3.
z Security, such as data encryption and digital signatures, can slow down performance
significantly, so be very judicious when adding security to a Web Service.
z Be very aware of what the handlers in your handler chains are doing, because they will
execute for every single Web Service operation invoke.
z Be sure to turn off all debugging flags you might have turned on during development.
invoke a Web Service, and later the computer on which the Web Service is running crashes, but
then another computer with a different IP address takes over for the crashed computer, a
subsequent invoke of the Web Service from the original client application will fail because the
client application continues to think that the Web Service is running on the computer with the old
cached IP address. In other words, it does not try to re-resolve the IP address with a new DNS
lookup, but rather uses the cached information from the original lookup.
To work around this problem, update your client application to set the JDK 1.4 system property
sun.net.inetaddr.ttl to the number of seconds that you want the application to cache the IP
address.
-Djava.protocol.handler.pkgs=weblogic.webservice.client
However, because of the way that the WebLogic client-side SSL was implemented, you must use
the SSLAdapter class to open a URL connection to the SSL server and get an InputStream, as
shown in the following code snippet:
SSLAdapter adapter =
SSLAdapterFactory.getDefaultFactory().getSSLAdapter();
InputStream in = adapter.openConnection(url).getInputStream();
The preceding code replaces generic code to open a connection, shown in the following example:
packageName="com.bea.example"
keepGenerated="True"
destDir="${classes}">
<classpath>
<path refid="project.classpath"/>
<pathelement path="${classes}"/>
</classpath>
</autotype>
<autotype
javaComponents="MyService"
targetNamespace="com.bea.example"
typeMappingFile="${classes}/types.xml"
packageName="com.bea.example"
keepGenerated="True"
destDir="${classes}">
<classpath>
<path refid="project.classpath"/>
<pathelement path="${classes}"/>
</classpath>
</autotype>
Note: You cannot use the servicegen Ant task on the MyService class to generate all the
serialization components in this scenario. This is because the servicegen Ant task will
not know to generate components for the Bar class, because this class does not explicitly
appear in the signatures of the methods of the MyService class.
...
<n1:Product xmlns:n1="http://mycompany.com/mywebservice"; >
<n1:ID>1234</n1:ID>
<n1:Name>MyFabProduct</n1:Name>
<n1:Description xsi:nil="true"></n1:Description>
</n1:Product>
...
This is not a bug in WebLogic Server. The difference in behavior is due to the ambiguity of the
XML Schema Part 0: Primer specification, which is very clear about what should happen when
minOccurs="1", but unclear in the case where minOccurs="0".
If you always want nillable and optional XML elements to appear in the SOAP response, even
when they have no content, then you can do one of the following:
z Explicitly set the value of the corresponding Java object to null, using a setXXX(null)
method, in the backend implementation of your Web Service operation.
z Update the WSDL of the Web Service so that all nillable="true" XML elements that
might sometimes be empty also have the minOccurs="1" attribute set. This option is not
always possible, however, so BEA recommends the preceding workaround.
packageName attribute. If you do, the autotype Ant task generates the serialization class for
only the last Java data type, rather than all the specified Java data types.
For example, assume you want to generate serialization classes for the following Java data types:
z mypackage.MyClass
z mypackage.test.MyClass
The following sample autotype Ant task specification in the build.xml file is correct and will
generate serialization classes for the two Java data types:
<autotype
destDir="/output/type_defs"
javaTypes="mypackage.MyClass,mypackage.test.MyClass"
keepGenerated="True"
overwrite="True">
<classpath refid="client.classpath"/>
</autotype>
The following autotype specification is incorrect and will generate only one serialization class
(for the mypackage.test.MyClass class):
<autotype
destDir="/output/type_defs"
javaTypes="mypackage.MyClass,mypackage.test.MyClass"
keepGenerated="True"
overwrite="True"
packageName="mypackage">
<classpath refid="client.classpath"/>
</autotype>
<servicegen
destEar="ears/myWebService.ear"
warName="myWAR.war">
<service
javaClassComponents="examples.webservices.basic.javaclass.HelloWorld"
targetNamespace="http://www.bea.com/examples/HelloWorld"
serviceName="HelloWorld"
serviceURI="/HelloWorld"
generateTypes="True"
ignoreAuthHeader="True"
expandMethods="True">
</service>
</servicegen>
Setting this attribute in the Ant task in turn sets the ignoreAuthHeader="True" attribute for the
<web-service> element that describes the Web Service in the generated web-services.xml
deployment descriptor.
Warning: Be careful using the ignoreAuthHeader attribute. If you set the value of this
attribute to True, WebLogic Server never authenticates a client application that is
attempting to invoke a Web Service, even if access control security constraints have
been defined for the EJB, Web Application, or Enterprise Application that make up
the Web Service. Or in other words, a client application that does not provide
athentication credentials is still allowed to invoke a Web Service that has security
constraints defined on it.
not know where to send this response, and thus the asynchronous client application never receives
it. This is because the Web Service asynchronous client uses temporary, rather than permanent,
JMS destinations in its implementation, and references to this temporary destination from
WebLogic Server are lost after a server restart.
:runAnt
if errorlevel 1 exit /b 1
goto end
To resolve this problem, the WebLogic Server administrator must change the permissions on the
uddi.properties file to give access to all users. The uddi.properties file, used to configure
the UDDI server, is located in the WL_HOME/server/lib directory, where WL_HOME refers to the
main WebLogic Platform installation directory.
The following sections describe how to upgrade WebLogic Web Services to 8.1:
2. Change to the staging directory that contains the components of your Version 7.0 Web
Service, such as the EJB JAR file and the build.xml file that contains the call to the
servicegen Ant task.
3. Execute the servicegen Ant task specified in the build.xml file by typing ant in the
staging directory:
prompt> ant
The Ant task generates the 8.1 Web Services EAR file in the staging directory which can
then deploy on WebLogic Server.
Warning: The wsgen Ant task was deprecated in Version 7.0 of WebLogic Server, and is not
supported in Version 8.1.
The WebLogic Web Services client API included in version 6.1 of WebLogic Server has been
removed and you cannot use it to invoke 8.1 Web Services. Version 8.1 includes a new client API,
based on the Java API for XML based RPC (JAX-RPC). You must rewrite client applications
that used the 6.1 Web Services client API to now use the JAX-RPC APIs. For details, see
Chapter 7, “Invoking Web Services from Client Applications and WebLogic Server.”
To upgrade a 6.1 WebLogic Web Service to 8.1:
1. Convert the build.xml Ant build file used to assemble 6.1 Web Services with the wsgen Ant
task to the 8.1 version that calls the servicegen Ant task.
For details see “Converting a 6.1 build.xml file to 8.1” on page 21-3.
2. Un-jar the 6.1 Web Services EAR file and extract the EJB JAR file that contains the
stateless session EJBs (for 6.1 RPC-style Web Services) or message-driven beans (for 6.1
message-style Web Services), along with any supporting class files.
3. If your 6.1 Web Service was RPC-style, see“Assembling WebLogic Web Services Using the
servicegen Ant Task” on page 6-3 for instructions on using the servicegen Ant task. If
your 6.1 Web Service was message-style, see “Assembling JMS-Implemented WebLogic
Web Services Using servicegen” on page 16-5.
4. In your client application, update the URL you use to access the Web Service or the WSDL
of the Web Service from that used in 6.1 to 8.1. For details, see “Updating the URL Used to
Access the Web Service” on page 21-5.
</target>
</project>
For detailed information on the WebLogic Web Service Ant tasks, see Appendix B, “Web
Service Ant Tasks and Command-Line Utilities.”
The following table maps the 6.1 wsgen elements and attributes to their equivalent 8.1
servicegen elements and attributes.
http://host:port/weather/statelessSession.WeatherHome/statelessSession.Weather
Home.wsdl
In 8.1, the default URL is:
[protocol]://[host]:[port]/[contextURI]/[serviceURI]?WSDL
as described in “WebLogic Web Services Home Page and WSDL URLs” on page 6-23.
For example, the URL to invoke the equivalent 8.1 Web Service after converting the 6.1
build.xml file shown in “Converting a 6.1 build.xml file to 8.1” on page 21-3 and running
wsgen is:
http://host:port/weather/weatheruri?WSDL
The following sections describe how to use WebLogic Workshop to create WebLogic Web
Services:
z “Using Meta-Data Tags When Creating EJBs and Web Services” on page 22-3
EJB or a plain Java Object to provide the business logic of the Web Service. To develop Web
Services using this model you can use the WebLogic Web Services Ant tasks (such as
servicegen). The second model is based on code annotation as defined in JSR-181, Web
Services Metadata for the Java Platform. The model used to develop Web Services in WebLogic
Workshop is a precursor to JSR-181. Whether you decide to use the JAX-RPC model or the
WebLogic Workshop model, the Web Services you develop will deploy and run on WebLogic
Server, however the SOAP implementation and dispatch model will vary depending on which
programming model you choose.
Typically, this difference in SOAP implementation is transparent and unimportant. However, due
to the differences in the programming models and the slight differences in the characteristics of
the two runtimes, you sometimes might want to use WebLogic Workshop to create applications
that run on the runtime supported by the JAX-RPC programming model. To do so, you cannot
use annotated JWS files, the standard way to create Web Services in WebLogic Workshop.
Rather, you use WebLogic Workshop to create the back-end component (stateless session EJB),
export the EJB and an Ant build script that builds the component, then add calls to the Web
Service Ant tasks to the build script to package everything up into a Web Service than runs on
the runtime supported by the JAX-RPC model. The examples in this document show how to go
through this process.
Once you have exported the EJB to a JAR file from WebLogic Workshop, follow the standard
guidelines outlined in this book to create a Web Service that runs on the runtime supported by the
JAX-RPC programming model. In particular, refer to:
z Chapter 6, “Assembling WebLogic Web Services Using Ant Tasks” for procedural
information about using the Ant tasks.
z Appendix B, “Web Service Ant Tasks and Command-Line Utilities” for reference
information about the Ant tasks.
z “Deploying and Testing WebLogic Web Services” on page 6-23 for information about
deploying and testing the Web Service.
EJBGen
When you use WebLogic Workshop to create a stateless session EJB back-end component, you
are actually using a plug-in called EJBGen, an EJB 2.0 code generator. When you write the code
for your EJB in Workshop, you use special @ejbgen Javadoc tags to describe what the EJB looks
like, and then, when you build your EJB, Workshop calls the EJBGen plug-in to generate the
remote and home interface classes and the deployment descriptor files.
EJBGen can also be executed as a command-line utility, which means that the same *.ejb file
you use in Workshop can also be processed outside of Workshop. (The only difference is that
you must change the extension from *.ejb to *.java.) Use the java command, as shown in the
following example:
java weblogic.tools.ejbgen.EJBGen myEJB.java
One way of using the command-line version of EJBGen is to add it to the Ant build script that
calls the Ant tasks, such as servicegen, to build your WebLogic Web Service so that you can
re-generate your EJB without having to use Workshop.
Because you can use EJBGen both within Workhop and as a command-line utility, it is assumed
in the examples in this document that you might use either flavor, even if the example describes
one particular flavor.
For details about using the command-line EJBGen tool, see EJBGen Reference at
http://e-docs.bea.com/wls/docs81/ejb/EJBGen_reference.html. For details about the EJBGen
Workshop plug-in, see the Developing Enterprise JavaBeans topic in the left frame of the
WebLogic Workshop Help at
http://e-docs.bea.com/wls/docs81/../../workshop/docs81/doc/en/core/index.html.
z those used by the WebLogic Web Service source2wsdd Ant task, specified with the @wlws
Javadoc tag.
You use meta-data Javadoc tags in a Java source file to specify in more detail what an EJB, and
the Web Service that exposes the EJB, look like. Then you use either EJBGen or the
source2wsdd Ant task (or both) to generate the additional components. In particular, EJBGen
generates the EJB deployment descriptors and the EJB Home and Remote interfaces; the
source2wsdd Ant task generates the Web Services deployment descriptor file.
For reference information about the EJBGen tags, see EJBGen Reference at
http://e-docs.bea.com/wls/docs81/ejb/EJBGen_reference.html. For information about the
source2wsdd tags, see Appendix C, “source2wsdd Tag Reference.”
2. If one does not already exist, create an application that will contain the stateless session
EJB.
It is assumed in the procedure that the application is named myApp.
3. If one does not already exist, create an EJB project under your Workshop application.
It is assumed that the project is named myEJBs.
6. Click Source View and update PurchaseOrderBean.ejb, replacing all the code after the
package myPackage statement with the following code:
import javax.ejb.*;
import weblogic.ejb.*;
/**
* @ejbgen:session
* ejb-name = "PurchaseOrder"
*
* @ejbgen:jndi-name
* remote = "ejb.PurchaseOrderRemoteHome"
*
* @ejbgen:file-generation
* remote-class = "true"
* remote-class-name = "PurchaseOrder"
* remote-home = "true"
* remote-home-name = "PurchaseOrderHome"
* local-class = "false"
* local-class-name = "PurchaseOrderLocal"
* local-home = "false"
* local-home-name = "PurchaseOrderLocalHome"
*/
public class PurchaseOrderBean
extends GenericSessionBean
implements SessionBean
{
public void ejbCreate() {
// Your code here
}
/**
* @ejbgen:remote-method
*/
public long submitPO(String PoText)
{
return System.currentTimeMillis();
}
/**
* @ejbgen:remote-method
*/
public int getStatus(long orderNo)
{
return 0;
}
}
7. Ensure that the EJB builds correctly by right-clicking on the myEJBs project in the
application pane and selecting Build myEJBs.
8. Export the Ant build file that builds the PurchaseOrder EJB outside of Workshop by
clicking Tools->Application Properties..., choosing Build in the left pane, and clicking the
Export to Ant File button.
9. Open a command window change to the project directory of your Workshop application.
10. Edit the exported_build.xml file, adding the following elements to invoke the
servicegen Ant task on the PurchaseOrder EJB you created in Workshop:
classname="weblogic.ant.taskdefs.webservices.servicegen.ServiceGenTask"
classpath="${server.classpath}" />
– A target for the servicegen Ant task:
<target name="servicegen">
<delete file="${output.file}" />
<servicegen
destEar="${output.file}"
>
<service
ejbJar="myEJBs.jar"
serviceName="PurchaseOrderService"
serviceURI="/PurchaseOrderService"
targetNamespace="http://example.com/PurchaseOrderService"
/>
</servicegen>
</target>
11. Set your environment by executing the setEnv.cmd command, located in your domain
directory. The default location of WebLogic Server domains is
BEA_HOME\user_projects\domains\domainName, where BEA_HOME is the top-level
installation directory of the BEA products and domainName is the name of your domain.
12. Execute the build and servicegen Ant tasks of the exported_build.xml file:
prompt> ant -f exported_build.xml build servicegen
The servicegen target of the Ant task updates the application, exposing the
PurchaseOrder EJB as a WebLogic Web Service.
13. Deploy the application as usual. For details, see “Deploying and Testing WebLogic Web
Services” on page 6-23.
Assumptions
This main point of this example is to show how to use WebLogic Workshop to create an EJB and
SOAP message handler that together will be exposed as a Web Service, and then how to package
it all together into a deployable EAR file than runs on the runtime supported by the JAX-RPC
programming model. For this reason, it is assumed that you have already:
z Within the PurchaseOrderService EJB project, created a folder called po that contains
the EJB that performs all the business logic (PurchasingManagerBean) as well as the
various objects used by the PurchasingManagerBean EJB, such as Item,
PurchaseOrder, and PurchaseOrderFactory.
See “Source Code for Supporting Java Objects” on page 22-16 for sample source code for
these objects.
The Example
Note: The following procedure does not always describe the exact steps you must perform in
the IDE to create the various projects and objects. For this kind of detailed information,
see the Developing Enterprise JavaBeans topic in the left frame of the WebLogic
Workshop Help at
http://e-docs.bea.com/wls/docs81/../../workshop/docs81/doc/en/core/index.html.
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
import javax.ejb.CreateException;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import po.PurchasingManagerLocal;
import po.PurchasingManagerLocalHome;
/**
* This is the web service facade. It defines the web service
* operations and contains any web service-specific
/**
* This operation return a PurchaseOrder that is retrieved from
* the PurchasingManager
* @ejbgen:local-method
* @wlws:operation handler-chain = "PurchaseOrderServiceHandlerChain"
*/
public po.PurchaseOrder getPurchaseOrder(String poNumber) {
return pm.getPO(poNumber);
}
public void ejbCreate() throws CreateException {
try {
InitialContext ctx = new InitialContext();
PurchasingManagerLocalHome pmhome = (PurchasingManagerLocalHome)
ctx.lookup("java:/comp/env/ejb/PurchasingManagerEJB");
pm = pmhome.create();
} catch (NamingException ne) {
throw new CreateException("Could not locate PurchasingManager EJB");
}
}
package service;
import javax.xml.rpc.handler.Handler;
import javax.xml.rpc.handler.MessageContext;
import javax.xml.rpc.handler.HandlerInfo;
import javax.xml.rpc.handler.soap.SOAPMessageContext;
import javax.xml.namespace.QName;
import javax.xml.soap.*;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Map;
import java.util.Iterator;
import java.util.Date;
/**
* Represents a JAX-RPC handler that intercepts an incoming SOAP message,
* extracts an optional header called"My-Username" and logs a message to a
* log file.
*/
out.flush();
return true;
}
Iterator i = headers.getChildElements(fact.createName(HEADER_NAME));
while (i.hasNext()) {
SOAPElement elt = (SOAPElement) i.next();
if (headerName.equals(elt.getElementName().getLocalName())) {
return elt.getValue();
}
}
return null;
}
}
This XML file will contain a description of the SOAP message handler and handler chain
used by the Web Service. The file will late be used by the source2wsdd Ant task when
generating the Web Service deployment descriptor.
8. In the middle pane, replace the Workshop-generated <root></root> XML elements with
the following XML:
<handler-chains>
<handler-chain name="PurchaseOrderServiceHandlerChain">
<handler class-name="service.PurchaseOrderServiceHandler">
<init-params>
<init-param name="logFile" value="./posvc.log" />
</init-params>
</handler>
</handler-chain>
</handler-chains>
9. Click Tools->Application Properties... and choose Build in the left pane. Make a note of the
project directory, listed under the EAR heading in the right pane.
10. Open a command window and change to the project directory of your Workshop
application.
11. Set your environment by executing the setEnv.cmd command, located in your domain
directory. The default location of WebLogic Server domains is
BEA_HOME\user_projects\domains\domainName, where BEA_HOME is the top-level
installation directory of the BEA products and domainName is the name of your domain
12. Ensure you can rebuild your EJB project from the command line by exeucting the
WL_HOME\workshop\wlwBuild.cmd, where WL_HOME refers to the main WebLogic
Platform directory, such as c:\beahome\weblogic81. Use the -project option to pass it
the name of the EJB project, as shown in the following example:
prompt> c:\beahome\weblogic81\workshop\wlwBuild.cmd -project
PurchaseOrderService
You can add this line to your automated shell scripts that iteratively build the application.
13. In the Workshop project directory, create an Ant build.xml file that includes calls to the
autotype and source2wsdd WebLogic Web Service ant tasks.
These Ant tasks take the compiled EJB and SOAP message handler class and create the
needed Web Services components, such as the deployment descriptor and data type
components. For an example of this file, see “Sample build.xml File” on page 22-13.
prompt> ant
If you use a build.xml file similar to the sample, the Ant task create a deployable EAR file
called PurchaseOrderService.ear in a directory called output that is parallel to the
Workshop project directory.
15. Deploy the PurchaseOrderService.ear file as usual. For details, see “Deploying and
Testing WebLogic Web Services” on page 6-23.
<!-- base url of the server and administrator user, password -->
<property name="server_url" value="http://localhost:7001"/>
<property name="admin_user" value="weblogic"/>
<property name="admin_passwd" value="gumby1234"/>
<!-- the dir into which the output of compilers and tools is directed -->
<property name="output_dir" value="../output"/>
<!-- the name of service (used in constructing war file name, WSDL, etc.) -->
<property name="service_name" value="PurchaseOrderService"/>
<!-- the Java package in which the service class is located -->
<property name="service_package" value="service"/>
<!-- name of the Workshop EJB project containing the web service EJBs -->
<property name="service_ejb_project" value="PurchaseOrderService" />
<!-- the dir that contains the exploded ear file containing the web service
-->
<property name="output_ear" value="${output_dir}/${service_name}-ear"/>
<path id="build.classpath">
<pathelement path="${java.class.path}"/>
<pathelement location="${platformhome}/server/lib/webservices.jar"/>
<pathelement location="${output_ear}"/>
<pathelement location="${output_ear}/APP-INF/classes"/>
<pathelement location="${service_ejb_project}.jar"/>
</path>
<target name="build"
depends="clean, setup, webservice.build, webservice.client, build.finish"/>
<target name="clean" description="delete generated stuff">
<delete dir="${output_dir}"/>
</target>
<!-- build the web service from the web service EJB JAR -->
<target name="webservice.build">
<!-- generate XML types from the Java value types in the service -->
<autotype javaComponents="${service_package}.${service_name}Local"
typeMappingFile="${output_ear}/APP-INF/classes/types.xml"
destDir="${output_ear}/APP-INF/classes"
packageName="${service_package}"
classpathref="build.classpath"/>
<!-- build the service from the EJB and autotyper types -->
<source2wsdd
javaSource="${service_ejb_project}/${service_package}/${service_name}Bean.ejb"
ddFile="${output_dir}/${service_name}-war/WEB-INF/web-services.xml"
typesInfo="${output_ear}/APP-INF/classes/types.xml"
handlerInfo="${service_ejb_project}/${service_package}/handler-chain.xml"
serviceURI="/${service_name}"
wsdlFile="${output_dir}/${service_name}-war/${service_name}.wsdl"
ejblink="${service_ejb_project}.jar#${service_name}EJB"
classpathref="build.classpath">
</source2wsdd>
<application>
<display-name> ${service_name}-Service </display-name>
<module>
<ejb>
${service_ejb_project}.jar
</ejb>
</module>
<module>
<web>
<web-uri> ${service_name}.war </web-uri>
<context-root> ${service_name} </context-root>
</web>
</module>
</application>
]]>
</echo>
<jar destFile="${output_dir}/${service_name}.ear"
baseDir="${output_ear}"/>
</target>
<target name="webservice.client">
<!-- generate JAX-RPC client interfaces, stubs into the client jar -->
<clientgen
description="create a web service client from the ear"
clientJar="${output_dir}/${service_name}-client"
wsdl="${output_dir}/${service_name}-war/${service_name}.wsdl"
typeMappingFile="${output_ear}/APP-INF/classes/types.xml"
packageName="${service_package}.client"
usePortNameAsMethodName="true"
keepgenerated="true"
classpathref="build.classpath">
</clientgen>
<!-- compile the client app into the client jar -->
<javac srcdir="."
includes="client/*.java"
destdir="${output_dir}/${service_name}-client"
classpathref="build.classpath">
</javac>
<!-- package the client jar; executing the jar runs the test app -->
<jar
destFile="${output_dir}/${service_name}-client.jar"
baseDir="${output_dir}/${service_name}-client"/>
</target>
<delete dir="${output_dir}/${service_name}-war"/>
<delete dir="${output_ear}"/>
</target>
</classpath>
<arg line="${server_url}/${service_name}/${service_name}?WSDL"/>
<jvmarg line="-Dweblogic.webservice.verbose=true"/>
</java>
</target>
</project>
z Item.java
z PurchaseOrder.java
z PurchasingManagerBean.java
z PurchaseOrderFactory.java
Item.java
package po;
/**
* Represents a single item on a purchase order.
*/
public class Item {
private String catNumber;
private String description;
private int quantity;
public Item() {
}
PurchaseOrder.java
package po;
import po.Item;
/**
* Date: Oct 15, 2003
* Time: 3:29:23 PM
*/
public class PurchaseOrder {
private String poNumber;
private Item[] items;
private String custName;
private String custAddress;
public PurchaseOrder() {
}
PurchasingManagerBean.java
package po;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
/**
* This is a session facade EJB that is the entry point to the business
* logic ofthe application.
*
* @ejbgen:session
* ejb-name = "PurchasingManagerEJB"
* @ejbgen:jndi-name
* local = "PurchasingManager"
*/
public class PurchasingManagerBean implements SessionBean {
/**
* @ejbgen:local-method
*/
public PurchaseOrder getPO(String poNumber) {
return PurchaseOrderFactory.createPO(); // always return same thing
}
/**
* @ejbgen:local-method
*/
public int getStatus(String poNumber) {
return 1;
}
PurchaseOrderFactory.java
package po;
import java.util.ArrayList;
import java.util.List;
/**
* A Factory to create PurchaseOrders. This just creates the same
* dummy PO each time.
*/
public class PurchaseOrderFactory {
/**
* Constructs a PurchaseOrder object
*/
public static PurchaseOrder createPO() {
// Add customer
po.setCustName("Mary Mary Quite Contrary");
po.setCustAddress("123 Main Street, Hogsmeade");
return po;
}
}
The following sections describe the web-services.xml file using different formats:
Overview of web-services.xml
The web-services.xml deployment descriptor file contains information that describes one or
more WebLogic Web Services. This information includes details about the back-end components
that implement the operations of a Web Service, the non-built-in data types used as parameters
and return values, the SOAP message handlers that intercept SOAP messages, and so on. As is
true for all deployment descriptors, web-services.xml is an XML file.
Graphical Representation
The following graphic describes the web-services.xml element hierarchy.
handler-chains
handler-chain
handler
init-params
init-param
web-service
components
stateless-ejb
ejb-link
jndi-name
jms-send-destination
jndi-name
jms-receive-queue
jndi-name
java-class
types
XML Schema
type-mapping
type-mapping-entry
(Continued)
(Continued)
operations
operation
params
param
return-param
fault
reliable-delivery
security
user
name
password
encryptionKey
name
password
signatureKey
name
password
(Continued)
(Continued)
spec:SecuritySpec
spec:UsernameTokenSpec
spec:BinarySecurityTokenSpec
spec:SignatureSpec
spec:ElementIdentifier
spec:EncryptionSpec
spec:ElementIdentifier
timestamp
clocks-synchronized
clock-precision
require-signature-timestamp
enforce-precision
inbound-expiry
generate-signature-timestamp
outbound-expiry
Element Reference
The following sections, arranged alphabetically, describe each element in the
web-services.xml file.
See “Examining Different Types of web-services.xml Files” on page E-9 for sample Web
Services deployment descriptor files for a variety of different types of WebLogic Web Services.
clock-precision
Describes the accuracy of synchronization between the clock of a client application invoking a
WebLogic Web Service and WebLogic Server’s clock. WebLogic Server uses this value to
account for a reasonable level of clock skew between two clocks.
The value is expressed in milliseconds. This means, for example, that if the clocks are accurate
within a one minute of each other, the value of this element is 60000.
If the value of this element is greater than the expiration period of an incoming SOAP request,
WebLogic Server rejects the request because it cannot accurately enforce the expiration. For
example, if the clock precision value is 60000 milliseconds, and WebLogic Server receives a
SOAP request that expires 30000 milliseconds after its creation time, it is possible that the
message has lived for longer than 30000 seconds, due to the 60000 millisecond clock precision
discrepancy, so WebLogic Server has no option but to reject the message. You can relax this strict
enforcement by setting the <enforce-precision> element to false. For details, see
“enforce-precision” on page A-7.
This element must be specified in conjunction with <clocks-synchronized>.
The default value for this element is 60000.
This element does not have any attributes. This element is a child element of <timestamp>.
clocks-synchronized
Specifies whether WebLogic Server assumes that the clocks of the client application invoking a
WebLogic Web Service and WebLogic Server are synchronized when dealing with timestamps
in SOAP messages.
If the value of this element is true, WebLogic Server enforces, if it exists, the time expiration of
the SOAP request from a client application that is invoking a WebLogic Web Service. This means
that if the time stamp has expired, WebLogic Server does not invoke the Web Service operation.
If the value of this element is false, WebLogic Server rejects all SOAP requests that contain a
time expiration.
Valid values for this element are true and false. The default value is false.
This element does not have any attributes. This element is a child element of <timestamp>.
components
Defines the back-end components that implement the Web Service.
A WebLogic Web Service can be implemented using one or more of the following components:
z JMS destination
z A Java class
This element has no attributes.
ejb-link
Identifies which EJB in an EJB JAR file is used to implement the stateless session EJB back-end
component.
encryptionKey
Specifies the name and password of a key pair and certificate used when encrypting elements of
the SOAP message. Specify the name using the <name> subelement; specify the password with
the <password> subelement.
Note: Create the key and certificate pair in the WebLogic Server keystore with the
Administration Console. For details, see Storing Private Keys, Digital Certificates, and
Trusted CAs.
enforce-precision
Specifies whether to enforce the clock precision time period.
If this element is set to false, WebLogic Server does not reject SOAP requests whose time
expiration period is smaller than the clock precision time, specified with the
<clock-precision> element. By default, WebLogic Server rejects these SOAP requests
because it cannot accurately determine whether the message has expired, due to the discrepancy
in clock precision between the client application and WebLogic Server.
Valid values for this element are true and false. The default value is true.
This element does not have any attributes. This element is a child element of <timestamp>.
fault
Specifies the SOAP fault that should be thrown if there is an error invoking this operation.
This element is not required.
class-name Fully qualified Java class that implements the SOAP fault. String Yes
generate-signature-timestamp
Specifies whether WebLogic Server includes a timestamp in the SOAP response to a client
application that has invoked a WebLogic Web Service operation.
Valid values for this element are true and false. The default value is true.
This element does not have any attributes. This element is a child element of <timestamp>.
handler
Describes a SOAP message handler in a handler chain. A single handler chain can consist of one
or more handlers.
If the Java class that implements the handler expects initialization parameters, specify them using
the optional <init-params> child element of the <handler> element.
class-name Fully qualified Java class that implements the SOAP String Yes
message handler.
handler-chain
Lists the SOAP message handlers that make up a particular handler chain. A single WebLogic
Web Service can define zero or more handler chains.
The order in which the handlers (defined by the <handler> child element) are listed is important.
By default, the handleRequest() methods of the handlers execute in the order that they are
listed as child elements of the <handler-chain> element. The handleResponse() methods of
the handlers execute in the reverse order that they are listed.
handler-chains
Contains a list of <handler-chain> elements that describe the SOAP message handler chains
used in the Web Service described by this web-services.xml file. A single WebLogic Web
Service can define zero or more handler chains.
This element does not have any attributes.
inbound-expiry
Specifies, in milliseconds, WebLogic Server’s expiration period for a SOAP request from a client
application invoking a Web Service. WebLogic Server adds the value of this element to the
creation date in the time stamp of the SOAP request, accounts for clock precision, then compares
the result to the current time. If the result is greater than the current time, WebLogic Server rejects
the invoke.
In addition to its own expiration period for SOAP requests, WebLogic Server also honors
expirations in the SOAP request message itself, specified by the client application.
To specify no expiration, set this element to -1.
The default value of this element is -1.
If you set this element to a value, be sure you also specify that the clocks between WebLogic
Server and client applications are synchronized by setting the <clocks-synchronized>
element to true.
init-param
Specifies a name-value pair that represents one of the initialization parameters of a handler.
init-params
Contains the list of initialization parameters that are passed to the Java class that implements a
handler.
This element does not have any attributes.
java-class
Describes the Java class component that implements one or more operations of a Web Service.
class-name Fully qualified name of the Java class that implements this String Yes
component.
jms-receive-queue
Specifies that one of the operations in the Web Service is mapped to a JMS queue. Use this
element to describe a Web Service operation that receives data from a JMS queue.
Typically, a message producer puts a message on the specified JMS queue, and a client invoking
this Web Service operation polls and receives the message.
connection-factory JNDI name of the JMS Connection factory that String Yes
WebLogic Server uses to create a JMS
Connection object.
jms-send-destination
Specifies that one of the operations in the Web Service is mapped to a JMS queue. Use this
element to describe a Web Service operation that sends data to the JMS queue.
Typically, a message consumer (such as a message-driven bean) consumes the message after it is
sent to the JMS destination.
connection-factory JNDI name of the JMS Connection factory that String Yes
WebLogic Server uses to create a JMS
Connection object.
jndi-name
Specifies a reference to an object bound into a JNDI tree. The reference can be to a stateless
session EJB or to a JMS destination.
path Path name to the object from the JNDI context root. String Yes
name
Depending on the parent element, the <name> element specifies:
z The username used in the username token in the SOAP response message. (Parent
element is <user>.)
z The name of the key pair and certificate, stored in WebLogic Server’s keystore, used to
encrypt part of the SOAP message. (Parent element is <encryptionKey>.)
z The name of the key pair and certificate, stored in WebLogic Server’s keystore, used to
digitally sign part of the SOAP message. (Parent element is <signatureKey>.)
This element does not have any attributes.
operation
Configures a single operation of a Web Service. Depending on the value and combination of
attributes for this element, you can configure the following types of operations:
z An invoke of a method of a stateless session EJB or Java class. Specify this type of
operation by setting the component attribute to the name of the stateless session EJB or
Java class component and the method attribute to the name of the method.
z An invoke of a JMS back-end component. Specify this type of operation by setting the
component attribute to the name of the JMS component.
z The sequential invoke of the SOAP message handlers on a handler chain together with the
invoke of a back-end component. Specify this type of operation by setting the component
attribute to the name of the component, and the handler-chain attribute to the name of
the handler chain you want to invoke.
z The sequential invoke of the SOAP message handlers on a handler chain, but with no
back-end component. Specify this type of operation by just setting the handler-chain
attribute to the name of the handler chain you want to invoke and not setting the
component and method attributes.
Use the <params> child element to explicitly specify the parameters and return values of the
operation.
in-security-spec Specifies the name of the security specification that String No.
describes the message-level security of the client
application’s SOAP request when it invokes the
operation. The security specification describes what
part of the SOAP request should be encrypted or
digitally signed.
If you do not specify this attribute, the default security
specification, if it exists, is applied to the SOAP
request. If there is no default security specification,
then no message-level security is applied to the SOAP
request.
The value of this attribute corresponds to the Id
attribute of the appropriate
<spec:SecuritySpec> element.
method Name of the method of the EJB or Java class that String No
implements the operation if you specify with the
component attribute that the operation is
implemented with a stateless session EJB or Java
class.
You can specify all the methods with the asterisk (*)
character.
If your EJB or Java class does not overload the
method, you need only specify the name of the
method, such as:
method="sell"
If, however, the EJB or Java class overloads the
method, then specify the full signature, such as:
method="sell(int)"
out-security-spec Specifies the name of the security specification that String No.
describes the message-level security of WebLogic
Server’s SOAP response after a client application has
invoked the operation. The security specification
describes what part of the SOAP response should be
encrypted or digitally signed.
If you do not specify this attribute, the default security
specification, if it exists, is applied to the SOAP
response. If there is no default security specification,
then no message-level security is applied to the SOAP
response.
The value of this attribute corresponds to the Id
attribute of the appropriate
<spec:SecuritySpec> element.
portTypeName Port type in the WSDL file to which this operation String No
belongs. You can include this operation in multiple
port types by specifying a comma-separated list of
port types. When the WSDL for this Web Service is
generated, a separate <portType> element is
created for each specified port type.
The default value is the value of the portType
attribute of the <web-service> element.
operations
The <operations> element groups together the explicitly declared operations of this Web
Service.
This element does not have any attributes.
outbound-expiry
Specifies, in milliseconds, the expiration period that WebLogic Server adds to the timestamp
header of the SOAP response.
To specify no expiration, set this element to -1.
The default value of this element is -1.
param
The <param> element specifies a single parameter of an operation.
You must list the parameters in the same order in which they are defined in the method that
implements the operation. The number of <param> elements must match the number of
parameters of the method.
class-name Java class name of the Java representation of the NMTOKEN Maybe. See
data type of the parameter. the
If you do not specify this attribute, WebLogic description
Server introspects the back-end component that of the
implements the operation for the Java class of the attribute.
parameter.
You are required to specify this attribute only if you
want the mapping between the XML and Java
representations of the parameter to be different than
the default. For example, xsd:int maps to the
Java primitive int type by default, so use this
attribute to map it to java.lang.Integer
instead.
location Part of the request SOAP message (either the String No.
header, the body, or the attachment) that contains
the value of the input parameter.
Valid values for this attribute are Body, Header, or
attachment. The default value is Body.
If you specify Body, the value of the parameter is
extracted from the SOAP Body, according to
regular SOAP rules for RPC operation invocation.
If you specify Header, the value is extracted from
a SOAP Header element whose name is the value of
the type attribute.
If you specify attachment, the value of the
parameter is extracted from the SOAP Attachment
rather than the SOAP envelope. As specified by the
JAX-RPC specification, only the following Java
data types can be extracted from the SOAP
Attachment:
• java.awt.Image
• java.lang.String
• javax.mail.internet.MimeMultiport
• javax.xml.transform.Source
• javax.activation.DataHandler
name Name of the input parameter that will be used in the String No.
generated WSDL.
The default value is the name of the parameter in the
method’s signature.
style Style of the input parameter, either a standard input String Yes.
parameter, an out parameter used as a return value,
or an in-out parameter for both inputting and
outputting values.
Valid values for this attribute are in, out, and
in-out.
If you specify a parameter as out or in-out, the
Java class of the parameter in the back-end
component’s method must implement the
javax.xml.rpc.holders.Holder interface.
params
The <params> element groups together the explicitly declared parameters and return values of
an operation.
You do not have to explicitly list the parameters or return values of an operation. If an
<operation> element does not have a <params> child element, WebLogic Server introspects
the back-end component that implements the operation to determine its parameters and return
values. When generating the WSDL file of the Web Service, WebLogic Server uses the names of
the corresponding method’s parameters and return value.
You explicitly list an operation’s parameters and return values when you want:
z The name of the parameters and return values in the generated WSDL to be different from
those of the method that implements the operation.
Use the <return-param> child element to specify the return value of the operation.
The <params> element does not have any attributes.
password
Depending on the parent element, the <password> element specifies:
z The password used in the username token in the SOAP response message. (Parent
element is <user>.)
z The password of the key pair and certificate, stored in WebLogic Server’s keystore, used to
encrypt part of the SOAP message. (Parent element is <encryptionKey>.)
z The password of the key pair and certificate, stored in WebLogic Server’s keystore, used to
digitally sign part of the SOAP message. (Parent element is <signatureKey>.)
This element does not have any attributes.
reliable-delivery
The <reliable-delivery> element specifies that the operation can be invoked asynchronously
using reliable SOAP messaging. This means that the application that invokes the Web Service
has a guaranteed that the SOAP message was delivered to the Web Service operation, or it
receives an explicit exception saying that the delivery did not happen.
You can specify only one <reliable-delivery> element for a given operation.
persist-duration The default minimum number of seconds that the Integer No.
Web Service should persist the history of a reliable
SOAP message (received from the sender that
invoked the Web Service) in its storage.
The Web Service, after recovering from a
WebLogic Server crash, does not dispatch persisted
messages that have expired.
The value of this attribute, if you set it, should be
greater than the product of the retry interval and the
retry count of the sender.
The default value of this attribute is 60,000.
require-signature-timestamp
Specifies whether WebLogic Server requires that the SOAP request from a client application that
invokes a WebLogic Server include a timestamp. If this element is set to true, and a SOAP
request does not contain a timestamp, WebLogic Server rejects the request.
Valid values for this element are true and false. The default value is true.
This element does not have any attributes. This element is a child element of <timestamp>.
return-param
The <return-param> element specifies the return value of the Web Service operation.
You can specify only one <return-param> element for a given operation.
class-name Java class name of the Java representation of the NMTOKEN Maybe. See
data type of the return parameter. the
If you do not specify this attribute, WebLogic description
Server introspects the back-end component that of the
implements the operation for the Java class of the attribute.
return parameter.
You are required to specify this attribute if:
• The back-end component that implements the
operation is <jms-receive-queue>.
• The mapping between the XML and Java
representations of the return parameter is
ambiguous, such as mapping xsd:int to
either the int Java primitive type or
java.lang.Integer.
location Part of the response SOAP message (either the String No.
header, the body, or the attachment) that contains
the value of the return parameter.
Valid values for this attribute are Body, Header, or
attachment. The default value is Body.
If you specify Body, the value of the return
parameter is added to the SOAP Body. If you
specify Header, the value is added as a SOAP
Header element whose name is the value of the
type attribute.
If you specify attachment, the value of the
parameter is added to the SOAP Attachment rather
than the SOAP envelope. As specified by the
JAX-RPC specification, only the following Java
data types can be added to the SOAP Attachment:
• java.awt.Image
• java.lang.String
• javax.mail.internet.MimeMultiport
• javax.xml.transform.Source
• javax.activation.DataHandler
name Name of the return parameter that will be used in the String No.
generated WSDL file.
If you do not specify this attribute, the return
parameter is called result.
type XML Schema data type of the return parameter. NMTOKEN Yes.
security
Element that contains all the security configuration information about a particular Web Service.
This information includes:
z The username and password used in the SOAP response username token (<user> child
element).
z The name of the key pairs in WebLogic Server’s keystore used for data encryption and
digital signatures (<encryptionKey> and <signatureKey> child elements).
z What parts of the SOAP message should be encrypted and digitally signed
(<spec:SecuritySpec> child element).
signatureKey
Specifies the name and password of a key pair and certificate used when digitally signing
elements of the SOAP message. Specify the name using the <name> subelement; specify the
password with the <password> subelement.
Note: Create the key pair and certificate in the WebLogic Server keystore with the
Administration Console. For details, see Storing Private Keys, Digital Certificates, and
Trusted CAs.
spec:BinarySecurityTokenSpec
Specifies the (binary) non-XML-based security tokens included in the SOAP messages.
Note: You must include the following namespace declaration with this element:
xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/07/secext"
and the value of each attribute of this element should be qualified with the wsse
namespace.
EncodingType Specifies the encoding format of the binary data. String Yes
Only one valid value: wsse:Base64Binary
ValueType Specifies the value type and space of the encoded binary String Yes
data.
Only one valid value: wsse:X509v3 (for X.509
certificates)
spec:ElementIdentifier
Identifies a particular element in the SOAP message (either the header or the body) that you want
to digitally sign or encrypt. You uniquely identify an element in the SOAP message by its local
name and its namespace.
Specify this element as the child of either <spec:SignatureSpec> or
<spec:EncryptionSpec>.
LocalPart The local name of the element. Do not specify the String Yes.
namespace with this attribute.
spec:EncryptionSpec
Specifies the elements in the SOAP message that are encrypted and how they are encrypted.
You can specify that the entire SOAP body be encrypted by setting the attribute
EncryptBody="True". You can also use the <spec:ElementIdentifier> child element to
specify particular elements of the SOAP message that are to be encrypted.
Warning: Do not specify both EncryptBody="True" and one or more elements with the
<spec:ElementIdentifier> child element, but rather, use just one way to specify
the elements of the SOAP message that should be encrypted.
Use the EncryptionMethod attribute to specify how to encrypt the SOAP message elements.
EncryptBody Specifies whether to encrypt the entire SOAP body. String Yes.
Note: Do not specify both EncryptBody="True" and one
or more elements with the
<spec:ElementIdentifier> child element, but
rather, use just one way to specify the elements of the
SOAP message that should be encrypted.
Valid values are True and False.
EncryptionMethod Specifies the algorithm used to encrypt the specified elements of String No.
the SOAP message.
Valid values are:
http://www.w3.org/2001/04/xmlenc#tripledes-c
bc
http://www.w3.org/2001/04/xmlenc#kw-triplede
s
Default value is
http://www.w3.org/2001/04/xmlenc#tripledes-c
bc.
KeyWrappingMethod Specifies the algorithm used to encrypt the message encryption String No.
key.
Valid values are:
http://www.w3.org/2001/04/xmlenc#rsa-1_5 (to
specify the REQUIRED RSA-v1.5 algorithm)
http://www.w3.org/2001/04/xmlenc#rsa-oaep-mg
f1p (to specify the REQUIRED RSA-OAEP algorithm)
When using this attribute, set the value to the URI, such as:
KeyWrappingMethod="http://www.w3.org/2001/04
/xmlenc#rsa-oaep-mgf1p"
Default value is
http://www.w3.org/2001/04/xmlenc#rsa-1_5.
spec:SecuritySpec
Specifies the set of security-related information associated with this Web Service.
The information in this element can include:
z A security token that specifies the username and password of the client invoking the Web
Service. (<spec:UsernameTokenSpec> child element)
z A binary security token that specify non-XML-based security tokens, such as X.509
certificates. (<spec:BinarySecurityTokenSpec> child element)
z A specification for the parts of the SOAP message that are digitally signed.
(<spec:SignatureSpec> child element)
and all child elements of the <spec:SecuritySpec> element must be qualified with the
spec namespace.
spec:SignatureSpec
Specifies the elements in the SOAP message that are digitally signed and how they are signed.
Digital signatures are a way to determine whether a message was altered in transit and to verify
that a message was really sent by the possessor of a particular security token.
You can specify that the entire SOAP body be digitally signed by setting the attribute
SignBody="True". Use the <spec:ElementIdentifier> child element to specify additional
particular elements of the SOAP message that are to be signed.
Use the CanonicalizationMethod and SignatureMethod attributes to specify how to
digitally sign the SOAP message elements.
CanonicalizationMethod Specifies the algorithm used to canonicalize the SOAP String Yes.
message elements being signed.
Only one valid value:
http://www.w3.org/2001/10/xml-exc-cl4n#
SignatureMethod Specifies the cryptographic algorithm used to compute the String Yes.
signature.
SignBody Specifies whether to digitally sign the entire SOAP body, in String Yes.
addition to the any specific elements identified with the
optional <spec:ElementIdentifier> child elements.
Valid values are True and False.
spec:UsernameTokenSpec
Specifies that the SOAP response after an invoke of this Web Service must include a username
token.
WebLogic Server uses the information in the <user> child element of the <security> element
when creating the security information in a SOAP response message.
Note: You must include the following namespace declaration with this element:
xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/07/secext"
and the value of each attribute of this element should be qualified with the wsse
namespace.
PasswordType Specifies how to include the password in the SOAP String Yes.
message.
Only valid value is wsse:PasswordText (actual
password for the username.)
stateless-ejb
Describes the stateless session EJB component that implements one or more operations of a Web
Service.
timestamp
The <timestamp> element groups together the elements used to configure timestamp behavior
of WebLogic Server. WebLogic Server adds or requires timestamps only in SOAP messages that
are encrypted or digitally signed.
If the web-services.xml deployment descriptor does not include a <timestamp> child element
of the <security> element, and the Web Service has been configured for message-level security
(encryption and digital signatures), WebLogic Server:
z Requires that SOAP requests include a timestamp and rejects any that do not.
z Assumes that its clock and the client application’s clock are not synchronized. This means
that if the SOAP request from a client application includes a timestamp with an expiration,
WebLogic Server rejects the message because it cannot ensure that the message has not
already expired.
Adds a timestamp to the SOAP response. The timestamp contains only the creation date of the
SOAP response.
This element has no attributes. This element has the following child elements:
z clock-precision
z clocks-synchronized
z enforce-precision
z generate-signature-timestamp
z inbound-expiry
z outbound-expiry
z require-signature-timestamp
type-mapping
The <type-mapping> element contains the list of mappings between the XML data types
defined in the <types> element and their Java representations.
For each data type in the <types> element, there is a corresponding <type-mapping-entry>
element that lists the Java class that implements the data type, how to serialize and deserialize the
data, and so on.
This element has no attributes.
type-mapping-entry
Describes the mapping between a single XML data type in the <types> element and its Java
representation.
class-name Fully qualified name of the Java class that maps to its String Yes.
corresponding XML data type.
deserializer Fully qualified name of the Java class that converts the String Only required if the
data from XML to Java. data type is not one
of the built-in data
dates supported by
the WebLogic Web
Services runtime,
listed in
“Supported
Built-In Data
Types” on
page 5-15.
element Name of the XML data type that maps to the Java data NMTOKEN One, but not both,
type. Specify only if the XML Schema definition of the of either element
data type uses the <element> element. or type is
required.
serializer Fully qualified name of the Java class that converts the String Only required if the
data from Java to XML. data type is not one
of the built-in data
dates supported by
the WebLogic Web
Services runtime,
listed in
“Supported
Built-In Data
Types” on
page 5-15.
type Name of the XML data type that maps to the Java data NMTOKEN One, but not both,
type. Specify only if the XML Schema definition of the of either element
data type uses the <type> element. or type is
required.
types
Describes, using XML Schema notation, the non-built-in data types used as parameters or return
types of the Web Service operations.
For details on using XML Schema to describe the XML representation of a non-built-in data type,
see http://www.w3.org/TR/xmlschema-0/.
The following example shows an XML Schema declaration of a data type called TradeResult
that contains two elements: stockSymbol, a string data type, and numberTraded, an integer.
<types>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:stns="java:examples.webservices"
attributeFormDefault="qualified"
elementFormDefault="qualified"
targetNamespace="java:examples.webservices">
<xsd:complexType name="TradeResult">
<xsd:sequence>
<xsd:element maxOccurs="1"
name="stockSymbol"
type="xsd:string" minOccurs="1">
</xsd:element>
<xsd:element maxOccurs="1"
name="numberTraded"
type="xsd:int"
minOccurs="1">
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
</types>
user
Specifies the username and password to be used in the SOAP response message.
This element has two child elements:
z <name>
z <password>
web-service
Defines a single Web Service.
The Web Service is defined by the following:
z Back-end components that implement an operation, such as a stateless session EJB, a Java
class, or a JMS consumer or producer.
z An optional set of data type declarations for non-built-in data types used as parameters or
return values to the Web Service operations.
z An optional set of XML to Java data type mappings that specify the serialization class and
Java classes for the non-built-in data types.
charset Specifies the character set that the Web Service uses in String No.
its response to an invocation. Examples of character sets
include US-ASCII, UTF-8, and Shift_JIS.
The default value is US-ASCII.
Note: Although US-ASCII is the default value for
this attribute, this does not mean that the
US-ASCII character set will always be used
in the response of a WebLogic Web Service
invocation if you have not explicitly set the
attribute in the web-service.xml file of the
Web Service. See “Order of Precedence of
Character Set Configuration Used By
WebLogic Server” for more details.
exposeHomePage Specifies whether to publicly expose the Home Page of Boolean No.
the Web Service.
Valid values for this attribute are True and False. The
default value is True. This means that by default the
Home Page is publicly accessible.
ignoreAuthHeader Specifies that the Web Service ignore the Boolean. No.
Authorization HTTP header in the SOAP request.
jmsUri Specifies that client applications can use the JMS String. No.
transport to invoke the Web Service, in addition to the
default HTTP/S transport. The form of this attribute is:
connection_factory_name/queue_name
where connection_factory_name is the JNDI
name of the JMS connection factory and queue_name
is the JNDI name of the JMS queue that you have
configured for the JMS transport. For example:
jmsURI="JMSTransFactory/JMSTransQueue"
If this attribute is set, the generated WSDL of the Web
Service contains an additional port that uses a JMS
binding. The clientgen Ant task, when generating
the stubs used to invoke this Web Service, generates a
getServicePortJMS() method, in addition to the
default getServicePort() method, used for JMS
and HTTP/S respectively.
style Specifies whether the Web Service has RPC-oriented or String No.
document-oriented operations.
RPC-oriented WebLogic Web Service operations use
SOAP encoding. Document-oriented WebLogic Web
Service operations use literal encoding.
The following two values specify document-oriented
Web Service operations: document and
documentwrapped.
If you specify document for this attribute, the resulting
Web Service operations take only one parameter. This
means that the methods that implement the operations
must also have only one parameter.
If you specify documentwrapped, the resulting Web
Service operations can take any number of parameters,
although the parameter values will be wrapped into one
complex data type in the SOAP messages. If two or
more methods of your stateless session EJB or Java
class that implement the Web Service have the same
number and data type of parameters, and you want the
operations to be document-oriented, you must specify
documentwrapped for this attribute rather than
document.
Valid values are rpc, documentwrapped, and
document. Default value is rpc.
uri URI of the Web Service, used subsequently in the URL String Yes.
that invokes the Web Service.
useSOAP12 Specifies whether to use SOAP 1.2 as the message Boolean No.
format protocol. By default, WebLogic Web Services
use SOAP 1.1.
If you specify useSOAP12="True", the generated
WSDL of the deployed WebLogic Web Service
includes two ports: the standard port that specifies a
binding for SOAP 1.1 as the message format protocol,
and a second port that uses SOAP 1.2. Client
applications, when invoking the Web Service, can use
the second port if they want to use SOAP 1.2 as their
message format protocol.
Valid values for this attribute are True and False. The
default value is False.
web-services
The root element of the web-services.xml deployment descriptor.
This element does not have any attributes.
The following sections describe WebLogic Web Service Ant tasks and the command-line utilities
based on these Ant tasks:
BEA provides a number of Ant tasks that help you generate important parts of a Web Service
(such as the serialization class, a client JAR file, and the web-services.xml file) and to package
all the pieces of a WebLogic Web Service into a deployable EAR file.
The Apache Web site provides other useful Ant tasks for packaging EAR, WAR, and EJB JAR
files. For more information, see http://jakarta.apache.org/ant/manual/.
Note: The Apache Jakarta Web site publishes online documentation for only the most current
version of Ant, which might be different from the version of Ant that is bundled with
WebLogic Server. To determine the version of Ant that is bundled with WebLogic
Server, run the following command after setting your WebLogic environment:
prompt> ant -version
To view the documentation for a specific version of Ant, download the Ant zip file from
http://archive.apache.org/dist/ant/binaries/ and extract the documentation.
You can also run some of the Ant tasks as a command-line utility, using flags rather than
attributes to specify how the utility works. The description of the flags is exactly the same as the
description of its corresponding attribute.
Warning: Not all the attributes of the Ant tasks are available as flags to the equivalent
command-line utility. See the sections that describe each Ant task for a list of the
supported flags when using the command-line equivalent.
For further examples and explanations of using these Ant tasks, see Chapter 6, “Assembling
WebLogic Web Services Using Ant Tasks.”
clientgen weblogic.webservice.clientgen Generates a client JAR file that contains a thin Java client
used to invoke a Web Service.
servicegen Not available. Main Ant task that performs all the steps needed to
assemble a Web Service. These steps include:
• Creating the Web Service deployment descriptor
(web-services.xml).
• Introspecting EJBs and Java classes and generating
any needed non-built-in data type supporting
components.
• Generating the client JAR file.
• Packaging all the pieces into a deployable EAR file.
wsdlgen weblogic.webservice.wsdlgen Generates a WSDL file from the EAR and WAR files that
make up the Web Service.
2. Create a file called build.xml that contains a call to the Web Services Ant tasks.
The following example shows a simple build.xml file (with details of the Web Services
Ant tasks servicegen and clientgen omitted for clarity):
<project name="buildWebservice" default="build-ear">
<target name="build-ear">
<servicegen attributes go here...>
...
</servicegen>
</target>
<target name="build-client" depends="build-ear">
<clientgen attributes go here .../>
</target>
<target name="clean">
<delete>
<fileset dir="."
includes="example.ear,client.jar" />
</delete>
</target>
</project>
Later sections provide examples of specifying the Ant task in the build.xml file.
3. Execute the Ant task or tasks specified in the build.xml file by typing ant in the same
directory as the build.xml file:
prompt> ant
wsdl attribute of the clientgen Ant task to create the Web Services-specific client JAR file
from an existing WSDL file that describes a Web Service.
The Ant tasks process these files in a case-sensitive way. This means that if, for example, the
XML Schema file specifies two complex types whose names differ only in their capilatization
(for example, MyReturnType and MYRETURNTYPE), the clientgen Ant task correctly generates
two separate sets of Java source files for the Java represenation of the complex data type:
MyReturnType.java and MYRETURNTYPE.java.
However, compiling these source files into their respective class files might cause a problem if
you are running the Ant task on Microsoft Windows, because Windows is a case insensitive
operating system. This means that Windows considers the files MyReturnType.java and
MYRETURNTYPE.java to have the same name. So when you compile the files on Windows, the
second class file overwrites the first, and you end up with only one class file. The Ant tasks,
however, expect that two classes were compiled, thus resulting in an error similar to the
following:
c:\src\com\bea\order\MyReturnType.java:14:
class MYRETURNTYPE is public, should be declared in a file named
MYRETURNTYPE.java
public class MYRETURNTYPE
^
To work around this problem rewrite the XML Schema so that this type of naming conflict does
not occur, or if that is not possible, run the Ant task on a case sensitive operating system, such as
Unix.
The following example shows how to add to the CLASSPATH by using the <classpath>
element:
<servicegen ...>
<classpath>
<pathelement path="${java.class.path}" />
<pathelement path="my_fab_directory" />
</classpath>
...
</servicegen>
The following example shows how you can build your CLASSPATH variable outside of the
WebLogic Web Service Ant task declarations, then specify the variable from within the task
using the <classpath> element:
<path id="myid">
<pathelement path="${java.class.path}"/>
<pathelement path="${additional.path1}"/>
<pathelement path="${additional.path2}"/>
</path>
<servicegen ....>
<classpath refid="myid" />
...
</servicegen>
Warning: The WebLogic Web Services Ant tasks support the standard Ant property
build.sysclasspath. The default value for this property is ignore. This means
that if you specifically set the CLASSPATH in the build.xml file as described in
this section, the Ant task you want to run ignores the system CLASSPATH (or the
CLASSPATH in effect when Ant is run) and uses only the one that you specifically
set. It is up to you to include in your CLASSPATH setting all the classes that the Ant
task needs to successfully run. To change this default behavior, set the
build.sysclasspath property to last to concatenate the system CLASSPATH to
the end of the one you specified, or first to concatenate your specified
CLASSPATH to the end of the system one.
For more information on the build.sysclasspath property, see the Ant
documentation.
Note: The Java Ant utility included in WebLogic Server uses the ant (UNIX) or ant.bat
(Windows) configuration files in the WL_HOME\server\bin directory to set various
Ant-specific variables, where WL_HOME is the top-level directory of your WebLogic
Platform installation If you need to update these Ant variables, make the relevant
changes to the appropriate file for your operating system.
3. Execute the utility using the java command, as shown in the following example:
prompt> java weblogic.webservice.clientgen \
-ear myapps/myapp.ear \
-serviceName myService \
-packageName myservice.client \
-clientJar myapps/myService_client.jar
Run the command with no arguments to get a usage message.
autotype
The autotype Ant task generates the following components for non-built-in data types that used
as parameters or return values of your Web Service operation:
z Serialization class that converts between the XML and Java representation of the data.
z Given an XML Schema or WSDL file, a Java class to contain the Java representation of
the data type.
z Given a Java class that represents the non-built-in data type, an XML Schema
representation of the data type.
You can specify one of the following types of input to the autotype Ant task:
z A Java class file that represents your non-built-in data types by specifying the javaTypes
attribute. The autotype Ant task generates the corresponding XML Schemas, the
serialization classes, and the data type mapping information for the web-services.xml
file.
z A Java class file of the component that implements your Web Service by specifying the
javaComponents attribute. If your Web Service is implemented with a Java class, then
this attribute points to the Java class. If your Web Service is implemented with a stateless
session EJB, then this attribute points to the remote interface of the EJB. The autotype
Ant task looks for non-built-in data types used as parameters or return values in the
component, then generates the corresponding XML Schemas, the serialization classes, and
the data type mapping information for the web-services.xml file. Be sure to include the
Java class for your non-built-in data type in your CLASSPATH.
z An XML Schema file that represents your non-built-in data type by specifying the
schemaFile attribute. The autotype Ant task generates the corresponding Java
representations, the serialization classes, and the data type mapping information for the
web-services.xml file.
z A URL to a WSDL file that contains a description of your non-built-in data type by
specifying the wsdlURI attribute. The autotype Ant task generates the corresponding Java
representations, the serialization classes, and the data type mapping information for the
web-services.xml file.
Use the destDir attribute to specify the name of a directory that contains the generated
components. The generated XML Schema and data type mapping information are generated in a
file called types.xml. You can use this file to manually update an existing web-services.xml
file with non-built-in data type mapping information, or use it in conjunction with the
typeMappingFile attribute of the servicegen or clientgen Ant tasks, or the typesInfo
attribute of the source2wsdd Ant task.
Warning: The serialization class and Java and XML representations generated by the
autotype, servicegen, and clientgen Ant tasks cannot be round-tripped. For
more information, see “Non-Roundtripping of Generated Data Type Components”
on page 6-22.
Note: The fully qualified name for the autotype Ant task is
weblogic.ant.taskdefs.webservices.javaschema.JavaSchema.
Example
The following example shows how to create non-built-in data type components from a Java class:
<autotype javatypes="mypackage.MyType"
targetNamespace="http://www.foobar.com/autotyper"
packageName="a.package.name"
destDir="output" />
The following example is similar to the preceding one, except it creates non-built-in data type
components for an array of mypackage.MyType Java data types:
<autotype javaTypes="[Lmypackage.MyType;"
targetNamespace="http://www.foobar.com/autotyper"
packageName="a.package.name"
destDir="output" />
Note: The [Lclassname; syntax follows the Java class naming conventions as outlined in the
java.lang.Class.getName() method documentation.
The following example shows how to use the autotype Ant task against a WSDL file; it also
shows how to specify that the Ant task keep the generated Java files for the serialization class:
<autotype wsdl="wsdls/myWSDL"
targetNamespace="http://www.foobar.com/autotyper"
packageName="a.package.name"
destDir="output"
keepGenerated="True" />
Attributes
The following table describes the attributes of the autotype Ant task.
destDir Full pathname of the directory that will contain the String Yes.
generated components. The generated XML Schema
and data type mapping information are generated in a
file called types.xml.
encoding Specifies whether the autotype Ant task uses String No.
SOAP or literal encoding when generating the XML Use this attribute
Schema file that describes the XML representation of only in conjunction
a Java data type. with either the
The encoding is particularly important when javaTypes or
generating complex XML data types, such as arrays. javaComponents
SOAP arrays are structurally different from attributes. An error is
non-SOAP arrays, so it is important to always use the returned if you use
correct one for the correct situation. the encoding
If you are creating a document-oriented Web Service, attribute with the
you must specify that autotype use literal encoding, schemaFile
or users might run into interoperability problems attribute.
when they later invoke your Web Service.
Use this attribute only when generating an XML
Schema from an existing Java data type.
Valid values for this attribute are soap and
literal. The default value is soap.
javaComponents Comma-separated list of Java class names that String You must specify
implement the Web Service. For Java one, and only one, of
class-implemented Web Services, this attribute points the following
to the Java class. For stateless session attributes:
EJB-implemented Web Services, this attribute points schemaFile,
to the remote interface of the EJB. The Java classes wsdl, javaTypes,
(of both the implementation of the component and the or
implementation of your non-built-in data type) must javaComponents.
be compiled and in your CLASSPATH.
For example:
javaComponents="my.class1,my.class2"
The autotype Ant task introspects the Java classes
to automatically generate the components for all
non-built-in data types it finds.
javaTypes Comma-separated list of Java class names that String You must specify
represent your non-built-in data types. The Java one, and only one, of
classes must be compiled and in your CLASSPATH. the following
For example: attributes:
schemaFile,
javaTypes="my.class1,my.class2" wsdl, javaTypes,
Note: Use the syntax [Lclassname; to specify or
an array of the Java data type. For an javaComponents.
example, see “Example” on page B-9.
keepGenerated Specifies whether the autotype Ant task should Boolean No.
keep (and thus include in the generated components)
the Java source code of the serialization class for any
non-built-in data types used as parameters or return
values to the Web Service operations, or whether the
autotype Ant task should include only the compiled
class file.
Valid values for this attribute are True and False.
The default value is False.
packageBase Base package name of the generated Java classes for String No.
any non-built-in data types used as a return value or If you specify this
parameter in a Web Service. This means that each attribute, you cannot
generated Java class will be part of the same package also specify
name, although the autotype Ant task generates its packageName.
own specific name for each Java class which it
appends to the specified package base name.
If you do not specify this attribute, the autotype Ant
task generates a base package name for you.
packageName Full package name of the generated Java classes for String No.
any non-built-in data types used as a return value or If you specify this
parameter in a Web Service. attribute, you cannot
If you do not specify this attribute, the autotype Ant also specify
task generates a package name for you. packageBase.
schemaFile Name of a file that contains the XML Schema String You must specify
representation of your non-built-in data types. one, and only one, of
the following
attributes:
schemaFile,
wsdl, javaTypes,
or
javaComponents.
typeMappingFile File that contains data type mapping information for String No.
non-built-in data types for which have already
generated needed components, as well as the XML
Schema representation of your non-built-in data
types. The format of the information is the same as the
data type mapping information in the
<type-mapping> and <types> elements of the
web-services.xml file.
The autotype Ant task does not generate
non-built-in data type components for any data types
listed in this file. It merges the information in this file
with the generated information in its output
types.xml file.
wsdl Full path name or URI of the WSDL that contains the String You must specify
XML Schema description of your non-built-in data one, and only one, of
type. the following
attributes:
schemaFile,
wsdl, javaTypes,
or
javaComponents.
The weblogic.webservice.autotype utility supports the following flags (see the equivalent
attribute for a description of the flag):
z -help (Prints the standard usage message)
z -destDir dir
z -schemaFile pathname
z -wsdl uri
z -javaTypes classname
z -javaComponents classname
z -packageName name
z -packageBase name
z -encoding name
z -generatePublicFields true_or_false
z -typeMappingFile pathname
z -keepGenerated true_or_false
clientgen
The clientgen Ant task generates a Web Service-specific client JAR file that client applications
can use to invoke both WebLogic and non-WebLogic Web Services. Typically, you use the
clientgen Ant task to generate a client JAR file from an existing WSDL file; you can also use
it with an EAR file that contains the implementation of a WebLogic Web Service.
The contents of the client JAR file includes:
z Client interface and stub files (conforming to the JAX-RPC specification) used to invoke a
Web Service in static mode.
z Optional serialization class for converting non-built-in data between its XML and Java
representation.
You can use the clientgen Ant task to generate a client JAR file from the WSDL file of an
existing Web Service (not necessarily running on WebLogic Server) or from an EAR file that
contains a Weblogic Web Service implementation.
The WebLogic Server distribution includes a client runtime JAR file that contains the client side
classes needed to support the WebLogic Web Services runtime component. For more
information, see “Generating the Client JAR File by Running the clientgen Ant Task” on
page 7-5.
Warning: The clientgen Ant task does not support solicit-response or notification WSDL
operations. This means that if you attempt to create a client JAR file from a WSDL
file that contains these types of operations, the Ant task ignores the operations.
Warning: The serialization class and Java and XML representations generated by the
autotype, servicegen, and clientgen Ant tasks cannot be round-tripped. For
more information, see “Non-Roundtripping of Generated Data Type Components”
on page 6-22.
Note: The fully qualified name of the clientgen Ant task is
weblogic.ant.taskdefs.webservices.clientgen.ClientGenTask.
Example
<clientgen wsdl="http://example.com/myapp/myservice.wsdl"
packageName="myapp.myservice.client"
clientJar="myapps/myService_client.jar"
/>
Attributes
The following table describes the attributes of the clientgen Ant task.
ear Name of an EAR file or exploded directory that String Either wsdl
contains the WebLogic Web Service or ear must
implementation for which a client JAR file should be specified.
be generated.
generateAsyncMethods Specifies that the clientgen Ant task should Boolean No.
generate two special methods used to invoke each
Web Service operation asynchronously, in
addition to the standard methods. The special
methods take the following form:
generatePublicFields Specifies whether the clientgen Ant task, when Boolean No.
generating the Java representation of any
non-built-in data types used by the Web Service,
should use public fields for the JavaBean
attributes rather than getter and setter methods.
Valid values are True and False. Default values
is False.
saveWSDL When set to True, specifies that the WSDL of the Boolean No.
Web Service be saved in the generated client JAR
file. This means that client applications do not
need to download the WSDL every time they
create a stub to the Web Service, possibly
improving performance of the client because of
reduced network usage.
Valid values are True and False. Default value
is True.
typeMappingFile File that contains data type mapping information, String No.
used by the clientgen task when generating the
JAX-RPC stubs. The format of the information is
the same as the data type mapping information in
the <type-mapping> element of the
web-services.xml file.
If you specified the ear attribute, the information
in this file overrides the data type mapping
information found in the web-services.xml
file.
typePackageBase Specifies the base package name of the generated String Required
Java class for any non-built-in data types used as only if you
a return value or parameter in a Web Service. This specified the
means that each generated Java class will be part wsdl
of the same package name, although the attribute and
clientgen Ant task generates its own specific the XML
name for each Java class which it appends to the Schema in
specified package base name. the WSDL
If you specify this attribute, you cannot also file does not
specify typePackageName. define a
target
If you do not specify this attribute and the XML namespace.
Schema in the WSDL file defines a target
namespace, then the clientgen Ant task
generates a package name for you based on the
target namespace. This means that if your XML
Schema does not define a target namespace, then
you must specify either the typePackageName
(preferred) or typePackageBase attributes of
the clientgen Ant task.
Note: Rather than using this attribute, BEA
recommends that you specify the full
package name with the
typePackageName attribute. The
typePackageBase attribute is
available for JAX-RPC compliance.
typePackageName Specifies the full package name of the generated String Required
Java class for any non-built-in data types used as only if you
a return value or parameter in a Web Service. specified the
If you specify this attribute, you cannot also wsdl
specify typePackageBase. attribute and
the XML
If you do not specify this attribute and the XML Schema in
Schema in the WSDL file defines a target the WSDL
namespace, then the clientgen Ant task file does not
generates a package name for you based on the define a
target namespace. This means that if your XML target
Schema does not define a target namespace, then namespace..
you must specify either the typePackageName
(preferred) or typePackageBase attributes of
the clientgen Ant task.
Note: Although not required, BEA
recommends you specify this attribute.
useLowerCaseMethodNames When set to true, specifies that the method names Boolean No.
in the generated stubs have a lower-case first
character. Otherwise, all method names will the
same as the operation names in the WSDL file.
Valid values are True and False. Default value
is True.
usePortNameAsMethodName Specifies where the clientgen Ant task should Boolean No.
get the names of the operations when generating a
client from a WSDL file.
If this value is set to true, then operations take the
name specified by the name attribute of the
<port> element in the WSDL file (where
<port> is the child element of the <service>
element). If usePortNameAsMethodName is
set to false, then operations take the name
specified by the name attribute of the
<portType> element in the WSDL file (where
<portType> is the child element of the
<definitions> element).
Valid values are True and False. Default value
is False.
useServerTypes Specifies where the clientgen task gets the Boolean No.
implementation of any non-built-in Java data Use only in
types used in a Web Service: either the task combination
generates the Java code or the task gets it from the with the ear
EAR file that contains the full implementation of attribute.
the Web Service.
Valid values are True (use the Java code in the
EAR file) and False. Default value is False.
For the list of non-built-in data types for
which clientgen can generate data type
components, see “Non-Built-In Data Types
Supported by servicegen and autotype Ant
Tasks” on page 6-18.
warName Name of the WAR file which contains the Web String No.
Service(s). You can
The default value is web-services.war. specify this
attribute only
in
combination
with the ear
attribute.
wsdl Full path name or URL of the WSDL that String Either wsdl
describes a Web Service (either WebLogic or or ear must
non-WebLogic) for which a client JAR file should be specified.
be generated.
The generated stub factory classes in the client
JAR file use the value of this attribute in the
default constructor.
z -ear pathname
z -clientJar pathname
z -packageName name
z -warName name
z -serviceName name
z -typeMappingFile pathname
z -useServerTypes true_or_false
z -typePackageName name
z -typePackageBase name
z -useLowerCaseMethodNames true_or_false
z -usePortNameAsMethodName true_or_false
z -generateAsyncMethods true_or_false
z -generatePublicFields true_or_false
z -saveWSDL true_or_false
z -autotype true_or_false
z -overwrite true_or_false
z -keepGenerated true_or_false
servicegen
The servicegen Ant task takes as input an EJB JAR file or list of Java classes, and creates all
the needed Web Service components and packages them into a deployable EAR file.
In particular, the servicegen Ant task:
z Introspects the EJBs and Java classes, looking for public methods to convert into Web
Service operations.
z Optionally creates the serialization class that converts the non-built-in data between its
XML and Java representations. It also creates XML Schema representations of the Java
objects and updates the web-services.xml file accordingly. This feature is referred to as
autotyping.
z Packages all the Web Service components into a Web application WAR file, then packages
the WAR and EJB JAR files into a deployable EAR file.
You can also configure default configuration for reliable SOAP messaging, handler chains, and
data security (digital signatures and encryption) for a Web Service using servicegen.
While you are developing your Web Service, BEA recommends that you create an exploded
directory, rather than an EAR file, by specifying a value for the destEar attribute of servicegen
that does not have an .ear suffix. You can later package the exploded directory into an EAR file
when you are ready to deploy the Web Service.
Warning: The serialization class and Java and XML representations generated by the
autotype, servicegen, and clientgen Ant tasks cannot be round-tripped. For
more information, see “Non-Roundtripping of Generated Data Type Components”
on page 6-22.
Note: The fully qualified name of the servicegen Ant task is
weblogic.ant.taskdefs.webservices.servicegen.ServiceGenTask.
Example
<servicegen
destEar="ears/myWebService.ear"
warName="myWAR.war"
contextURI="web_services" >
<service
ejbJar="jars/myEJB.jar"
targetNamespace="http://www.bea.com/examples/Trader"
serviceName="TraderService"
serviceURI="/TraderService"
generateTypes="True"
expandMethods="True" >
</service>
</servicegen>
The following graphic describes the hierarchy of the servicegen Ant task.
service
client
handlerChain
reliability
security
service
client
handlerChain
reliability
security
servicegen
The servicegen Ant task is the main task for automatically generating and assembling all the
parts of a Web Service and packaging it into a deployable EAR file.
The following table describes the attributes of the servicegen Ant task.
contextURI Context root of the Web Service. You use this value in String No.
the URL that invokes the Web Service.
The default value of the contextURI attribute is the
value of the warName attribute.
destEar Pathname of the EAR file or exploded directory which String Yes
will contain the Web Service and all its components.
To create or update an EAR file, use a.ear suffix when
specifying the EAR file, such as
ears/mywebservice.ear. If the attribute value
does not have a.ear suffix, then the servicegen task
creates an exploded directory.
If you specify an EAR file or directory that does not
exist, the servicegen task creates a new one.
keepGenerated Specifies whether the servicegen Ant task should Boolean No.
keep (and thus include in the generated Web Services
EAR file) the Java source code of the serialization class
for any non-built-in data types used as parameters or
return values to the Web Service operations, or whether
the servicegen Ant task should include only the
compiled class file.
Valid values for this attribute are True and False. The
default value is False.
mergeWithExistingWS Specifies whether the servicegen Ant task should Boolean No.
attempt to merge the generated components into
existing Web Services in the EAR file specified by the
destEar attribute.
Valid values for this attribute are True and False. The
default value is False.
warName Name of the WAR file or exploded directory into which String No
the Web Service Web application is written. The WAR
file or directory is created at the top level of the EAR
file.
The default value is a WAR file called
web-services.war.
To specify a WAR file, use a .war suffix, such as
mywebserviceWAR.war. If the attribute value does
not have a .war suffix, then the servicegen task
creates an exploded directory.
service
The <service> element describes a single Web Service implemented with either a stateless
session EJB or a Java class.
The following table describes the attributes of the <service> element of the servicegen Ant
task. Include one <service> element for every Web Service you want to package in a single
EAR file.
Table B-5 Attributes of the <service> Element of the servicegen Ant Task
Attribute Description Data Required?
Type
ejbJar JAR file or exploded directory that contains the EJBs String You must
that implement the back-end component of a Web specify either
Service operation. The servicegen Ant task the ejbJar,
introspects the EJBs to automatically generate all the javaClassC
components. omponents,
or JMS*
attribute.
Table B-5 Attributes of the <service> Element of the servicegen Ant Task
Attribute Description Data Required?
Type
ignoreAuthHeader Specifies that the Web Service ignore the Boolean No.
Authorization HTTP header in the SOAP
request.
Table B-5 Attributes of the <service> Element of the servicegen Ant Task
Attribute Description Data Required?
Type
javaClassComponents Comma-separated list of Java class names that String You must
implement the Web Service operation. The Java specify either
classes must be compiled and in your CLASSPATH. the ejbJar,
For example: javaClassC
omponents,
javaClassComponents="my.FirstClass,my or JMS*
.SecondClass" attribute.
Note: Do not include the .class extension when
specifying the class names.
The servicegen Ant task introspects the Java
classes to automatically generate all the needed
components.
JMSAction Specifies whether the client application that invokes String Yes, if creating
this JMS-implemented Web Service sends or receives a
messages to or from the JMS destination. JMS-impleme
Valid values are send or receive. nted Web
Service.
Specify send if the client sends messages to the JMS
destination and receive if the client receives
messages from the JMS destination.
Table B-5 Attributes of the <service> Element of the servicegen Ant Task
Attribute Description Data Required?
Type
JMSDestinationType Type of JMS destination. Currently only one type is String Yes, if creating
supported: Queue. a
Valid value is queue. JMS-impleme
nted Web
Service.
JMSMessageType Data type of the single parameter to the send or String No.
receive operation.
Default value is java.lang.String.
If you use this attribute to specify a non-built-in data
type, and set the generateTypes attribute to True,
be sure the Java representation of this non-built-in
data type is in your CLASSPATH.
JMSOperationName Name of the operation in the generated WSDL file. String No.
Default value is either send or receive, depending
on the value of the JMSAction attribute.
protocol Protocol over which this Web Service is deployed. String No.
Valid values are http and https. The default value
is http.
serviceName Name of the Web Service which will be published in String Yes.
the WSDL.
Table B-5 Attributes of the <service> Element of the servicegen Ant Task
Attribute Description Data Required?
Type
serviceURI Web Service URI portion of the URL used by client String Yes.
applications to invoke the Web Service.
Note: Be sure to specify the leading "/", such as
/TraderService.
The full URL to invoke the Web Service will be:
protocol://host:port/contextURI/servi
ceURI
where
• protocol refers to the protocol attribute of
the <service> element
• host refers to the computer on which WebLogic
Server is running
• port refers to the port on which WebLogic
Server is listening
• contextURI refers to the contextURI
attribute of the main servicegen Ant task
• serviceURI refers to this attribute
Table B-5 Attributes of the <service> Element of the servicegen Ant Task
Attribute Description Data Required?
Type
style Specifies whether the servicegen Ant task should String No.
generate RPC-oriented or document-oriented Web
Service operations.
RPC-oriented WebLogic Web Service operations use
SOAP encoding. Document-oriented WebLogic Web
Service operations use literal encoding.
You can use the following two values to generate
document-oriented Web Service operations:
document and documentwrapped.
If you specify document for this attribute, the
resulting Web Service operations take only one
parameter. This means that the methods that
implement the operations must also have only one
parameter. In this case, if servicegen encounters
methods that have more than one parameter,
servicegen ignores the method and does not
generate a corresponding Web Service operation for
it.
If you specify documentwrapped, the resulting
Web Service operations can take any number of
parameters, although the parameter values will be
wrapped into one complex data type in the SOAP
messages. If two or more methods of your stateless
session EJB or Java class that implement the Web
Service have the same number and data type of
parameters, and you want the operations to be
document-oriented, you must specify
documentwrapped for this attribute rather than
document.
Valid values for this attribute are rpc,
documentwrapped, and document. Default value
is rpc.
Table B-5 Attributes of the <service> Element of the servicegen Ant Task
Attribute Description Data Required?
Type
typeMappingFile File that contains additional XML data type mapping String No.
information and XML Schema representation of
non-built-in data types. The format of the information
is the same as the data type mapping information in a
web-services.xml.
Use this attribute if you want to include extra XML
data type information in the <type-mapping>
element of the web-services.xml file, in addition
to the required XML descriptions of data types used
by the EJB or Java class that implements an operation.
The servicegen task adds the extra information in
the specified file to a generated
web-services.xml file.
useSOAP12 Specifies whether to use SOAP 1.2 as the message Boolean No.
format protocol. By default, WebLogic Web Services
use SOAP 1.1.
If you specify useSOAP12="True", the generated
WSDL of the deployed WebLogic Web Service
includes two ports: the standard port that specifies a
binding for SOAP 1.1 as the message format protocol,
and a second port that uses SOAP 1.2. Client
applications, when invoking the Web Service, can use
the second port if they want to use SOAP 1.2 as their
message format protocol.
Valid values for this attribute are True and False.
The default value is False.
client
The optional <client> element describes how to create the client JAR file that client
applications use to invoke the Web Service. Specify this element only if you want the
servicegen Ant task to create a client JAR file.
Note: You do not have to create the client JAR file when you assemble your Web Service. You
can later use the clientgen Ant task to generate the JAR file.
Table B-6 Attributes of the <client> Element of the servicegen Ant Task
Attribute Description Data Required?
Type
packageName Package name into which the generated client interfaces and String Yes.
stub files are packaged.
saveWSDL When set to True, saves the WSDL file of the Web Service in Boolean No.
the generated client JAR file. This means that client applications
do not need to download the WSDL file every time they create
a stub to the Web Service, possibly improving performance of
the client because of reduced network usage.
Valid values are True and False. Default value is True.
useServerTypes Specifies where the servicegen task gets the implementation Boolean No.
of any non-built-in Java data types used in a Web Service: either
the task generates the Java code or the task gets it from the EAR
file that contains the full implementation of the Web Service.
Valid values are True (use the Java code in the EAR file) and
False. Default value is False.
For the list of non-built-in data types for which servicegen can
generate data type components, see “Non-Built-In Data
Types Supported by servicegen and autotype Ant Tasks”
on page 6-18.
handlerChain
The optional <handlerChain> child element of the <service> element adds a handler chain
component to the Web Service, and specifies that the handler chain is associated with every
operation of the Web Service. A handler chain consists of one or more handlers. For more
information on handler chains, see Chapter 12, “Creating SOAP Message Handlers to Intercept
the SOAP Message.”
Note: Setting this element in servicegen associates the handler chain with every operation in
your Web Service. If you want only some operations to be associated with this handler
chain, then you must edit the generated web-services.xml file and remove the
handler-chain attribute of the corresponding <operation> element. For details of
these elements and attributes, see Appendix A, “WebLogic Web Service Deployment
Descriptor Elements.”
The following table describes the attributes of the <handlerChain> element.
Table B-7 Attributes of the <handlerChain> Element of the servicegen Ant Task
Attribute Description Data Required?
Type
handlers Comma separated fully qualified list of Java class names that String Yes.
implement the handlers in the handler chain. You must include
at least one class name.
reliability
The optional <reliability> child element of the <service> element specifies that every
operation of the Web Service can be invoked asynchronously using reliable SOAP messaging.
For more information on reliable SOAP messaging, see Chapter 10, “Using Reliable SOAP
Messaging.”
Note: Setting this element in servicegen enables reliable SOAP messaging for every
operation in your Web Service. If you want only some operations to have reliable SOAP
messaging, then you must edit the generated web-services.xml file and remove the
<reliable-delivery> child element of the corresponding <operation> element. For
details of these elements, see Appendix A, “WebLogic Web Service Deployment
Descriptor Elements.”
The following table describes the attributes of the <reliability> element.
Table B-8 Attributes of the <reliability> Element of the servicegen Ant Task
Attribute Description Data Required?
Type
duplicateElimination Specifies whether the WebLogic Web Service operations Boolean No.
should ignore duplicate invokes from the same client
application.
If this attribute is set to True, the Web Service persists the
message IDs from client applications that invoke the Web
Service so that it can eliminate any duplicate invokes. If this
values is set to False, the Web Service does not keep track
of duplicate invokes, which means that if a client retries an
invoke, both invokes could return values.
Valid values for this attribute are True and False. The
default value is True.
persistDuration The default minimum number of seconds that the Web Integer No.
Service should persist the history of a reliable SOAP
message (received from the sender that invoked the Web
Service) in its storage.
The Web Service, after recovering from a WebLogic Server
crash, does not dispatch persisted messages that have
expired.
The default value of this attribute is 60,000 seconds.
security
The optional <security> child element of the <service> element adds default data security,
such as digital signatures and encryption, to your Web Service. For more information about data
security, see Chapter 13, “Configuring Security.”.
Note: You can encrypt or digitally sign only the entire SOAP message body when you
configure data security using the servicegen Ant task. If you want to specify particular
elements of the SOAP message that are to be digitally signed or encrypted, see
“Configuring Message-Level Security: Main Steps” on page 13-9. This section also
describes the general security configuration tasks you must perform with the
Administration Console before you can successfully invoke your secure Web Service.
The following table describes the attributes of the <security> element.
Table B-9 Attributes of the <security> Element of the servicegen Ant Task
Attribute Description Data Required?
Type
encryptKeyName The name of the key and certificate pair, stored in WebLogic String Only if you
Server’s keystore, used to encrypt SOAP message. want to
If you do not specify this attribute, no part of the SOAP encrypt the
message will be encrypted. SOAP
message.
encryptKeyPass The password of the key and certificate pair, stored in String Only if you
WebLogic Server’s keystore, used to encrypt the SOAP want to
message. encrypt the
If you do not specify this attribute, no part of the SOAP SOAP
message will be encrypted. message.
Table B-9 Attributes of the <security> Element of the servicegen Ant Task
Attribute Description Data Required?
Type
password Specifies the password used in the username token of the String Only if your
SOAP response message. SOAP
If you do not specify this attribute, the SOAP response messages
message will not include a username token specification. require a
username
token.
signKeyName The name of the key and certificate pair, stored in String Only if you
WebLogic Server’s keystore, used to digitally sign the want to
SOAP message. digitally sign
the SOAP
If you do not specify this attribute, no part of the SOAP message.
message will be digitally signed.
signKeyPass The password of the key and certificate pair, stored in String Only if you
WebLogic Server’s keystore, used to digitally sign the want to
SOAP message. digitally sign
the SOAP
If you do not specify this attribute, no part of the SOAP message.
message will be digitally signed.
username Specifies the username used in the username token of the String Only if your
SOAP response message. SOAP
If you do not specify this attribute, the SOAP response messages
message will not include a username token specification. require a
username
token.
source2wsdd
The source2wsdd Ant task generates a web-services.xml deployment descriptor file from the
Java source file for a stateless session EJB- or Java class-implemented WebLogic Web Service.
You can also specify that the WSDL that describes the Web Service be generated.
The source2wsdd Ant task sets the name of the Web Service to the class name of the Java class
or EJB that implements the Web Service. This name will also be the public name of the Web
Service published in its WSDL.
The source2wsdd Ant task does not generate data type mapping information for any non-built-in
data types used as parameters or return values of the methods of your EJB or Java class If your
EJB or Java class uses non-built-in data types, you must first run the autotype Ant task to
generate the needed components, then point the typesInfo attribute of the source2wsdd Ant
task to the types.xml file generated by the autotype Ant task.
If your EJB or Java class refers to other Java class files, be sure to set the sourcePath attribute
of source2wsdd Ant task to the directory that contains them.
Note: The fully qualified name of the source2wsdd Ant task is
weblogic.ant.taskdefs.webservices.autotype.JavaSource2DD.
Example
The following example shows how to generate a web-services.xml file, generated into the
ddfiles directory, for a Java class-implemented Web Service. The information about the
non-built-in data types is contained in the autotype/types.xml file. The Web Service portion
of the URI used to invoke the service is /MyService.
<source2wsdd
javaSource="source/MyService.java"
typesInfo="autotype/types.xml"
ddFile="ddfiles/web-services.xml"
serviceURI="/MyService"
/>
The following example shows how to generate both a web-services.xml file and the WSDL
file (called wsdFiles/Temperature.wsdl) that describes a stateless session EJB-implemented
Web Service. Because the ejbLink attribute is specified, the javaSource attribute must point
to the EJB source file. The source2wsdd Ant task uses the value of the ejblink attribute as the
value of the <ejb-link> child element of the <stateless-ejb> element in the generated
web-services.xml file.
<source2wsdd
javaSource="source/TemperatureService.java"
ejbLink="TemperatureService.jar#TemperatureServiceEJB"
ddFile="ddfiles/web-services.xml"
typesInfo="autotype/types.xml"
serviceURI="/TemperatureService"
wsdlFile="wsdlFiles/Temperature.wsdl"
/>
Attributes
The following table describes the attributes of the source2wsdd Ant task.
ejblink Specifies the value of the <ejb-link> child element String No.
of the <stateless-ejb> element in the generated If you specify
deployment descriptor file for a stateless session this attribute,
EJB-implemented Web Service. Use this attribute only the required
if you are generating the web-services.xml file javaSource
from an EJB. attribute must
Note: The source2wsdd Ant task does not use this point to the
attribute to determine the EJB which it needs to EJB source
introspect. Rather, it uses this attribute to file.
determine what value it should use for the
<ejb-link> element in the generated
web-services.xml file. Use the
javaSource attribute to point to the actual
EJB source file.
The format of this attribute is as follows:
jar-name#ejb-name
jar-name refers to the name of the JAR file, contained
within the Web Service EAR file, that contains the
stateless session EJB. The name should include
pathnames relative to the top level of the EAR file.
ejb-name refers to the name of the stateless session
EJB, corresponding to the <ejb-name> element in the
ejb-jar.xml deployment descriptor file in the EJB
JAR file.
Example: myapp.jar#StockQuoteBean
handlerInfo Full pathname of the XML file that contains information String No.
about the SOAP message handlers and handler
chains defined for the Web Service.
You must create this file manually. The root element of
the file is <handler-chains>. For more information
about how to populate the file, see “Updating the
web-services.xml File with SOAP Message
Handler Information” on page 12-19 and
Appendix A, “WebLogic Web Service
Deployment Descriptor Elements.”
If you do not specify this attribute, the generated
web-services.xml file does not contain any SOAP
message handlers or handler chain information.
ignoreAuthHeader Specifies that the Web Service ignore the Boolean No.
Authorization HTTP header in the SOAP request.
javaSource Name of the stateless session EJB or Java source file String Yes.
that implements your Web Service component.
mergeWithExistingWS Specifies whether the source2wsdd Ant task should Boolean No.
attempt to merge the generated web-services.xml
deployment descriptor information with an existing file,
specified with the ddFile attribute.
Valid values for this attribute are True and False. The
default value is False.
overwrite Specifies whether the components generated by this Ant Boolean No.
task should be overwritten if they already exist.
If you specify True, new components are always
generated and any existing components are overwritten.
If you specify False, the Ant task overwrites only
those components that have changed, based on the
timestamp of any existing components.
Valid values for this attribute is True or False. The
default value is True.
serviceURI Web Service URI portion of the URL used by client String Yes.
applications to invoke the Web Service.
sourcePath Full pathname of the directory that contains any String No.
additional classes referred to by the Java source file
specified with the javaSource attribute.
typesInfo Name of the file that contains the XML Schema String Yes.
representation and data type mapping information for
any non-built-in data types used as parameters or return
value of the Web Service.
The format of the data type mapping information is the
same as that in the <type-mapping> element of the
web-services.xml file.
Typically you have already run the autotype Ant task
to generate this information into a file called
types.xml.
wsdl2Service
The wsdl2Service Ant task takes as input an existing WSDL file and generates:
z the Java interface that represents the implementation of your Web Service based on the
WSDL file
z the Java exception class for user-defined exceptions specified in the WSDL file
The wsdl2Service Ant task generates a Java interface for only one Web Service in a WSDL file
(specified by the <service> element.) Use the serviceName attribute to specify a particular
service; if you do not specify this attribute, the wsdl2Service Ant task generates a Java interface
for the first <service> element in the WSDL.
The wsdl2Service Ant task does not generate data type mapping information for any
non-built-in data types used as parameters or return values of the operations in the WSDL file.
If the WSDL uses non-built-in data types, you must first run the autotype Ant task to generate
the data type mapping information, then point the typeMappingFile attribute of the
wsdl2Service Ant task to the types.xml file generated by the autotype Ant task.
Warning: The wsdl2Service Ant task, when generating the web-services.xml file for your
Web Service, assumes you use the following convention when naming the Java class
that implements the generated Java interface:
packageName.serviceNameImpl
Example
<wsdl2service
wsdl="wsdls/myService.wsdl"
destDir="myService/implementation"
typeMappingFile="autotype/types.xml"
packageName="example.ws2j.service"
/>
Attributes
The following table describes the attributes of the wsdl2Service Ant task.
ddFile Full pathname of the generated Web Services deployment String No.
descriptor file (web-services.xml) which will contain
the deployment descriptor information.
If you do not specify this attribute, the
web-services.xml file is generated in the directory
specified by the destDir attribute.
destDir The full pathname of the directory that will contain the String Yes.
generated components (web-services.xml file and Java
interface file that represents the implementation of your
Web Service and optional implementation class.)
generateImpl Specifies that the wsdl2Service Ant task should generate Boolean No.
an empty implementation Java class file.
The name of the Java class is serviceNameImpl, where
serviceName refers to the value of the similarly-named
attribute of the wsdl2Service Ant task. The name of
the generated Java file is serviceNameImpl.java,
and the file is generated in the directory specified by the
destDir attribute.
Valid values for this attribute are True and False. The
default value is False.
keepGenerated Specifies whether the wsdl2Service Ant task should Boolean No.
keep (and thus include in directory specified by the
destDir attribute) the Java source code of the interface
that represents your Web service and the user-defined
exceptions in the WSDL file. The default behavior is for the
Ant task to include only the compiled class files.
Valid values for this attribute are True and False. The
default value is False.
overwrite Specifies whether the components generated by this Ant Boolean No.
task should be overwritten if they already exist.
If you specify True, new components are always generated
and any existing components are overwritten.
If you specify False, the Ant task overwrites only those
components that have changed, based on the timestamp of
any existing components.
Valid values for this attribute is True or False. The
default value is True.
packageName The package name for the generated Java interface file that String Yes.
represents the implementation of your Web Service.
serviceName The name of the Web Service in the WSDL file for which a String No.
partial WebLogic implementation will be generated. The
name of a Web Service in a WSDL file is the value of the
name attribute of the <service> element.
If you do not specify this attribute, the wsdl2Service Ant
task generates a partial implementation for the first
<service> element it finds in the WSDL file.
typeMappingFile File that contains data type mapping information for all String Required only if
non-built-in data types referred to by the operations of the the operations of
Web Service in the WSDL file. The format of the the Web Service
information is the same as the data type mapping in the WSDL file
information in the <type-mapping> element of the refer to any
web-services.xml file. non-built-in data
Typically, you first run the autotype Ant task (specifying types.
the wsdl attribute) against the same WSDL file and
generate all the non-built-in data type components. One of
the components is a file called types.xml that contains
the non-built-in data type mapping information and the
XML Schema of the non-built-in data types. Set the
typeMappingFile attribute equal to this file.
wsdl The full path name or URL of the WSDL that describes a String Yes.
Web Service for which a partial WebLogic Web Service
implementation will be generated.
wsdlgen
The wsdlgen Ant task generates a WSDL file from the EAR and WAR files that implement your
Web Service. The EAR file contains the EJBs that implement your Web Service and the WAR
file contains the web-services.xml deployment descriptor file.
The fully qualified name of the wsdlgen Ant task is
weblogic.ant.taskdefs.webservices.wsdlgen.WSDLGen.
Example
<wsdlgen ear="myapps/myapp.ear"
warName="myapps/myWAR.war"
serviceName="myService"
wsdlFile="wsdls/myService.WSDL"
/>
Attributes
The following table describes the attributes of the wsdlgen Ant task.
ear Name of an EAR file or exploded directory that contains the String Yes.
WebLogic Web Service implementation for which the
WSDL file should be generated.
defaultEndpoint Endpoint Web Service URL to be included in the generated String No.
WSDL file.
The default value is http://localhost:7001.
overwrite Specifies whether the components generated by this Ant Boolean No.
task should be overwritten if they already exist.
If you specify True, new components are always generated
and any existing components are overwritten.
If you specify False, the Ant task overwrites only those
components that have changed, based on the timestamp of
any existing components.
Valid values for this attribute is True or False. The
default value is True.
serviceName Web Service name for which a corresponding WSDL file String No.
should be generated.
The Web Service name corresponds to the
<web-service> element in the web-services.xml
deployment descriptor file.
If you do not specify the serviceName attribute, the
wsdlgen task generates a WSDL file for the first service
name found in the web-services.xml file.
warName Name of the WAR file that contains the String Yes.
web-services.xml deployment descriptor file of your
Web Service.
wsdlFile Name of the output file that will contain the generated String Yes.
WSDL.
z -warName name
z -serviceName name
z -defaultEndpoint address
wspackage
Use the wspackage Ant task to:
z package the various components of a WebLogic Web Service into a new deployable EAR
file.
z The EJB JAR file that contains the EJBs the implement a Web Service
z A client JAR file that users can download and use to invoke the Web Service
z Components for any non-built-in data types used as parameters and return values for the
Web Service. These components include the XML and Java representations of the data type
and the serialization class that converts the data between its two representations.
Typically you use other Ant tasks, such as clientgen, autotype, source2wsdd, and
wsdl2Service, to generate the preceding components.
When you use the wspackage Ant task to add additional components to an existing EAR file, be
sure you specify the overwrite="false" attribute to ensure that none of the existing
components are overwritten. Use the output attribute to specify the full pathname of the
existing EAR file.
Note: The fully qualified name of the wspackage Ant task is
weblogic.ant.taskdefs.webservices.wspackage.WSPackage.
Example
The following example shows how to use the wspackage Ant task to package WebLogic Web
Service components into a new EAR file:
<wspackage
output="ears/myWebService.ear"
contextURI="web_services"
codecDir="autotype"
webAppClasses="example.ws2j.service.SimpleTest"
ddFile="ddfiles/web-services.xml"
/>
The following example shows how to add additional components to an existing EAR file called
ears/myWebService.ear.
<wspackage
output="ears/myWebService.ear"
overwrite="false"
filesToEar="myEJB2.jar"
/>
Attributes
The following table describes the attributes of the wspackage Ant task.
codecDir Name of the directory that contains the serialization classes String No.
for any non-built-in data types used as parameters or return
values in your Web Service.
contextURI Context root of the Web Service. You use this value in the String No.
URL that invokes the Web Service.
The default value of the contextURI attribute is the value
of the warName attribute.
filesToWar Comma-separated list of additional files, such as the client String No.
JAR file, to be packaged in the root directory of the Web
Service’s Web application.
output Pathname of the EAR file or exploded directory which will String Yes
contain the Web Service and all its components. If you are
using the wspackage Ant task to add additional
components to an existing EAR file, this attribute specifies
the full pathname of the existing file.
To create or update an EAR file, use a.ear suffix when
specifying the EAR file, such as
ears/mywebservice.ear. If the attribute value does
not have a.ear suffix, then the wspackage task creates an
exploded directory.
If you specify an EAR file or directory that does not exist,
the wspackage task creates a new one.
utilJars Comma-separated list of files that should be packaged in the String No.
WEB-INF/lib directory of the Web Service Web
application.
warName Name of the WAR file into which the Web Service is String No
written. The WAR file is created at the top level of the EAR
file.
The default value is web-services.war.
webAppClasses Comma-separated list of class files that should be packaged String No.
in the WEB-INF/classes directory of the Web Service’s
Web application.
Use this attribute to specify the Java class that implements a
Web Service, SOAP handler classes, and so on.
web-services.xml file, use the source2wsdd Javadoc tags to specify exactly what your Web
Service looks like.
There are three source2wsdd Javadoc tags:
z @wlws:webservice, used in the Javadoc for the class that implements your Web Service.
z @wlws:operation, used in the Javadoc for a method that you want to expose as a Web
Service operation.
z @wlws:part partname used in the Javadoc for a method that has been exposed as an
operation and you want to customize the description of its parameters and return values.
Each tag has a set of attributes which correspond to the appropriate element in the
web-services.xml file that it is describing.
@wlws:webservice
The source2wsdd Ant task uses the @wlws:webservice tag to populate the <web-service>
element of the generated web-services.xml file.
You specify the @wlws:webservice tag in the Javadoc of the class that implements your Web
Service.
The following example shows how to use the @wlws:webservice tag in the Javadoc that
documents a Java class:
/**
* PurchaseOrderService - a service to show different features of
* Weblogic Web Services.
*
* @wlws:webservice
* targetNamespace="http://www.bea.com/po-service/"
* name="PurchaseOrderService"
* portName="POPort"
* portTypeName="POPort"
* protocol="https"
*/
public class POService {
...
}
In the example, the POService Java class is the back-end component that implements a Web
Service whose name is PurchaseOrderService (specified with the name attribute of the
@wls:webservice tag). The <port> and <portType> elements in the generated WSDL for the
Web Service are both POPort. Finally, client applications access the Web Service using HTTPS
rather than the default HTTP.
The following table lists all the attributes of the @wlws:webservice tag.
Name The name of the Web Service, published in the WSDL. The name of the class in the
annotated source code.
portName Name of the <port> child element of the <service> The name of the Web Service
element of the dynamically generated WSDL of this Web with Port appended. For
Service. example, if the name of this
Web Service is
TraderService, the
default port name is
TraderServicePort.
portTypeName Name of the default <portType> element in the The name of this Web
dynamically generated WSDL of this Web service. Service with Port appended.
For example, if the name of
this Web service is
TraderService, the
default portType name is
TraderServicePort.
protocol Protocol over which the Web Service is invoked. Default value is http.
Valid values are http and https.
Style Specifies whether the Web Service has RPC-oriented or Default value is rpc.
document-oriented Web Service operations.
RPC-oriented WebLogic Web Service operations use
SOAP encoding. Document-oriented WebLogic Web
Service operations use literal encoding.
You can use the following two values to generate
document-oriented Web Service operations: document
and documentwrapped.
If you specify document for this attribute, the resulting
Web Service operations take only one parameter. This
means that the methods that implement the operations
must also have only one parameter. In this case, if
source2wsdd encounters methods that have more than
one parameter, source2wsdd ignores the method and
does not generate a corresponding Web Service operation
for it.
If you specify documentwrapped, the resulting Web
Service operations can take any number of parameters,
although the parameter values will be wrapped into one
complex data type in the SOAP messages. If two or more
methods of your stateless session EJB or Java class that
implement the Web Service have the same number and
data type of parameters, and you want the operations to be
document-oriented, you must specify
documentwrapped for this attribute rather than
document.
Valid values for this attribute are rpc,
documentwrapped, and document.Because the
style attribute applies to an entire Web Service, all
operations in a single WebLogic Web Service must be
either RPC-oriented or documented-oriented; WebLogic
Server does not support mixing the two styles within the
same Web Service.
Uri Web Service URI portion of the URL used by client Although you are not
applications to invoke the Web Service. required to specify the Uri
attribute of the
Note: Be sure to specify the leading "/", such as @wlws:webservice tag,
/TraderService. you are required to specify
Note: You can also specify the URI using the the serviceURI of the
serviceURI attribute of the source2wsdd source2wsdd Ant task.
Ant task. If you specify the URI in both places, This means that there is no
and they are different from each other, the URI default value and that at some
specified by the @wlws:webservice Javadoc point you must specify the
tag takes precedence. Web Service URI.
@wlws:operation
The source2wsdd Ant task uses the @wlws:operation tag to populate the corresponding
<operation> element in the generated web-services.xml file.
By default, every public method of the Java class or EJB that implements a Web Service is
exposed as an operation in the generated WSDL. The source2wsdd Ant task uses information
from the method, such as its signature, to populate the <operation> element; use the
@wlws:operation Javadoc tag to change some of the default information, such as the operation
name. Use the @wlws:exclude tag to specify that a public method not be exposed as a Web
Service operation.
You specify the @wlws:operation tag in the Javadoc of the method that implements the
operation.
The following example shows how to use the @wlws:operation tag in the Javadoc that
documents a method:
/**
* A one way call. Client will not wait for this method to
* complete.
*
* Note: A one way call must have a void return type.
*
* @wlws:operation
* invocation-style="one-way"
* Name="sendTime"
*/
public void oneWayCall( long time ){
.....
}
In the example, the oneWayCall method implements an operation of a Web Service called
sendTime, which is the published name of the operation in the WSDL. The operation is one-way,
which means that the client application does not receive a return value.
The following table lists all the attributes of the @wlws:operation tag.
Handler-chain Name of the SOAP message handler chain that, together If you do not specify this
with the method, implements the operation. attribute, no handler-chain
The name of this attribute corresponds to the name information is added to the
attribute of the appropriate <handler-chain> element <operation> element in
in the file that contains the SOAP handler chain the web-services.xml
information. You must write this file manually and file.
specify its location with the handlerInfo attribute of
the source2wsdd Ant task.
invocation-style Specifies whether the operation both receives a SOAP Default value is
request and sends a SOAP response (request-response), or request-response.
whether the operation only receives a SOAP request but
does not send back a SOAP response (one-way).
Valid values are request-response and one-way.
Note: If the back-end component that implements this
operation is a method of a stateless session EJB
or Java class and you set this attribute to
one-way, the method must return void.
Name The name of the operation. This is the name that is The name of the method in
published in the WSDL of the Web Service. the Java source file.
@wlws:part partname
The source2wsdd Ant task uses the @wlws:part tag to populate the corresponding <param> and
<return-param> elements that describe the parameters and return values for the operation in the
generated web-services.xml file.
Every public method of the Java class or EJB that implements a Web Service is exposed as an
operation in the generated WSDL. The source2wsdd Ant task uses information from the method
signature to determine basic information about the parameters and return value of the operation.
If, however, you want to change some of this default information, specify the @wlws:part tag in
the Javadoc of the method. In particular, use the attributes of the tag when you want:
z The name of the parameters and return values in the generated WSDL to be different from
those of the method that implements the operation.
z To explicitly specify the XML and Java represenation of the data type of the paramter or
return value.
Use the @wlws:part tag in the Javadoc of the method that implements the operation. Specify
the name of the parameter right after the tag and before the attributes, as shown:
dataInHeader.setAddress( addressInHeader );
dataInHeader.setId( idInBody );
return dataInHeader;
}
In the example, when a client application invokes the methodWithHeaders operation, the
addressInHeader and dataInHeader input parameters are located in the header of the SOAP
request. When WebLogic Server responds to the invocation of the operation, the return value is
located in the body of the SOAP response.
The following table lists all the attributes of the @wlws:part tag.
class-name Java class name of the Java representation of the The data type of the parameter or
data type of the inpur or return parameter. return value of the operation.
location Part of the request or response SOAP message The default value is Body.
(header, body, or attachment) that contains the
value of the input or return parameter.
Valid values for this attribute are Body,
Header, or attachment.
If you specify Body, the value of the input or
return parameter is contained in the SOAP Body
(of either the request or response, depending on
whether the parameter is input or return). If you
specify Header, the value contained in a SOAP
Header element whose name is the value of the
type attribute.
If you specify attachment, the value of the
parameter is contained in the SOAP Attachment
rather than the SOAP envelope. As specified by
the JAX-RPC specification, only the following
Java data types can be contained in the SOAP
Attachment:
• java.awt.Image
• java.lang.String
• javax.mail.internet.MimeMultipo
rt
• javax.xml.transform.Source
• javax.activation.DataHandler
name The name of the parameter. This is the name For input parameters, the default
that is published in the WSDL of the Web value is the name of the parameter in
Service in the <part> element. the method’s signature.
The default value of the return
parameter is results.
style Style of the input parameter: either a standard The default value is in.
input parameter, an out parameter used as a
return value, or an in-out parameter for both
inputting and outputting values.
Valid values for this attribute are in, out, and
inout.
If you specify a parameter as out or inout, the
Java class of the parameter in the back-end
component’s method must implement the
javax.xml.rpc.holders.Holder
interface.
type XML Schema data type of the parameter. If you do not specify this attribute, the
If you specify this attribute of the @wlws:part XML data type is based on the Java
tag, you must also specify a types.xml file data type of the parameter.
using the typesInfo attribute of the
source2wsdd Ant task. You must also ensure
that the XML Schema data type you specify for
this tag exists in the types.xml file, and that
the two element names match exactly. If the
source2wsdd Ant task does not find the name
of this XML Schema data type in the
types.xml file, the Ant task generates its own
data type mapping information, which could
lead to incorrect behavior of your Web Service.
@wlws:exclude
The source2wsdd Ant task uses the @wlws:exclude tag to exclude public methods of the Java
source file from the list of generated Web Service operations.
By default, every public method of the Java class or EJB that implements a Web Service is
exposed as an operation in the generated WSDL. If you do not want to expose a public method,
you must explicitly add the @wlws:exclude tag to the method’s Javadoc.
The following example shows how to use the @wlws:exclude tag:
/**
* A public method that is not exposed as a Web Service operation.
*
* @wlws:exclude
*/
public void dontExposeThisMethod(){
In the example, the source2wsdd will not add the public method dontExposeThisMethod() to
the list of Web Service operations in the generated webservices.xml file, and thus it will also
not appear in the generated WSDL file.
The @wlws:exclude tag does not have any attributes.
The following sections describe how to customize your WebLogic Web Service by updating the
Web application deployment descriptor files of your Web Service WAR file:
z “Configuring Basic Microsoft MIME Types in the Generated web.xml” on page D-3
Warning: If you publish a static WSDL as the public description of your Web Service, you
must always ensure that it remains up to date with the actual Web Service. In other
words, if you change your Web Service, you must also manually change the static
WSDL to reflect the changes you made to your Web Service. One advantage of
using the dynamic WebLogic-generated WSDL is that it is always up to date.
To include a static WSDL file in your Web Services EAR file and publish it, rather than the
dynamically generated WSDL, to the Web, follow these steps:
1. Un-JAR the WebLogic Web Services EAR file and then the WAR file that contains the
web-services.xml file.
2. Put the static WSDL file in a directory of the exploded Web application. This procedure
assumes you put the file at the top-level directory.
3. Update the web.xml file of the Web application, adding a <mime-mapping> element to
map the extension of your WSDL file to an XML mime type.
For example, if the name of your static WSDL file is myService.wsdl, the corresponding
entry in the web.xml file is as follows:
<mime-mapping>
<extension>wsdl</extension>
<mime-type>text/xml</mime-type>
</mime-mapping>
5. Invoke the static WSDL file using the standard URL to invoke a static file in a Web
application.
For example, use the following URL to invoke the myService.wsdl file in a Web
application that has a context root of web_services:
http://host:port/web_services/myService.wsdl
1. Update the web.xml file of the Web application, adding a <mime-mapping> element to map
the extensions of Microsoft Word applications to their appropriate MIME type.
For example:
<mime-mapping>
<extension>xls</extension>
<mime-type>application/vnd.ms-excel</mime-type>
<extension>mdb</extension>
<mime-type>application/vnd.ms-access</mime-type>
<extension>mpp</extension>
<mime-type>application/vnd.ms-project</mime-type>
<extension>doc</extension>
<mime-type>application/msword</mime-type>
<extension>xls</extension>
<mime-type>application/ms-excel</mime-type>
<extension>ppt</extension>
<mime-type>application/ms-powerpoint</mime-type>
</mime-mapping>
The following sections provide information about assembling a WebLogic Web Service
manually:
3. If your Web Service uses non-built-in data types, create all the needed components, such as
the serialization class.
For detailed information on creating these components manually, see Chapter 11, “Using
Non-Built-In Data Types.”
Based on the contents of the web-services.xml deployment descriptor file, WebLogic Server
dynamically generates the WSDL of a deployed WebLogic Web Service. See “WebLogic Web
Services Home Page and WSDL URLs” on page 6-23 for details on getting the URL of the
dynamically generated WSDL.
A single WebLogic Web Service consists of one or more operations; you can implement each
operation using methods of different back-end components and SOAP message handlers. For
example, an operation might be implemented with a single method of a stateless session EJB or
with a combination of SOAP message handlers and a method of a stateless session EJB.
A single web-services.xml file contains a description of at least one, and maybe more,
WebLogic Web Services.
If you are assembling a Web Service manually (necessary, for example, is the service uses SOAP
message handlers and handler chains), you need to create the web-services.xml file manually.
If you assemble a WebLogic Web Service with the servicegen Ant task, you do not need to
create the web-services.xml file manually, because the Ant task generates one for you based
on its introspection of the EJBs, the attributes of the Ant task, and so on.
Even if you need to manually assemble a Web Service, you can use the servicegen Ant task to
create a basic template, and then use this document to help you update the generated
web-services.xml with the extra information that servicegen does not provide.
<web-services>
<web-service name="stockquotes" targetNamespace="http://example.com"
uri="/myStockQuoteService">
<components>
<stateless-ejb name="simpleStockQuoteBean">
<ejb-link path="stockquoteapp.jar#StockQuoteBean" />
</stateless-ejb>
</components>
<operations>
<operation method="getLastTradePrice"
component="simpleStockQuoteBean" />
</operations>
</web-service>
</web-services>
To create the preceding web-services.xml file manually:
1. Create the root <web-services> element which contains all other elements:
<web-services>
...
</web-services>
2. If one or more of your Web Services include SOAP message handlers to intercept SOAP
messages, create a <handler-chains> child element of the <web-services> root element
and include all the relevant child elements to describe the handlers in the handler chain, the
order in which they should be invoked, and so on. For details, see “Updating the
web-services.xml File with SOAP Message Handler Information” on page 12-19.
3. For each Web Service you want to define, follow these steps:
a. Create a <web-service> child element of the <web-services> element. Use the name,
targetNamespace, and uri attributes to specify the name of the Web Service, its target
namespace, and the URI that clients will use to invoke the Web Service, as shown in the
following example:
<web-service name="stockquote"
targetNamespace="http://example.com"
uri="myStockQuoteService">
...
</web-service>
To specify that the operations in your Web Service are all document-oriented, use the
style="document" attribute. The default value of the style attribute is rpc, which
means the operations are all RPC-oriented.
b. Create a <components> child element of the <web-service> element that lists the
back-end components that implement the operations of the Web Service. For details, see
“Creating the <components> Element” on page E-5.
c. If the operations in your Web Service use non-built-in data types as parameters or return
values, add data type mapping information by creating <types> and <type-mapping>
child elements of the <web-service> element. For details, see “Creating the Data Type
Mapping File” on page 11-10.
Note: You do not have to perform this step if the operations of your Web Service use
only built-in data types as parameters or return values. See “Supported Built-In
Data Types” on page 5-15 for a list of the supported built-in data types.
d. Create an <operations> child element of the <web-service> element that lists the
operations that make up the Web Service:
<operations xmlns:xsd="http://www.w3.org/2001/XMLSchema">
....
</operations>
e. Within the <operations> element, list the operations defined for the Web Service. For
details, see “Creating <operation> Elements” on page E-6.
z <stateless-ejb>
This element describes a stateless EJB back-end component. Use either the <ejb-link>
child element to specify the name of the EJB and the JAR file where it is located or the
<jndi-name> child element to specify the JNDI name of the EJB, as shown in the
following example:
<components>
<stateless-ejb name="simpleStockQuoteBean">
<ejb-link path="stockquoteapp.jar#StockQuoteBean" />
</stateless-ejb>
</components>
z <java-class>
This element describes a Java class back-end component. Use the class-name attribute to
specify the fully qualified path name of the Java class, as shown in the following example:
<components>
<java-class name="customClass"
class-name="myclasses.MyOwnClass" />
</components>
<operation name="getQuote"
component="simpleStockQuoteBean"
method="getQuote">
<params>
<param name="in1" style="in" type="xsd:string" location="Header"/>
<param name="in2" style="in" type="xsd:int" location="Header"/>
<return-param name="result" type="xsd:string" location="Header"/>
</params>
</operation>
Typically, every instance of an <operation> element in the web-services.xml file includes
the name attribute which translates into the public name of the Web Service operation. The only
exception is when you use the method="*" attribute to specify all methods of an EJB or Java
class in a single <operation> element; in this case, the public name of the operation is the name
of the method.
Use the attributes of the <operation> element in combination to specify different kinds of
operations. For details, see “Specifying the Type of Operation” on page E-6.
Use the <params> element to optionally group together the parameters and return value of the
operation. For details, see “Specifying the Parameters and Return Value of the Operation” on
page E-8.
z To specify that an operation is implemented with just a method of a stateless session EJB,
use the name, component, and method attributes, as shown in the following example:
<operation name="getQuote"
component="simpleStockQuoteBean"
method="getQuote">
</operation>
z To specify with a single <operation> element that you want to include all the methods of
an EJB or Java class, use the method="*" attribute; in this case, the public name of the
operation is the name of the method:
<operation component="simpleStockQuoteBean"
method="*">
</operation>
z To specify that an operation only receives data and does not return anything to the client
application, add the invocation-style attribute:
<operation name="getQuote"
component="simpleStockQuoteBean"
method="getQuote(java.lang.String)"
invocation-style="one-way">
</operation>
The example also shows how to specify the full signature of a method with the method
attribute. You only need to specify the full signature of a method if your EJB or Java class
overloads the method and you thus need to unambiguously declare which method you are
exposing as a Web Service operation.
z To specify that an operation is implemented with a SOAP message handler chain and a
method of a stateless session EJB, use the name, component, method, and
handler-chain attributes:
<operation name="getQuote"
component="simpleStockQuoteBean"
method="getQuote"
handler-chain="myHandler">
</operation>
z To specify that an operation is implemented with just a SOAP message handler chain, use
just the name and handler-chain attributes:
<operation name="justHandler"
handler-chain="myHandler">
</operation>
z Make the name of the parameters and return values in the generated WSDL different from
those of the method that implements the operation.
z To specify that a parameter is a standard input parameter, located in the header of the
request SOAP message, use the style and location attributes as shown:
<param name="inparam" style="in"
location = "Header" type="xsd:string" />
z Out and in-out parameters enable an operation to return more than one return value (in
addition to using the standard <return-value> element.) The following sample <param>
element shows how to specify that a parameter is an in-out parameter, which means that it
acts as both an input and output parameter:
<param name="inoutparam" style="inout"
type="xsd:int" />
Because the default value of the location attribute is Body, both the input and output
parameter values are found in the body of the SOAP message.
z The following example shows how to specify a standard return value located in the header
of the response SOAP message:
<return-param name="result" location="Header"
type="xsd:string" />
Optionally use the <fault> child element of the <params> element to specify your own Java
exception that is thrown if there is an error while invoking the operation. This exception will be
thrown in addition to the java.rmi.RemoteException exception. For example:
<fault name="MyServiceException"
class-name="my.exceptions.MyServiceException" />
<web-services>
<web-service name="stockquotes" targetNamespace="http://example.com"
uri="/myStockQuoteService">
<components>
<stateless-ejb name="simpleStockQuoteBean">
<ejb-link path="stockquoteapp.jar#StockQuoteBean" />
</stateless-ejb>
</components>
<operations>
<operation method="getLastTradePrice"
component="simpleStockQuoteBean" />
</operations>
</web-service>
</web-services>
The example shows a Web Service called stockquotes. The Web Service is implemented with
a stateless session EJB whose <ejb-name> in the ejb-jar.xml file is StockQuoteBean and is
packaged in the EJB JAR file called stockquoteapp.jar. The internal name of this component
is simpleStockQuoteBean. The Web Service has one operation, called getLastTradePrice,
the same as the EJB method name. The input and output parameters are inferred from the method
signature and thus do not need to be explicitly specified in the web-services.xml file.
Note: The servicegen Ant task does not include the methods of EJBObject when generating
the list of operations in the web-services.xml file.
The previous example shows how to explicitly list an operation of a Web Service. You can,
however, implicitly expose all the public methods of an EJB by including just one <operation
method="*"> element, as shown in the following example:
<operations>
<operation method="*"
component="simpleStockQuoteBean" />
</operations>
If your Web Service supports only HTTPS, then use the protocol attribute of the
<web-service> element, as shown in the following example:
<web-service name="stockquotes"
targetNamespace="http://example.com"
uri="/myStockQuoteService"
protocol="https" >
...
</web-service>
For example, the following interface describes an EJB whose two methods return a TradeResult
object:
public interface Trader extends EJBObject {
public TradeResult buy (String stockSymbol, int shares)
throws RemoteException;
public TradeResult sell (String stockSymbol, int shares)
throws RemoteException;
}
public TradeResult() {}
The following web-services.xml file describes a Web Service implemented with this EJB:
<web-services>
<web-service name="TraderService"
uri="/TraderService"
targetNamespace="http://www.bea.com/examples/Trader">
<types>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:stns="java:examples.webservices"
attributeFormDefault="qualified"
elementFormDefault="qualified"
targetNamespace="java:examples.webservices">
<xsd:complexType name="TradeResult">
<xsd:sequence><xsd:element maxOccurs="1" name="stockSymbol"
type="xsd:string" minOccurs="1">
</xsd:element>
<xsd:element maxOccurs="1" name="numberTraded"
type="xsd:int" minOccurs="1">
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
</types>
<type-mapping>
<type-mapping-entry
deserializer="examples.webservices.TradeResultCodec"
serializer="examples.webservices.TradeResultCodec"
class-name="examples.webservices.TradeResult"
xmlns:p1="java:examples.webservices"
type="p1:TradeResult" >
</type-mapping-entry>
</type-mapping>
<components>
<stateless-ejb name="ejbcomp">
<ejb-link path="trader.jar#TraderService" />
</stateless-ejb>
</components>
<operations>
<operation method="*" component="ejbcomp">
</operation>
</operations>
</web-service>
</web-services>
In the example, the <types> element uses XML Schema notation to describe the XML
representation of the TradeResult data type. The <type-mapping> element contains an entry
for each data type described in the <types> element (in this case there is just one:
TradeResult.) The <type-mapping-entry> lists the serialization class that converts the data
between XML and Java, as well as the Java class file used to create the Java object.
<web-services>
<handler-chains>
<handler-chain name="submitOrderCrypto">
<handler class-name="com.example.security.EncryptDecrypt">
<init-params>
<init-param name="elementToDecrypt" value="credit-info" />
<init-param name="elementToEncrypt" value="order-number" />
</init-params>
</handler>
</handler-chain>
</handler-chains>
The Web Service defines one stateless session EJB back-end component called orderbean.
The submitOrder operation shows how to combine a handler-chain with a back-endback-end
component by specifying the method, component, and handler-chain attributes in
combination. When a client application invokes the submitOrder operation, the
submitOrderCrypto handler chain first processes the SOAP request, decrypting the credit card
information. The handler chain then invokes the submit() method of the orderbean EJB,
passing it the modified parameters from the SOAP message, including the purchase-order
input parameter. The submit() method then returns an order-number, which is encrypted by
the handler chain, and the handler chain finally sends a SOAP response with the encrypted
information to the client application that originally invoked the submitOrder operation.
<web-services>
<handler-chains>
<handler-chain name="enterWorkflowChain">
<handler class-name="com.example.WorkFlowEntry">
<init-params>
<init-param name="workflow-eng-jndi-name"
value="workflow.entry" />
</init-params>
</handler>
</handler-chain>
</handler-chains>
<web-service targetNamespace="http://example.com"
name="myworkflow" uri="myWorkflowService">
<operations xmlns:xsd="http://www.w3.org/2001/XMLSchema" >
<operation name="enterWorkflow"
handler-chain="enterWorkflowChain"
invocation-style="one-way" />
</operations>
</web-service>
</web-services>
The example shows a Web Service that includes one SOAP message handler chain, called
enterWorkflowChain. This handler chain has one handler, implemented with the Java class
com.example.WorkFlowEntry, that takes as an initialization parameter the JNDI name of the
existing workflow system.
The Web Service defines one operation called enterWorkflow. When a client application
invokes this operation, the enterWorkflowChain handler chain takes the SOAP message
request and passes it to the workflow system running on WebLogic Server whose JNDI name is
workflow.entry. The operation is defined as asynchronous one-way, which means that the
client application does not receive a SOAP response.
Note that because the enterWorkflow operation does not specify the method and component
attributes, no back-end component is ever invoked directly by the Web Service. This also means
that the web-services.xml file does not need to specify a <components> element.