Running the Web Service sample

The Web Service sample has two parts:

Running the Web Service Host sample

When you run the Web Service Host sample, the broker receives a SOAP/XML message over HTTP protocol and sends back a SOAP/XML reply message, again using HTTP. Thus the broker is acting as a Web service host.

The broker takes data from this SOAP message, and generates a new message mapped to a C header file. This is sent it to a legacy application using WebSphere MQ. The legacy application responds, and data from this response is put into the HTTP reply which the broker generates. Thus the broker has fronted a legacy application as a Web service.

To run the Web Service Host sample:

  1. Start the legacy application.

    The legacy application is written in C, and is started with two input parameters: a WebSphere MQ queue manager name and a queue name. The application reads messages from this queue and queue manager, and sends replies to the queue and queue manager specified in the reply information of the input message.

    Two executable versions of the legacy application are supplied:

    The sample is configured to run the legacy application using the same WebSphere MQ queue manager as the broker. If your broker uses a different queue manager to the legacy application, configure your WebSphere MQ queue managers (broker and legacy) for inter-communication.

    You must also make a small change to the MQOutput to legacy node in message flow WSHOST_WSHOST1. Set the Basic property Queue Manager Name to the name of the legacy application's queue manager.

    If you want to run the legacy application on a platform other than Windows or Linux, the source files are provided in project WSHOST_LEGACY. The C source file is legacyservice.c, with header files legacyservice.h and legacyservice2.h. Compile using a compiler of your choice, then run the application following the above guidelines for input parameters.

    Both the input and the output messages are mapped to the following C structure:

    typedef struct tagIA81CONF {
       char MessageId[8];
       char OrderNumber[8];
       char ItemReference[12];
       char ItemQuantity[8];
       char CustomerNumber[12];
       char DeliveryRef[8];
       char Confirm[1];
       char filler1[3];
    } IA81CONF;
    

    This is supplied in file legacyservice.h of project WSHOST_LEGACY. Note that this header file also contains other structures.

  2. Put a SOAP message to the URL specified in the HTTPInput node. If you do not have a utility to do this, there are several freeware tools available.

    All the test messages used in running this sample are based on the following format:

    <?xml version="1.0" encoding="UTF-8"?>
    <soapenv:Envelope 	xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
        xmlns:c="http://www.brokersamplewshost.ibm.com"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <soapenv:Body>
            <c:IA81CONFIN>
                <MessageId>IA81CONF</MessageId>
                <OrderNumber>ON4002</OrderNumber>
                <ItemReference>IY4003</ItemReference>
                <ItemQuantity>4</ItemQuantity>
                <CustomerNumber>CY4004</CustomerNumber>
                <DeliveryRef> </DeliveryRef>
                <Confirm> </Confirm>
                <filler1> </filler1>
            </c:IA81CONFIN>
        </soapenv:Body>
    </soapenv:Envelope>

Understanding the results

The Web Service Host sample calls a legacy application with a message called msg_tagIA81CONF. In that message, a field called DeliveryRef is set to blank on input, and on output is set to JOHNCORP. Also, a field called Confirm is set to blank on input, and on output is set to either Y or N, depending on whether input field ItemReference contains the character Y.

The response message from the above input message is as follows:

<?xml version="1.0"?>
<tns:Envelope xmlns:tns="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:NS1="http://www.brokersamplewshost.ibm.com"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <tns:Body>
        <NS1:IA81CONFOUT>
            <MessageId>IA81CONF</MessageId>
            <OrderNumber>ON4002</OrderNumber>
            <ItemReference>IY4003</ItemReference>
            <ItemQuantity>4</ItemQuantity>
            <CustomerNumber>CY4004</CustomerNumber>
            <DeliveryRef>JOHNCORP</DeliveryRef>
            <Confirm>Y</Confirm>
            <filler1>   </filler1>
        </NS1:IA81CONFOUT>
    </tns:Body>
</tns:Envelope>

Running the Web Service Client sample

