Simple request-reply client and server WCF sample

This sample demonstrates the IBM MQ custom channel being used to start a Windows Communication foundation (WCF) service from a WCF client using a request-reply channel shape.


This service provides some simple calculator methods to add and subtract two numbers, and then return the result. 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 in the following procedure described. For to change the resource names, then you also need to change the corresponding value on the client application in the MQ_INSTALLATION_PATH \Tools\wcf\samples\WCF\requestreply\client\app.config file, and on the service application in the MQ_INSTALLATION_PATH \Tools\wcf\samples\WCF\requestreply\service\RequestReplyService.cs file, where MQ_INSTALLATION_PATH is the installation directory for IBM MQ. For more information about formatting the JMS endpoint URI, see IBM MQ Transport for SOAP in the IBM MQ product documentation. For to modify the sample solution and source, then we need an IDE, for example, Microsoft Visual Studio 8 or higher.


Procedure

  1. Create a queue manager called QM1
  2. Create a queue destination called SampleQ
  3. Create a queue destination called SampleReplyQ
  4. Start the service so the listener is waiting for messages: Run the MQ_INSTALLATION_PATH \Tools\wcf\samples\WCF\requestreply\service\bin\Release\SimpleRequestReply_Service.exe file, where MQ_INSTALLATION_PATH is the installation directory for IBM MQ.
  5. Run the client once: Run the MQ_INSTALLATION_PATH \Tools\wcf\samples\WCF\requestreply\client\bin\Release\SimpleRequestReply_Client.exe file, where MQ_INSTALLATION_PATH is the installation directory for IBM MQ.


Results

When the client has been run, the following process is started and repeats four times so a total of five messages are sent each way:
  1. The client puts a request message on SampleQ and waits for a response.
  2. The service gets the request message from SampleQ.
  3. The service adds and subtracts some values using the contents of the message.
  4. The service then puts the results into a message on SampleReplyQ, and waits for the client to put a new message.
  5. The client gets the message from SampleReplyQ and displays the results on the screen.


What to do next

Parent topic: Use the WCF samples