bea.com | products | dev2dev | support | askBEA |
|
e-docs > WebLogic Server > Programming WebLogic Web Services > Using JMS Transport to Invoke a WebLogic Web Service |
Programming WebLogic Web Services |
Using JMS Transport to Invoke a WebLogic Web Service
The following sections provide information about using JMS transport to invoke a WebLogic Web Service:
Overview of Using JMS Transport
By default, client applications use HTTP/S as the connection protocol when invoking a WebLogic Web Service. You can, however, configure your Web Service so that client applications can also use JMS as the transport when invoking the Web Service.
When a WebLogic Web Service is configured to also use JMS as the connection transport:
Note: You can use JMS transport to invoke only one-way operations.
Specifying JMS Tranport for a WebLogic Web Service: Main Steps
The following procedure assumes that you have already implemented and assembled a WebLogic Web Service and you want to update it to use JMS transport.
Note: You cannot use a JMS Server that is targeted to a Migratable Target when configuring the resources for using JMS transport when invoking a WebLogic Web Service.
Note: If you use the default connection factory, you have no control over the JMS server on which the connection factory may be deployed. If you would like to target a particular JMS server, create a new connection factory and specify the appropriate JMS server target(s).
See Invoking a Web Service Using JMS Transport for details about writing a Java client application that invokes your Web Service.
Updating the web-services.xml File
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 for more information on locating the file.
To update the web-services.xml file to specify JMS transport, follow these steps:
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>
This means that every <operation> child element of this <web-service> element must specify the invocation-style="one-way" attribute. For example:
<operation name="sendQuote"
component="simpleStockQuoteBean"
invocation-style="one-way">
</operation>
Invoking a Web Service Using JMS Transport
Invoking a WebLogic Web Service using the JMS transport is very similar to using HTTP/S, as described in Invoking Web Services, but with the following restrictions:
WL_HOME\server\lib\wlclient.jar
WL_HOME\server\lib\wljmsclient.jar
where WL_HOME refers to the main WebLogic Server installation directory.
For more information on JMS client classes, see Programming WebLogic JMS.
When writing your client appliction to invoke the JMS-transport-enabled Web Service, you first use the clientgen Ant task to generate the Web Service-specific client JAR file that contains the generated stubs, as usual. The clientgen Ant task in this case generates a JAX-RPC Service implementation of your Web Service that contains two getPort() methods: the standard one for HTTP/S, called getServiceNamePort(), and a second one for using JMS transport, called getServiceNamePortJMS(), where ServiceName refers to the name of your Web Service. These two getPort() methods correspond to the two port definitions in the generated WSDL of the Web Service, as described in Overview of Using JMS Transport.
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" );
}
}
}