WCF client to a .NET service hosted by IBM MQ sample

Sample client applications and sample service proxy applications are supplied for both .NET and Java. The samples are based on a Stock Quote service that takes a request for a stock quote and then provides the stock quote.


Before starting

The sample requires that the .NET SOAP over JMS service hosting environment is correctly installed and configured in IBM MQ and is accessible from a local queue manager.

When the .NET SOAP over JMS service hosting environment is correctly installed and configured in IBM MQ and is accessible from a local queue manager, additional configuration steps must be completed.

  1. Set the WMQSOAP_HOME environment variable to the IBM MQ installation directory, for example: C:\Program Files\IBM\MQ
  2. Ensure that the Java compiler javac is available and on the PATH.
  3. Copy the file axis.jar from the prereqs/axis directory of the WebSphere installation CD to the IBM MQ production directory, for example: C:\Program Files\IBM\MQ\java\lib\soap
  4. Add to the PATH: MQ_INSTALLATION_PATH\Java\lib where MQ_INSTALLATION_PATH represents the directory where IBM MQ is installed, for example: C:\Program Files\IBM\MQ
  5. Ensure that the location of .NET is specified correctly in MQ_INSTALLATION_PATH\bin\amqwcallWSDL.cmd where MQ_INSTALLATION_PATH represents the directory where IBM MQ is installed, for example: C:\Program Files\IBM\MQ. The location of .NET can be specified for example: set msfwdir=%ProgramFiles%\Microsoft Visual Studio .NET 2003\SDK\v1.1\Bin

When the previous steps are complete, test and run the service:

  1. Navigate to your SOAP over JMS working directory.
  2. Enter one of the following commands to run the verification test and leave the service listener running:

    • For .NET: MQ_INSTALLATION_PATH\Tools\soap\samples\runivt dotnet hold where MQ_INSTALLATION_PATH represents the directory where IBM MQ is installed.
    • For AXIS: MQ_INSTALLATION_PATH\Tools\soap\samples\runivt Dotnet2AxisClient hold where MQ_INSTALLATION_PATH represents the directory where IBM MQ is installed.

The hold argument keeps the listeners running after the test completes. If errors are reported during this configuration, we can remove all the changes so that the procedure may be restarted in the following way:

  1. Delete the generated SOAP over JMS directory.
  2. Delete the queue manager.


About this task

This sample demonstrates a connection from a WCF client to the .NET SOAP over JMS sample service provided in IBM MQ using a one-way channel shape. The service implements a simple StockQuote example, which outputs a text string to the console.

The client has been generated by using WSDL to generate client files as described in Generating a WCF client proxy and application configuration files using the svcutil tool with WSDL

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\WMQNET\default\client\app.config file, and on the service application in the MQ_INSTALLATION_PATH \tools\wcf\samples\WMQNET\default\service\WmqDefaultSample_StockQuoteDotNet.wsdl file, where MQ_INSTALLATION_PATH represents 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.


Procedure

Run the client once: Run the MQ_INSTALLATION_PATH \tools\wcf\samples\WMQNET\default\client\bin\Release\TestClient.exe file, where MQ_INSTALLATION_PATH represents the installation directory for IBM MQ. The client application loops five times sending five messages to the sample queue.


Results

The service application gets the messages from the sample queue and displays Hello World five times on the screen. Parent topic: Use the WCF samples