8-6 Programming Advanced Features of JAX-RPC Web Services for Oracle WebLogic Server
8.5 Using the WLJmsTransport JWS Annotation
If you know at the time that you program the JWS file that you want client applications to use JMS transport instead of HTTPS to invoke the Web service, you
can use the WLJmsTransport to specify the details of the invocation. Later, at build-time, you can override the invocation defined in the JWS file and add additional
JMS transport specifications, by specifying the WLJmsTransport child element of the jwsc Ant task, as described in
Section 8.6, Using the WLJmsTransport Child Element of the jwsc Ant Task
. Follow these guidelines when using the WLJmsTranport annotation:
■
You can include only one WLJmsTransport annotation in a JWS file.
■
Use the queue attribute to specify the JNDI name of the JMS queue you configured earlier in the section. If you want to use the default Web services queue
weblogic.wsee.DefaultQueue then you do not have to specify the queue attribute.
■
Use the connectionFactory attribute to specify the JNDI name of the connection factory. The default value of this attribute is the default JMS connection
factory for your WebLogic Server instance.
The following example shows a simple JWS file that uses the WLJmsTransport annotation, with the relevant code in bold:
package examples.webservices.jmstransport; import javax.jws.WebMethod;
import javax.jws.WebService; import javax.jws.soap.SOAPBinding;
import weblogic.jws.WLJmsTransport;
WebServicename=JMSTransportPortType, 3
Create a JMS Server. 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 Oracle WebLogic Server Administration Console Help.
4 Create JMS module and
define queue. 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. See Create JMS system modules and Create queues in a system
module in Oracle WebLogic Server Administration Console Help.
If you want the JMS transport Web service to use the default Web services queue, set the JNDI name of the JMS queue to
weblogic.wsee.DefaultQueue . Otherwise, if you use a different JNDI
name, be sure to specify the queue name when specifying the WLJmsTransport
annotation or WLJmsTransport child element of the jwsc Ant task.
Clustering Considerations:
If you are using the Web service JMS transport feature in a cluster, you must:
■
Create a local JMS queue, rather than a distributed queue, when creating the JMS queue.
■
Explicitly target this JMS queue to each server in the cluster.
Table 8–3 Cont. Steps to Configure Host WebLogic Server Instance Manually for the JMS Transport Web
Step Description
Using JMS Transport as the Connection Protocol 8-7
serviceName=JMSTransportService, targetNamespace=http:example.org
SOAPBindingstyle=SOAPBinding.Style.DOCUMENT, use=SOAPBinding.Use.LITERAL,
parameterStyle=SOAPBinding.ParameterStyle.WRAPPED
WebLogic-specific JWS annotation that specifies the context path and service URI used to build the URI of the Web Service is
transportsJMSTransport
WLJmsTransportcontextPath=transports, serviceUri=JMSTransport, queue=JMSTransportQueue, portName=JMSTransportServicePort,
connectionFactory=JMSTransportConnectionFactory
This JWS file forms the basis of simple Java-class implemented WebLogic Web Service with a single operation: sayHello
public class JMSTransportImpl { WebMethod
public String sayHelloString message { System.out.printlnsayHello: + message;
return Here is the message: + message + ; }
}
8.6 Using the WLJmsTransport Child Element of the jwsc Ant Task