![]() ![]() ![]() ![]() ![]() ![]() |
The following sections describe how to use Web Services Reliable Messaging:
Note: | Web Service Reliable Messaging relies on the asynchronous request-response feature of WebLogic Web Services. Before proceeding, you should familiarize yourself with the concepts described in Invoking a Web Service Using Asynchronous Request-Response. |
Web Service reliable messaging is a framework that enables an application running on one application server to reliably invoke a Web Service running on another application server, assuming that both servers implement the WS-ReliableMessaging specification. Reliable is defined as the ability to guarantee message delivery between the two Web Services.
Note: | Web Services reliable messaging works between any two application servers that implement the WS-ReliableMessaging specification. In this document, however, it is assumed that the two application servers are WebLogic Server instances. |
WebLogic Web Services conform to the WS-ReliableMessaging specification (June 2007), which describes how two Web Services running on different application servers can communicate reliably in the presence of failures in software components, systems, or networks. In particular, the specification describes an interoperable protocol in which a message sent from a source endpoint (or client Web Service) to a destination endpoint (or Web Service whose operations can be invoked reliably) is guaranteed either to be delivered, according to one or more delivery assurances, or to raise an error.
A reliable WebLogic Web Service provides the following delivery assurances.
Note: | Web Services reliable messaging is not supported with the JMS transport feature. |
This document describes how to create the reliable and client Web Services and how to configure the two WebLogic Server instances to which the Web Services are deployed. See the WS-ReliableMessaging specification for detailed documentation about the architecture of Web Service reliable messaging.
WebLogic Web Services use WS-Policy files to enable a destination endpoint to describe and advertise its Web Service reliable messaging capabilities and requirements. The WS-Policy files are XML files that describe features such as the version of the supported WS-ReliableMessaging specification and quality of service requirements. The WS-Policy specification provides a general purpose model and syntax to describe and communicate the policies of a Web Service.
WebLogic Server includes pre-packaged WS-Policy files that contain typical reliable messaging assertions, as described in Pre-Packaged WS-Policy Files for Reliable Messaging. If the pre-packaged WS-Policy files do not suit your needs, you must create your own WS-Policy file. See Creating the Web Service Reliable Messaging WS-Policy File for details. See “Web Service Reliable Messaging Policy Assertion Reference” in the WebLogic Web Service Reference for reference information about the reliable messaging policy assertions.
The following figure shows a one-way reliable message exchange.
A reliable message sequence is used to track the progress of a set of messages that are exchanged reliably between an RM source and RM destination. A sequence can be used to send zero or more messages, and is identified by a string identifier. This identifier is used to reference the sequence when using reliable messaging.
The Web Service client application sends a message for reliable delivery which is transmitted by the RM source to the RM destination. The RM destination acknowledges that the reliable message has been received and delivers it to the Web Service application. The message may be retransmitted by the RM source until the acknowledgement is received.
A Web Service client sends messages to a target Web Service by invoking methods on a JAX-RPC stub. The stub is associated with the port type of the reliable Web Service and represents a programmatic interface to that service. WebLogic stores the identifier for the reliable message sequence within this stub. This causes the reliable message sequence to be connected to a single JAX-RPC stub. All messages that are sent using a given stub will use the same reliable messaging sequence, regardless of the number of messages that are sent using the stub. The JAX-RPC stub is created by the <clientgen>
child element of the
jwsc
Ant task.
Because WebLogic Server retains resources associated with the reliable sequence, it is recommended that you take steps to release these resources in a timely fashion. WebLogic Server provides a utility class,
weblogic.wsee.reliability.WsrmUtils
, for use with the Web Service reliable messaging. Use this class to perform common tasks such as set configuration options, get the sequence id, and terminate a reliable sequence.
Under normal circumstances, a reliable sequence should be retained until all messages have been sent and acknowledged by the RM destination. To facilitate the timely and proper termination of a sequence, it is recommended that you identify the final message in a reliable message sequence. Doing so indicates you are done sending messages to the RM destination and that WebLogic Server can begin looking for the final acknowledgement before automatically terminating the reliable sequence. Indicate the final message using the weblogic.wsee.reliability.WsrmUtils
.setFinalMessage()
method, passing the JAX-RPC stub being used to send messages to the RM destination.
When you identify a final message, after all messages up to and including the final message are acknowledged, the reliable message sequence is terminated, and all resources are released. Otherwise, the sequence is terminated automatically after the configured sequence expiration period is reached.
Although not recommended, you can terminate the sequence reliable message sequence regardless of whether all messages have been acknowledged using the terminateSequence()
method. Once issued, no further reliable messages can be sent on this stub.
Note: | The JAX-RPC stub is not fully initialized until shortly after the first method is invoked on the reliable Web Service. When the first method is invoked, the RM source sends a CreateSequence() message to the RM destination requesting that the RM destination create and register the reliable sequence. The RM destination, at some later time, responds with the ID for the newly created sequence. Until this response ID is received, the RM source cannot have any further communication with the RM destination and the JAX-RPC stub representing the target service at the RM destination cannot be used. |
Note: | You cannot perform operations on the reliable message sequence until it is fully initialized; otherwise an error is returned. Use the weblogic.wsee.reliability.WsrmUtils .waitForSequenceInitialization() method to monitor whether or not the reliable message sequence has been initialized. Once the reliable sequence is initialized, this method returns the ID of the sequence. |
For more information about the WsrmUtils
utility class, see the
weblogic.wsee.reliability.WsrmUtils
Javadocs.
Configuring reliable messaging for a WebLogic Web Service requires standard JMS tasks such as creating JMS servers and Store and Forward (SAF) agents, as well as Web Service-specific tasks, such as adding additional JWS annotations to your JWS file. Optionally, you create WS-Policy files that describe the reliable messaging capabilities of the reliable Web Service if you do not use the pre-packaged ones.
If you are using the WebLogic client APIs to invoke a reliable Web Service, the client application must run on WebLogic Server. Thus, configuration tasks must be performed on both the source WebLogic Server instance on which the Web Service that includes client code to invoke the reliable Web Service reliably is deployed, as well as the destination WebLogic Server instance on which the reliable Web Service itself is deployed.
The following table summarizes the steps to create a reliable Web Service, as well as a client Web Service that invokes an operation of the reliable Web Service. The procedure describes how to create the JWS files that implement the two Web Services from scratch; if you want to update existing JWS files, use this procedure as a guide. The procedure also describes how to configure the source and destination WebLogic Server instances.
You will deploy the reliable Web Service to the destination WebLogic Server instance. For information about configuring the destination WebLogic Server instance, see Configuring the Destination WebLogic Server Instance.
You will deploy the client Web Service that invokes the reliable Web Service to the source WebLogic Server instance. For information about configuring the source WebLogic Server instance, see Configuring the Source WebLogic Server Instance.
|
||
Using your favorite XML or plain text editor, optionally create a WS-Policy file that describes the reliable messaging capabilities of the Web Service running on the destination WebLogic Server. For details about creating your own WS-Policy file, see Creating the Web Service Reliable Messaging WS-Policy File.
This step is not required if you plan to use one of the WS-Policy files that are included in WebLogic Server; see Pre-Packaged WS-Policy Files for Reliable Messaging for more information.
|
||
This Web Service will be deployed to the destination WebLogic Server instance. See Programming Guidelines for the Reliable JWS File.
|
||
Update your
build.xml file to include a call to the jwsc Ant task which will compile the reliable JWS file into a Web Service.
See
“Running the jwsc WebLogic Web Services Ant Task” in Getting Started With WebLogic Web Services Using JAX-RPC for general information about using the
jwsc task.
|
||
Configure the reliable messaging options for the reliable Web Service using the Administration Console. See Configuring Reliable Messaging for a Reliable Web Service.
|
||
This service invokes the reliable Web Service and will be deployed to the source WebLogic Server. See Programming Guidelines for the JWS File That Invokes a Reliable Web Service.
|
||
Each of these steps is described in more detail in the following sections.
In addition, the following advanced topics are discussed:
xs:base64Binary
in SOAP messagesIt is assumed that you have completed the following tasks:
build.xml
files that you can edit, for example, to add targets for running the jwsc
Ant task and deploying the generated reliable Web Service. For more information, see “Developing WebLogic Web Services” in Getting Started With WebLogic Web Servers Using JAX-RPC.
To configure the WebLogic Server instance on which the reliable Web Service is deployed, configure the JMS and store and forward (SAF) resources.
You can configure these resources manually or you can use the Configuration Wizard to extend the WebLogic Server domain using a Web Services-specific extension template. Using the Configuration Wizard greatly simplifies the required configuration steps; for details, see “Configuring Your Domain For Web Services Features” in Getting Started With WebLogic Web Services Using JAX-RPC.
Note: | Alternatively, you can use WLST to configure the resources. For information about using WLST to extend the domain, see “Configuring Existing Domains” in WebLogic Scripting Tool. |
If you prefer to configure the resources manually, perform the following steps.
See
“Invoking the Administration Console” in Getting Started With WebLogic Web Services Using JAX-RPC.
|
||
Optionally create a persistent store (file or JDBC) that will be used by the destination WebLogic Server to store internal Web Service reliable messaging information. You can use an existing one, or the default store that always exists, if you do not want to create a new one.
See
“Create file stores” in the Administration Console Online Help.
|
||
Create a JMS Server. If a JMS server already exists, you can use it if you do not want to create a new one.
See
“Create JMS servers” in the Administration Console Online Help.
|
||
Create a JMS module, and then define a JMS queue in the module. If a JMS module already exists, you can use it if you do not want to create a new one. Target the JMS queue to the JMS server you created in the preceding step. Be sure you specify that this JMS queue is local, typically by setting the local JNDI name.
Take note of the JNDI name you define for the JMS queue because you will later use it when you program the JWS file that implements your reliable Web Service.
See
“Create JMS system modules” and
“Create queues in a system module” in the Administration Console Online Help.
|
||
See
“Create Store-and-Forward agents” in the Administration Console Online Help.
|
||
Review
“Tuning Heavily Loaded Systems to Improve Web Service Performance” in WebLogic Server Performance and Tuning.
|
Configuring the WebLogic Server instance on which the client Web Service is deployed involves configuring JMS and store and forward (SAF) resources.
You can configure these resources manually or you can use the Configuration Wizard to extend the WebLogic Server domain using a Web Services-specific extension template. Using the Configuration Wizard greatly simplifies the required configuration steps; for details, see “Configuring Your Domain For Web Services Features” in Getting Started With WebLogic Web Services Using JAX-RPC.
Note: | Alternatively, you can use WLST to configure the resources. For information about using WLST to extend the domain, see “Configuring Existing Domains” in WebLogic Scripting Tool. |
If you prefer to configure the resources manually, perform the following steps.
See
“Invoking the Administration Console” in Getting Started With WebLogic Web Services Using JAX-RPC.
|
||
Optionally create a persistent store (file or JDBC) that will be used by the source WebLogic Server to store internal Web Service reliable messaging information. You can use an existing one, or the default store that always exists, if you do not want to create a new one.
See
“Create file stores” in the Administration Console Online Help.
|
||
When you create the SAF agent, set the Agent Type field to
Both to enable both sending and receiving agents.
See
“Create Store-and-Forward agents” in the Administration Console Online Help.
|
||
Review
“Tuning Heavily Loaded Systems to Improve Web Service Performance” in WebLogic Server Performance and Tuning.
|
A WS-Policy file is an XML file that contains policy assertions that comply with the WS-Policy specification. In this case, the WS-Policy file contains Web Service reliable messaging policy assertions.
WebLogic Server includes pre-packaged WS-Policy files that contain typical reliable messaging assertions that you can use if you do not want to create your own WS-Policy file. The pre-packaged WS-Policy files are listed in the following table.
Note: | The DefaultReliability.xml and LongRunningReliability.xml files are deprecated in this release. Use of the DefaultReliability1.1.xml , Reliability1.1_SequenceTransportSecurity , or Reliability1.0_1.1.xml file is recommended and required to comply with the 1.1 version of the
WS-ReliableMessaging specification. |
Specifies policy assertions related to quality of service. The Web Service reliable messaging assertions are based on
WS Reliable Messaging Policy Assertion 1.1. See DefaultReliability1.1.xml WS-Policy File.
|
|
Specifies policy assertions related to transport-level security and quality of service. The Web Service reliable messaging assertions are based on
WS Reliable Messaging Policy Assertion 1.1. See Reliability1.1_SequenceTransportSecurity.xml WS-Policy File.
|
|
Combines
1.1 and
1.0 WS Reliable Messaging policy assertions. This sample relies on smart policy selection to determine the policy assertion that is applied at runtime. See Reliability1.0_1.1.xml WS-Policy.xml File
|
|
Deprecated. The Web Service reliable messaging assertions are based on
WS Reliable Messaging Policy Assertion Version 1.0.In this release, many of the reliable messaging policy assertions are managed through JWS annotations or configuration.
Specifies typical values for the reliable messaging policy assertions, such as inactivity timeout of 10 minutes, acknowledgement interval of 200 milliseconds, and base retransmission interval of 3 seconds. See DefaultReliability.xml WS-Policy File (Deprecated).
|
|
Deprecated. The Web Service reliable messaging assertions are based on
WS Reliable Messaging Policy Assertion Version 1.0 for long running processes. In this release, many of the reliable messaging policy assertions are managed through JWS annotations or configuration.
Similar to the preceding default reliable messaging WS-Policy file, except that it specifies a much longer activity timeout interval (24 hours.) See LongRunningReliability.xml WS-Policy File (Deprecated).
|
You can use one of the pre-packaged reliable messaging WS-Policy files included in WebLogic Server; these files are adequate for most use cases. You cannot modify the pre-packaged files. If the values do not suit your needs, you must create a custom WS-Policy file. The following sections describe how to create a custom WS-Policy file.
This section describes how to create a custom WS-Policy file that contains Web Service reliable messaging assertions that are based on WS Reliable Messaging Policy Assertion Version 1.1. In the current release, many of the reliable messaging policy assertions are managed through JWS annotations or configuration.
The root element of the WS-Policy file is <Policy>
and it should include the following namespace declaration:
<wsp:Policy
xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
You wrap all Web Service reliable messaging policy assertions inside of a <wsrmp:RMAssertion>
element. This element should include the following namespace declaration for using Web Service reliable messaging policy assertions:
<wsrmp:RMAssertion
xmlns:wsrmp="http://docs.oasis-open.org/ws-rx/wsrmp/200702">
The following table lists the Web Service reliable messaging assertions that you can specify in the WS-Policy file. The order in which the assertions appear is important. You can specify the following assertions; the order they appear in the following list is the order in which they should appear in your WS-Policy file:
The following example shows a simple Web Service reliable messaging WS-Policy file:
<?xml version="1.0"?>
<wsp:Policy xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
<wsrmp:RMAssertion
xmlns:wsrmp="http://docs.oasis-open.org/ws-rx/wsrmp/200702">
<wsrmp:SequenceTransportSecurity/>
<wsrmp:DeliveryAssurance>
<wsp:Policy>
<wsrmp:ExactlyOnce/>
</wsp:Policy>
</wsrmp:DeliveryAssurance>
</wsrmp:RMAssertion>
</wsp:Policy>
For more information about Reliable Messaging policy assertions in the WS-Policy file, see “Web Service Reliable Messaging Policy Assertion Reference” in WebLogic Web Services Reference.
This section describes how to create a custom WS-Policy file that contains Web Service reliable messaging assertions that are based on WS Reliable Messaging Policy Assertion Version 1.0.
Note: | In the current release, many of the reliable messaging policy assertions are managed through JWS annotations or configuration. |
The root element of the WS-Policy file is <Policy>
and it should include the following namespace declarations for using Web Service reliable messaging policy assertions:
<wsp:Policy
xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm"
xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
xmlns:beapolicy="http://www.bea.com/wsrm/policy">
You wrap all Web Service reliable messaging policy assertions inside of a <wsrm:RMAssertion>
element. The assertions that use the wsrm:
namespace are standard ones defined by the
WS-ReliableMessaging specification. The assertions that use the beapolicy:
namespace are WebLogic-specific. See
“Web Service Reliable Messaging Policy Assertion Reference” in the WebLogic Web Services Reference for details.
The following table lists the Web Service reliable messaging assertions that you can specify in the WS-Policy file. All Web Service reliable messaging assertions are optional, so only set those whose default values are not adequate. The order in which the assertions appear is important. You can specify the following assertions; the order they appear in the following list is the order in which they should appear in your WS-Policy file,
Number of milliseconds, specified with the
Milliseconds attribute, which defines an inactivity interval. After this amount of time, if the destination endpoint has not received a message from the source endpoint, the destination endpoint may consider the sequence to have terminated due to inactivity. The same is true for the source endpoint. By default, sequences never timeout.
|
|
Amount of time after which the reliable Web Service expires and does not accept any new sequence messages. The default value is to never expire. This element has a single attribute,
Expires , whose data type is an
XML Schema duration type. For example, if you want to set the expiration time to one day, use the following: <beapolicy:Expires Expires="P1D" /> .
|
|
Delivery assurance level, as described in Table 3-1. The element has one attribute,
QOS , which you set to one of the following values: AtMostOnce , AtLeastOnce , or ExactlyOnce . You can also include the InOrder string to specify that the messages be in order. The default value is ExactlyOnce InOrder . This element is typically not set.
|
The following example shows a simple Web Service reliable messaging WS-Policy file:
<?xml version="1.0"?>
<wsp:Policy
xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm/policy"
xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
xmlns:beapolicy="http://www.bea.com/wsrm/policy"
>
<wsrm:RMAssertion>
<wsrm:InactivityTimeout
Milliseconds="600000" />
<wsrm:BaseRetransmissionInterval
Milliseconds="500" />
<wsrm:ExponentialBackoff />
<wsrm:AcknowledgementInterval
Milliseconds="2000" />
</wsrm:RMAssertion>
</wsp:Policy>
For more information about Reliable Messaging policy assertions in the WS-Policy file, see “Web Service Reliable Messaging Policy Assertion Reference” in WebLogic Web Services Reference.
You can configure multiple policy alternatives—also referred to as smart policy alternatives—for a single Web Service by creating a custom policy file. At runtime, WebLogic Server selects which of the configured policies to apply. It excludes policies that are not supported or have conflicting assertions and selects the appropriate policy, based on your configured preferences, to verify incoming messages and build the response messages.
The following example provides an example of a security policy that supports both
1.1 and
1.0 WS-Reliable Messaging. Each policy alternative is enclosed in a <wsp:All>
element.
Note: | The 1.0 Web Service reliable messaging assertions are prefixed by wsrmp10 . |
<wsp:Policy xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
<wsp:ExactlyOne>
<wsp:All>
<wsrmp10:RMAssertion
xmlns:wsrmp10="http://schemas.xmlsoap.org/ws/2005/02/rm/policy">
<wsrmp10:InactivityTimeout Milliseconds="1200000"/>
<wsrmp10:BaseRetransmissionInterval Milliseconds="60000"/>
<wsrmp10:ExponentialBackoff/>
<wsrmp10:AcknowledgementInterval Milliseconds="800"/>
</wsrmp10:RMAssertion>
</wsp:All>
<wsp:All>
<wsrmp:RMAssertion
xmlns:wsrmp="http://docs.oasis-open.org/ws-rx/wsrmp/200702">
<wsrmp:SequenceSTR/>
<wsrmp:DeliveryAssurance>
<wsp:Policy>
<wsrmp:AtMostOnce/>
</wsp:Policy>
</wsrmp:DeliveryAssurance>
</wsrmp:RMAssertion>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
For more information about multiple policy alternatives, see “Smart Policy Selection” in “Configuring Message-Level Security” in Securing WebLogic Web Services.
This section describes how to create the JWS file that implements the reliable Web Service.
The following JWS annotations are used in the JWS file that implements a reliable Web Service.
Required. Specifies that the Web Service has a WS-Policy file attached to it that contains reliable messaging assertions. See Using the @Policy Annotation.
|
|
Required only if you invoke the reliable Web Service operation synchronously (that is, you are not using the asynchronous request-response feature). See Using the @Oneway Annotation.
|
|
Optional. Specifies the JNDI name of the JMS queue which WebLogic Server uses to store reliable messages internally. See Using the @BufferQueue Annotation.
|
|
Optional. Specifies the number of times WebLogic Server should attempt to deliver the message from the JMS queue to the Web Service implementation and the amount of time that the server should wait in between retries. See Using the @ReliabilityBuffer Annotation
|
The following example shows a simple JWS file that implements a reliable Web Service; see the explanation after the example for coding guidelines that correspond to the Java code in bold.
package examples.webservices.reliable;
import javax.jws.WebMethod;
import javax.jws.WebService;import javax.jws.Oneway;
import weblogic.jws.WLHttpTransport;
import weblogic.jws.ReliabilityBuffer;
import weblogic.jws.BufferQueue;
import weblogic.jws.Policy;
/**
* Simple reliable Web Service.
*/
@WebService(name="ReliableHelloWorldPortType",
serviceName="ReliableHelloWorldService")
@WLHttpTransport(contextPath="ReliableHelloWorld",
serviceUri="ReliableHelloWorld",
portName="ReliableHelloWorldServicePort")
@Policy(uri="ReliableHelloWorldPolicy.xml",
direction=Policy.Direction.both,
attachToWsdl=true)
@BufferQueue(name="webservices.reliable.queue")
public class ReliableHelloWorldImpl {
@WebMethod()@Oneway()
@ReliabilityBuffer(retryCount=10, retryDelay="10 seconds")
public void helloWorld(String input) {
System.out.println(" Hello World " + input);
}
}
In the example, the ReliableHelloWorldPolicy.xml
file is attached to the Web Service at the class level, which means that the policy file is applied to all public operations of the Web Service. The policy file is applied only to the request Web Service message (as required by the reliable messaging feature) and it is attached to the WSDL file.
The JMS queue that WebLogic Server uses internally to enable the Web Service reliable messaging has a JNDI name of webservices.reliable.queue
, as specified by the @BufferQueue
annotation.
The helloWorld()
method has been marked with both the @WebMethod
and @Oneway
JWS annotations, which means it is a public operation called helloWorld
. Because of the @Policy
annotation, the operation can be invoked reliably. The Web Services runtime attempts to deliver reliable messages to the service a maximum of 10 times, at 10-second intervals, as described by the @ReliabilityBuffer
annotation. The message may require re-delivery if, for example, the transaction is rolled back or otherwise does not commit.
Use the @Policy
annotation in your JWS file to specify that the Web Service has a WS-Policy file attached to it that contains reliable messaging assertions. WebLogic Server delivers a set of pre-packaged WS-Policy files, as described in Pre-Packaged WS-Policy Files for Reliable Messaging.
Follow the following guidelines when using the @Policy
annotation for Web Service reliable messaging:
uri
attribute to specify the build-time location of the policy file, as follows:@Policy(uri="ReliableHelloWorldPolicy.xml",
direction=Policy.Direction.both,
attachToWsdl=true)
In this example, the ReliableHelloWorldPolicy.xml
file is located in the same directory as the JWS file.
policy:
prefix along with the name and path of the policy file. This syntax tells the jwsc
Ant task at build-time not to look for an actual file on the file system, but rather, that the Web Service will retrieve the WS-Policy file from WebLogic Server at the time the service is deployed.Note: | Shared Java EE libraries are useful when you want to share a WS-Policy file with multiple Web Services that are packaged in different Enterprise applications. As long as the WS-Policy file is located in the META-INF/policies or WEB-INF/policies directory of the shared Java EE library, you can specify the policy file in the same way as if it were packaged in the same archive at the Web Service. See
“Creating Shared Java EE Libraries and Optional Packages” in Developing Applications With WebLogic Server for information about creating libraries and setting up your environment so the Web Service can locate the policy files. |
http:
prefix along with the URL, as shown in the following example:@Policy(uri="http://someSite.com/policies/mypolicy.xml"
direction=Policy.Direction.both,
attachToWsdl=true)
direction
attribute by setting the attribute to Policy.Direction.inbound
or Policy.Direction.outbound
.wsp:optional
attribute within the policy file specified by uri
.
If the optional
attribute is set to false
for outbound on any operation, then:
<wsrm: Offer...>
as described in the
WS-ReliableMessaging specification) for use when sending reliable responses.
If the optional
attribute is set to true
for outbound on all operations, then:
attachToWsdl
attribute of the @Policy
annotation to specify whether the policy file should be attached to the WSDL file that describes the public contract of the Web Service. Typically, you want to publicly publish the policy so that client applications know the reliable messaging capabilities of the Web Service. For this reason, the default value of this attribute is true
.
For more information about the @Policy
annotation, see
“weblogic.jws.Policy” in WebLogic Web Services Reference.
If you plan on invoking the reliable Web Service operation synchronously (or in other words, not using the asynchronous request-response feature), then you must annotate the implementing method with the @Oneway
annotation to specify that the method is one-way. This means that the method cannot return a value, but rather, must explicitly return void
.
Conversely, if the method is not annotated with the @Oneway
annotation, then you must invoke it using the asynchronous request-response feature. If you are unsure how the operation is going to be invoked, consider creating two flavors of the operation: synchronous and asynchronous.
See Invoking a Web Service Using Asynchronous Request-Response, and Using the Asynchronous Features Together.
Use the @BufferQueue
annotation to specify the JNDI name of the JMS queue which WebLogic Server uses to store reliable messages internally. The JNDI name is the one you configured when creating a JMS queue in step 4 in Configuring the Destination WebLogic Server Instance.
The @BufferQueue
annotation is optional; if you do not specify it in your JWS file then WebLogic Server uses a queue with a JNDI name of weblogic.wsee.DefaultQueue
. You must, however, still explicitly create a JMS queue with this JNDI name using the Administration Console.
For more information about the @BufferQueue
annotation, see
“weblogic.jws.BufferQueue” in WebLogic Web Services Reference.
Use the @ReliabilityBuffer
annotation to specify the number of times WebLogic Server should attempt to deliver the message from the JMS queue to the Web Service implementation and the amount of time that the server should wait in between retries.
Use the retryCount
attribute to specify the number of retries and the retryDelay
attribute to specify the wait time. The format of the retryDelay
attribute is a number and then one of the following strings:
For example, to specify a retry count of 20 and a retry delay of two days, use the following syntax:
@ReliabilityBuffer(retryCount=20, retryDelay="2 days")
The retry count and delay default to 3 and 5 seconds, respectively.
For more information about the @ReliabilityBuffer
annotation, see
“weblogic.jws.ReliabilityBuffer” in WebLogic Web Services Reference.
If necessary, you can edit the reliable message configuration options for a reliable Web Service that are stored in the weblogic-webservices.xml
descriptor by updating the application deployment plan. The deployment plan associates new values with specific locations in the descriptors for your application. At deployment time, a deployment plan is merged with the descriptors in the application by applying the values in its variable assignments to the locations in the application descriptors to which the variables are linked.
The following table summarizes the reliable messaging options that can be configured for the reliable Web Service. For more information, see “Web Service Reliable Messaging” in the Administration Console Online Help.
You can set the reliable messaging configuration options using the Administration Console or WLST, as described in the following sections.
To use the Administration Console to update an application’s deployment plan and configure reliable messaging, access the reliable messaging configuration options for a reliable Web Service in the Deployments table under the Configuration > Port Components tabs. For information about invoking the Administration Console and accessing the Web Service deployments, see “Invoking the Administration Console” in Getting Started With WebLogic Web Services Using JAX-RPC.
For a complete description and example of using WLST to update an application’s deployment plan to configure reliable messaging, see “Updating a Deployment Plan” in WebLogic Scripting Tool.
For your reference, the following table summarizes the XPath values for the WS-RM configuration options.
If you are using the WebLogic client APIs, you must invoke a reliable Web Service from within a Web Service; you cannot invoke a reliable Web Service from a stand-alone client application.
The following example shows a simple JWS file for a Web Service that invokes a reliable operation from the service described in Programming Guidelines for the Reliable JWS File.
package examples.webservices.reliable;
import java.rmi.RemoteException;
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.xml.rpc.Stub;
import weblogic.jws.WLHttpTransport;import weblogic.jws.ServiceClient;
import weblogic.jws.ReliabilityErrorHandler;
import examples.webservices.reliable.ReliableHelloWorldPortType;
import weblogic.wsee.reliability.ReliabilityErrorContext;
import weblogic.wsee.reliability.ReliableDeliveryException;
import weblogic.wsee.reliability.WsrmUtils;
@WebService(name="ReliableClientPortType",
serviceName="ReliableClientService")
@WLHttpTransport(contextPath="ReliableClient",
serviceUri="ReliableClient",
portName="ReliableClientServicePort")
public class ReliableClientImpl
{
@ServiceClient(
serviceName="ReliableHelloWorldService",
portName="ReliableHelloWorldServicePort")
private ReliableHelloWorldPortType port;
@WebMethod
public void callHelloWorld(String input, String serviceUrl)
throws RemoteException {
((Stub)port)._setProperty(Stub.ENDPOINT_ADDRESS_PROPERTY, serviceUrl);
WsrmUtils.setFinalMessage((Stub)port);port.helloWorld(input);
System.out.println(" Invoked the ReliableHelloWorld.helloWorld operation reliably." );
}
@ReliabilityErrorHandler(target="port")
public void onReliableMessageDeliveryError(ReliabilityErrorContext ctx) {
ReliableDeliveryException fault = ctx.getFault();
String message = null;
if (fault != null) {
message = ctx.getFault().getMessage();
}
String operation = ctx.getOperationName();
System.out.println("Reliable operation " + operation + " may have not invoked. The error message is " + message);
}
}
As illustrated in the previous examples (in bold text), follow these guidelines when programming the JWS file that invokes a reliable Web Service:
@ServiceClient
and @ReliabitliyErrorHandler
JWS annotations:import weblogic.jws.ServiceClient;
import weblogic.jws.ReliabilityErrorHandler;
<clientgen>
child element of the jwsc
Ant task, of the port type of the reliable Web Service you want to invoke. The stub package is specified by the packageName
attribute of <clientgen>
, and the name of the stub is determined by the WSDL of the invoked Web Service.import examples.webservices.reliable.ReliableHelloWorldPortType;
import weblogic.wsee.reliability.ReliabilityErrorContext;
import weblogic.wsee.reliability.ReliableDeliveryException;
import javax.xml.rpc.Stub;
import weblogic.wsee.reliability.WsrmUtils;
@ServiceClient
JWS annotation to specify the name and port of the reliable Web Service you want to invoke. You specify this annotation at the field-level on a private variable, whose data type is the JAX-RPC port type of the Web Service you are invoking. @ServiceClient(
serviceName="ReliableHelloWorldService",
portName="ReliableHelloWorldServicePort")
private ReliableHelloWorldPortType port;
port._setProperty
method to dynamically specify the target service endpoint address within the Web Service client. For more information, see
“Accessing Runtime Information About a Web Service” in Getting Started With WebLogic Web Services Using JAX-RPC.((Stub)port)._setProperty(Stub.ENDPOINT_ADDRESS_PROPERTY, serviceUrl);
setFinalMessage
method specifies that this is the final message to be sent on this sequence. This will allow the reliable messaging subsystem to proactively clean up the reliable sequence instead of timing out.WsrmUtils.setFinalMessage((Stub)port);
@ServiceClient
annotation, invoke the reliable operation:port.helloWorld(input);
Because the operation has been marked one-way, it does not return a value.
@weblogic.jws.ReliabilityErrorHandler
annotation:@ReliabilityErrorHandler(target="port")
public void onReliableMessageDeliveryError(ReliabilityErrorContext ctx) {
ReliableDeliveryException fault = ctx.getFault();
String message = null;
if (fault != null) {
message = ctx.getFault().getMessage();
}
String operation = ctx.getOperationName();
System.out.println("Reliable operation " + operation + " may have not invoked. The error message is " + message);
}
This method takes ReliabilityErrorContext
as its single parameter and returns void
.
See
"weblogic.jws.ReliabilityErrorHandler"
in the WebLogic Web Services Reference for details about programming this error-handling method.
When programming the client Web Service:
@ReliabilityErrorHandler
) or use any reliable messaging assertions in the associated WS-Policy files.wsdlLocation
attribute of the @ServiceClient
annotation. This is because the runtime retrieval of the specified WSDL might not succeed; therefore, it is better for WebLogic Server to use a local WSDL file instead.
To update a build.xml
file to generate the JWS file that invokes the operation of a reliable Web Service, add taskdefs
and a build-reliable-client
targets similar to the following:
<taskdef name="jwsc"
classname="weblogic.wsee.tools.anttasks.JwscTask" />
<target name="build-reliable-client">
<jwsc
enableAsyncService="true"
srcdir="src"
destdir="${client-ear-dir}" >
<jws file="examples/webservices/reliable/ReliableClientImpl.java">
<clientgen
wsdl="http://${wls.destination.host}:${wls.destination.port}/ReliableHelloWorld/ReliableHelloWorld?WSDL"
packageName="examples.webservices.reliable"/>
</jws>
</jwsc>
</target>
Use the taskdef
Ant task to define the full classname of the jwsc
Ant tasks.
Update the jwsc
Ant task that compiles the client Web Service to include a <clientgen>
child element of the <jws>
element so as to generate and compile the JAX-RPC stubs for the deployed ReliableHelloWorld
Web Service. The jwsc
Ant task automatically packages them in the generated WAR file so that the client Web Service can immediately access the stubs. You do this because the ReliableClientImpl
JWS file imports and uses one of the generated classes.
The following example shows a simple JWS file that implements a reliable Web Service and uses MTOM/XOP to optimize the transmission of XML data of type xs:base64Binary
in SOAP messages; see the explanation after the example for coding guidelines that correspond to the Java code in bold. This example builds on the example provided in Programming Guidelines for the JWS File That Invokes a Reliable Web Service.
package examples.webservices.reliable;
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.Oneway;
import weblogic.jws.WLHttpTransport;
import weblogic.jws.ReliabilityBuffer;
import weblogic.jws.BufferQueue;
import weblogic.jws.Policy;import weblogic.jws.Policies;
/**
* Simple reliable Web Service.
*/
@WebService(name="ReliableHelloWorldPortType",
serviceName="ReliableHelloWorldService")
@WLHttpTransport(contextPath="ReliableHelloWorld",
serviceUri="ReliableHelloWorld",
portName="ReliableHelloWorldServicePort")
@Policies({@Policy(uri="ReliableHelloWorldPolicy.xml",
direction=Policy.Direction.both,
attachToWsdl=true),
@Policy(uri = "policy:Mtom.xml")})
@BufferQueue(name="webservices.reliable.queue")
public class ReliableHelloWorldImpl {
@WebMethod()
@Oneway()
@ReliabilityBuffer(retryCount=10, retryDelay="10 seconds")
public void helloWorld(String input) {
System.out.println(" Hello World " + input);
}
@WebMethod
public byte[] echoBinary(byte[] bytes) {
return bytes;
}
}
As illustrated in the previous example (in bold text), follow these guidelines when programming the JWS file that invokes a reliable Web Service with MTOM:
@weblogic.jws.Policy
annotation to specify that the pre-packaged Mtom.xml
file should be applied to your Web Service. Use the
@weblogic.jws.Policies
annotation to group multiple WS-Policy files, including the reliable messaging policy file and the MTOM policy file. @Policies({@Policy(uri="ReliableHelloWorldPolicy.xml",
direction=Policy.Direction.both,
attachToWsdl=true),
@Policy(uri = "policy:Mtom.xml")})
byte[]
data type in your Web Service operations as either a return value or input parameter whenever you want the resulting SOAP message to use MTOM/XOP to send or receive the binary data. public byte[] echoBinary(byte[] bytes) {
return bytes;
}
Note: | In this release of WebLogic Server, the only supported Java data type when using MTOM/XOP is byte[] ; other binary data types, such as image , are not supported. |
WebLogic Server supports production redeployment, which means that you can deploy a new version of an updated reliable WebLogic Web Service alongside an older version of the same Web Service.
WebLogic Server automatically manages client connections so that only new client requests are directed to the new version. Clients already connected to the Web Service during the redeployment continue to use the older version of the service until they complete their work, at which point WebLogic Server automatically retires the older Web Service. If the client is connected to a reliable Web Service, its work is considered complete when the existing reliable message sequence is explicitly ended by the client or as a result of a timeout.
For additional information about production redployment and Web Service clients, see “Client Considerations When Redeploying a Web Service” in Getting Started With WebLogic Web Services Using JAX-RPC.
Client applications that invoke reliable Web Services might not invoke the operation directly, but rather, use a proxy server. Reasons for using a proxy include the presence of a firewall or the deployment of the invoked Web Service to a cluster.
In this case, the WebLogic Server instance that hosts the invoked Web Service must be configured with the address and port of the proxy server. If your Web Service is deployed to a cluster, you must configure every server in the cluster.
This procedure describes how to create a network channel, the primary configurable WebLogic Server resource for managing network connection. Network channels enable you to provide a consistent way to access the front-end address of a cluster. For more information about network channels, see “Understanding Network Channels” in Configuring Server Environments.
weblogic-wsee-proxy-channel-
XXX
, where XXX
refers to the protocol. For example, to create a network channel for HTTPS, call it weblogic-wsee-proxy-channel-https
. See “Configure custom network channels” in the Administration Console Online Help for general information about creating a network channel.
-Dweblogic.wsee.skip.async.response=true
Java system property.By default, every WebLogic Server instance deploys an internal asynchronous Web Service that handles the asynchronous request-response feature. If you do not specify this system property, asynchronous messages will never get to the cluster, as required, because the asynchronous service on the proxy server will consume them instead.
![]() ![]() ![]() |