+

Search Tips | Advanced Search

WCF client to Java service hosted by WebSphere Application Server sample

Sample client applications and sample service proxy applications are supplied for WebSphere Application Server Version 6. A request-response service is also provided.


Before starting

This sample requires that the following IBM MQ configuration is used:

Object Required name
Queue manager QM1
Local queue HelloWorld
Local queue HelloWorldReply
This sample also requires that a WebSphere Application Server Version 6 hosting environment is correctly installed and configured. WebSphere Application Server Version 6 uses a bindings mode connection to connect to IBM MQ by default. Therefore WebSphere Application Server Version 6 must be installed on the same machine as the queue manager.

After the WAS environment is configured, the following additional configuration steps must be completed:

  1. Create the following JNDI objects in the WebSphere Application Server JNDI repository:
    1. A JMS queue destination called HelloWorld

      • Set the JNDI name to jms/HelloWorld
      • Set the queue name to HelloWorld

    2. A JMS queue connection factory called HelloWorldQCF

      • Set the JNDI name to jms/HelloWorldQCF
      • Set the queue manager name to QM1

    3. A JMS queue connection factory called WebServicesReplyQCF

      • Set the JNDI name to jms/WebServicesReplyQCF
      • Set the queue manager name to QM1

  2. Create a Message Listener Port called HelloWorldPort in WebSphere Application Server with the following configuration:

    • Set the connection factory JNDI name to jms/HelloWorldQCF
    • Set the destination JNDI name to jms/HelloWorld

  3. Install the web service HelloWorldEJBEAR.ear application to your WebSphere Application Server as follows:
    1. Click Applications > New Application > New Enterprise Application.
    2. Navigate to MQ_INSTALLATION_PATH\tools\wcf\samples\WAS\HelloWorldsEJBEAR.ear where MQ_INSTALLATION_PATH is the installation directory of IBM MQ.
    3. Do not change any of the default option in the wizard, and restart the application server after the application has been installed.

When the WAS configuration is complete, test the service by running it once:

  1. Navigate to your Soap over JMS working directory.
  2. Enter this command to run the sample: MQ_INSTALLATION_PATH \tools\wcf\samples\WAS\TestClient.exe where MQ_INSTALLATION_PATH is the installation directory of IBM MQ.


The sample demonstrates a connection from a WCF client to the WebSphere Application Server SOAP over JMS sample service provided in the WCF samples included in IBM MQ, using a request-response channel shape. Messages flow between WCF and the WebSphere Application Server using IBM MQ queues. The service implements the HelloWorld(...) method, which takes a string and returns a greeting to the client.

The client has been generated by using the svcutil tool to retrieve the service metadata from a separately exposed HTTP endpoint as described in Generating a WCF client proxy and application configuration files using the svcutil tool with metadata from a running service

The sample has been configured with specific resource names as described in the following procedure. For to change the resource names, then we must also change the corresponding value on the client application in the MQ_INSTALLATION_PATH \tools\wcf\samples\WAS\default\client\app.config file, and on the service application in the MQ_INSTALLATION_PATH \tools\wcf\samples\WAS\HelloWorldsEJBEAR.ear where MQ_INSTALLATION_PATH is the installation directory of IBM MQ.

The service and client are based upon the service and client outlined in the IBM Developer article Building a JMS web service using SOAP over JMS and WebSphere Studio. For more information about developing SOAP over JMS web services that are compatible with the IBM MQ WCF custom channel, see https://www.ibm.com/developerworks/websphere/library/techarticles/0402_du/0402_du.html.


Procedure

Run the client once: Run the MQ_INSTALLATION_PATH \tools\wcf\samples\WAS\default\client\bin\Release\TestClient.exe file, where MQ_INSTALLATION_PATH is the installation directory for IBM MQ. The client application starts both of the service methods at the same time, sending two messages to the sample queue.


Results

The service application gets the messages from the sample queue and provides a response to the HelloWorld(...) method call which the client application outputs to the console. Parent topic: Use the WCF samples

Last updated: 2020-10-04