Running the Web Services using HTTP nodes sample

When you import the sample you might receive several warnings in the Toolkit about attributes, CWF messages, elements, and the MRM domain. These warnings are message set related and do not affect the running of the sample.

The Web Services using HTTP nodes sample has two parts:

If you encounter any problems when you run the sample, see Resolving problems when running samples in the IBM Integration Bus documentation.

Running the Web Service Host sample

When you run the Web Service Host sample, the broker receives and sends back a SOAP/XML message, over HTTP protocol. 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 new message is sent to a legacy application by using WebSphere MQ. The legacy application responds, and data from this response is put into the HTTP reply that is generated by the broker. 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 by using the queue manager that is used by the broker and created by the Default Configuration wizard (IB9QMGR). 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 change the MQOutput to legacy node in message flow WSHOST_WSHOST1. Set the Basic property Queue Manager Name to the name of the queue manager that is used by the legacy application.

    If you want to run the legacy application on a platform other than Windows or Linux, the source files are provided in project WSHOST_LEGACY1. The C source file is legacyservice.c, with header files legacyservice.h and legacyservice2.h. Compile by using a compiler of your choice, then run the application following the preceding 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 structure is supplied in the legacyservice.h file in project WSHOST_LEGACY1. This header file also contains other structures.

  2. Put a SOAP message to the URL that is specified in the WSHOST_WSHOST1.msgflow HTTPInput node. If you do not have a utility to perform this task, several freeware tools are available for testing web services and sending SOAP messages. The sample message is in the WSHOST1IN.xml file in project WSHOST1_MFP1. If your broker is on the same machine as your HTTP utility, put the message to http://localhost:7080/samplebrokerwshost Otherwise, amend the localhost and the port number as appropriate.

    All of the test messages that are 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, the DeliveryRef field is set to blank on input, and on output is set to JOHNCORP. The Confirm field is set to blank on input, and on output is set to either Y or N, depending on whether the ItemReference input field contains the character Y.

The following code shows the response message from the preceding input message:

<?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 by using HTTP protocol. It receives a Web service reply as a SOAP/XML message, by using HTTP, and sends back a legacy reply message, by using WebSphere MQ. 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. This data is used to build a SOAP/XML message that 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. In this sample 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 it is not running on the same broker or HTTP port number, amend the local host, 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 Integration project WSCLIENT_MFP1 under Broker Archives. You might have to copy the file 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 Integration project WSHOST_MFP1. You might have 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 the Running the Web Service Host sample section of this topic.
  4. Put a message on the WebSphere MQ queue that is defined in the MQInput node, the 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 following message is sent to the Web Service Host message flow:

    <?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 following response message is received by the Web Service Client message flow for the preceding input message:

<?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 previous message in CWF format, which is based on C structure tagIA81CONF. The following information details the fields and values:

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;

Close the legacy application. You can now remove the sample from your workspace by using the Prepare the Samples wizard.

Back to sample home