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 you begin
This sample requires that the following IBM MQ configuration is used: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.
Table 1. IBM MQ required configuration Object Required name Queue manager QM1 Local queue HelloWorld Local queue HelloWorldReply After the WAS environment is configured, the following additional configuration steps must be completed:
When the WAS configuration is complete, test the service by running it once:
- Create the following JNDI objects in the WebSphere Application Server JNDI repository:
- A JMS queue destination called HelloWorld
- Set the JNDI name to jms/HelloWorld
- Set the queue name to HelloWorld
- A JMS queue connection factory called HelloWorldQCF
- Set the JNDI name to jms/HelloWorldQCF
- Set the queue manager name to QM1
- A JMS queue connection factory called WebServicesReplyQCF
- Set the JNDI name to jms/WebServicesReplyQCF
- Set the queue manager name to QM1
- 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
- Install the web service HelloWorldEJBEAR.ear application to your WebSphere Application Server as follows:
- Click Applications > New Application > New Enterprise Application.
- Navigate to MQ_INSTALLATION_PATH\tools\wcf\samples\WAS\HelloWorldsEJBEAR.ear where MQ_INSTALLATION_PATH is the installation directory of IBM MQ.
- Do not change any of the default option in the wizard, and restart the application server after the application has been installed.
- Navigate to your Soap over JMS working directory.
- 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. If you need to change the resource names, then you 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. For more information about formatting the JMS endpoint URI, see URI syntax and parameters for web service deployment.
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 http://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.