When you run the Web Service Client sample, the broker receives a message in the legacy format over WebSphere MQ protocol. It calls a Web service by sending a SOAP/XML message using HTTP protocol. It receives a Web service reply as a SOAP/XML message, again using HTTP, and sends back a legacy reply message, using MQ. Thus the broker is acting as a Web service client.

The broker takes data from the legacy message, which is mapped to a C header file. Data from this is used to build a SOAP/XML message, which is mapped to the XML schema in a WSDL file. The WSDL file was supplied by a Web service host, and imported into a message set in the broker. Here, the Web service host is the Web Service Host sample.

The Web Service Host sample must be running in order to run this Web Service Client sample.

To run the Web Service Client sample:

  1. The message flow assumes the Web Service Host sample is running on the same broker as the Web Service Client sample, and that the broker is using the default HTTP port number 7080. If this is not the case, amend the localhost, the port number, or both in the HTTPRequest node of the message flow to address the Web Service Host. You must then recompile and deploy the bar file, WSCLIENT.bar, to the broker. This file is in message flow project WSCLIENT_MFP1. You might need to copy it to a domain project before you can deploy it.
  2. If you have not already done so, deploy the bar file WSHOST.bar to the broker. This file is in message flow project WSHOST_MFP1. You might need to copy it to a domain project before you can deploy it.
  3. If you have not already done so, start the legacy application that the Web Service Host sample calls (see above).
  4. Put a message on the WebSphere MQ queue that is defined in the MQInput node (queue name is WSCLIENT1_IN1).

    The input test messages used in running this sample are based on the following format:

    typedef struct tagIA81BUY {
       char MessageId[8];
       char OrderNumber[8];
       char ItemReference[12];
       char ItemQuantity[8];
       char CustomerNumber[12];
       char DeliveryRef[8];
    } IA81BUY;
    

    The message sent to the Web Service Host message flow is as follows:

    
    <?xml version="1.0"?>
    <tns:Envelope xmlns:tns="http://schemas.xmlsoap.org/soap/envelope/"
        xmlns:NS1="http://schemas.xmlsoap.org/soap/encoding/"
        xmlns:NS2="http://www.brokersamplewshost.ibm.com"
        xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        xmlns:mrm="http://tempuri.org/"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <tns:Body>
            <NS2:IA81CONFIN>
                <MessageId>IA81CONF</MessageId>
                <OrderNumber>LAB51234</OrderNumber>
                <ItemReference>ITEM12345678</ItemReference>
                <ItemQuantity>qty00005</ItemQuantity>
                <CustomerNumber>CUST34567890</CustomerNumber>
                <DeliveryRef> </DeliveryRef>
                <Confirm> </Confirm>
                <filler1> </filler1>
            </NS2:IA81CONFIN>
        </tns:Body>
    </tns:Envelope>
    

Understanding the results

The response message received by the Web Service Client message flow for the above input message is as follows:

<?xml version="1.0"?>
<tns:Envelope xmlns:tns="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:NS1="http://www.brokersamplewshost.ibm.com"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <tns:Body>
        <NS1:IA81CONFOUT>
            <MessageId>IA81CONF</MessageId>
            <OrderNumber>LAB51234</OrderNumber>
            <ItemReference>ITEM12345678</ItemReference>
            <ItemQuantity>qty00005</ItemQuantity>
            <CustomerNumber>CUST34567890</CustomerNumber>
            <DeliveryRef>JOHNCORP</DeliveryRef>
            <Confirm>N</Confirm>
            <filler1>   </filler1>
        </NS1:IA81CONFOUT>
    </tns:Body>
</tns:Envelope>

The reply message

The Web Service Client message flow outputs the above message in CWF format. This is based on C structure tagIA81CONF, defined above. The fields and values are as follows:

typedef struct tagIA81CONF {
   char MessageId[8];           IA81CONF
   char OrderNumber[8];         LAB5123
   char ItemReference[12];      ITEM12345678
   char ItemQuantity[8];        qty00005
   char CustomerNumber[12];     CUST34567890
   char DeliveryRef[8];         JOHNCORP
   char Confirm[1];             N
   char filler1[3];
} IA81CONF;

Back to sample home