Skip navigation.
Downloads | Product Documentation | Support

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
- Specifying JMS Transport for a WebLogic Web Service: Main Steps
- Updating the web-services.xml File to Specify JMS Transport
- Invoking a Web Service Using JMS Transport

# 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 a WebLogic 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 use JMS as the connection transport:

- 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.

- 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.

# Specifying JMS Transport for a WebLogic Web Service: Main Steps

In the following procedure, it is assumed that you are familiar with the `servicegen` Ant task and you want to update the Web Service to use JMS transport. For an example of using `servicegen`, see Creating a WebLogic Web Service: A Simple Example.

Some of the main steps include configuring JMS resources using the Administration Console.

1. Invoke the Administration Console to in your browser, as described in Overview of Administering 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.

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.

4. Redeploy the Web Service.

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 to Specify JMS Transport

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:

1. Open the file in your favorite editor.
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>

# 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 from Client Applications and WebLogic Server, but with a few differences, as described in the following procedure.

1. Re-run the `clientgen` Ant task.

Because the WSDL of the Web Service has been updated to include an additional port with a JMS binding, the `clientgen` Ant task automatically creates new stubs that contains these JMS-specific `getPortXXX()` methods.

For details, see Generating the Client JAR File by Running the clientgen Ant Task.

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

where `WL_HOME` refers to the main WebLogic Server installation directory.

For more information on JMS client JAR files, see Programming WebLogic JMS.

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 `get` `ServiceName` `Port()`; the new method to use the JMS transport is called `get` `ServiceName` `PortJMS()`, 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.

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" );
>         }
>       }
>     }