Building the Web Services using HTTP nodes sample

The Web Services using HTTP nodes sample has two parts:

Building the Web Service Host sample

All the files that are required to run the Web Service Host sample are supplied, but if you prefer to create the sample yourself, you can use the following instructions:

To build the Web Service Host sample:

  1. Import the Web Service sample so that the C header file is available for you to use, see Web Services using HTTP nodes sample.
  2. Create a message set to serve both the Web service format message (XML) and the legacy format (CWF):
    1. Start the IBM Integration Toolkit.
    2. Click File > New > Message Set.
    3. In the Message set name field, enter the name WSHOST_BUILD_MS1.
    4. In the Message set project name field, enter the name WSHOST_BUILD_MSP1, click Next.
    5. In the Select the type of message data that you will be working with most often field, select XML documents (general), select Binary data (for example, C or COBOL structures), click Finish.
    6. On the messageSet.mset tab, under Properties Hierarchy, right-click Binary1, select Rename and enter the new name CWF1, click Finish.
    7. Save and close messageSet.mset.
  3. Import a C header file, which maps to the input and output message of the legacy application:
    1. In the Application Development view, copy the legacyservice.h file from project WSHOST_LEGACY1, and paste it into project WSHOST_BUILD_MSP1.
    2. Create a message definition file from the C header file:
      1. In the Application Development view, under WSHOST_BUILD_MSP1, right-click legacyservice.h, click New > Message Definition File From > C Header File, click Next.
      2. Ensure that the Message set field is set to /WSHOST_BUILD_MSP1/WSHOST_BUILD_MS1.
      3. Set Target namespace to http://www.brokersamplewshost.ibm.com, click Next.
      4. In the Source structures pane, click tagIA81CONF, click the right-arrow (>) button, click Select all > Finish.
    3. In the legacyservice.mxsd pane, expand and right-click Messages. Select Add Message. Enter IA81CONFIN, click Complex Type, select tns:tagIA81CONF from the list. Repeat this step for IA81CONFOUT.
    4. Save and close legacyservice.mxsd.
  4. Build a SOAP message definition:
    1. In the Application Development view, right-click message set WSHOST_BUILD_MS1 which you have already created, then click New > Message Definition File From > IBM Supplied Message.
    2. In the IBM supplied messages pane, select SOAP 1.1 Envelope, click Finish.
    3. Save and close soapenv11.mxsd.

      Several warnings are shown in the Problems view of the IBM Integration Toolkit. These problems are caused by having a CWF defined for a SOAP message definition. You can ignore the warnings.

  5. Generate WSDL:
    1. In the Application Development view, right-click message set WSHOST_BUILD_MS1, select Generate > WSDL Definition.
    2. Select Generate a new WSDL definition from existing message definitions, click Next.
    3. Highlight WSHOST_BUILD_MSP1, click Create New Folder.
    4. Type wsdl as the folder name, click OK, click Next.
    5. In the "Specify WSDL details pane", ensure that Style is set to document, click Next.
    6. In the Operations pane, from the list select IA81CONFIN for Input, and IA81CONFOUT for Output, click Next.
    7. In the Bindings pane, select the SOAP/HTTP radio button and set Port Address to http://localhost:7080/samplebrokerwshost, click Finish.
  6. Create a message flow. The flow takes a HTTP request, runs the legacy application by using WebSphere MQ, and routes information from the legacy application's response to the HTTP requester.

    To create the message flow:

    1. Click File > New > Integration project.
    2. Set Project name to WSHOST_BUILD_MFP1, click Next.
    3. In the "Referenced projects" pane, select the WSHOST_BUILD_MSP1 check box, click Finish.
    4. In the Application Development view, right-click WSHOST_BUILD_MFP1, click New > Message Flow.
    5. Set Message flow name to WSHOST_WSHOST1.
    6. Clear Use default broker schema.
    7. Set Schema to WSHOST_MFP1, click Finish.
    8. In the Message Flow editor, add and rename the nodes listed in the following table.
      For instructions, see Adding a node in the IBM Integration Bus documentation.
      Palette drawers Node type Node name
      HTTP HTTPInput HTTP Input
      Transformation Compute Compute
      Transformation Compute Compute1
      Transformation Compute Compute2
      WebSphere MQ MQOutput MQOutput to legacy
      WebSphere MQ MQOutput MQOutput store HTTP state
      WebSphere MQ MQGet MQGet stored HTTP state
      WebSphere MQ MQInput MQInput from legacy
      HTTP HTTPReply HTTPReply
    9. Connect the nodes together as shown in the following table.
      For instructions, see Connecting nodes in the IBM Integration Bus documentation.
      Node name Terminal Connect to this node
      HTTPInput Out Compute
      Compute Out MQOutput to legacy
      MQOutput to legacy Out Compute1
      Compute1 Out MQOutput store HTTP state
      MQInput from legacy Out MQGet stored HTTP state
      MQGet stored HTTP state Out Compute2
      Compute2 Out HTTPReply
  7. Customize the HTTPInput node:
    1. Right-click the HTTPInput node, and click Properties.
    2. Click Basic, and set Path suffix for URL to /samplebrokerwshost.
    3. Click Input Message Parsing:
      • For Message domain, select MRM from the list.
      • For Message set, select WSHOST_BUILD_MS1 from the list.
      • For Message type, select Envelope.
      • For Message format, select XML1 from the list.
    4. Save and close the Properties view.
  8. Customize the Compute node:
    1. Right-click the Compute node, and click Open ESQL.
    2. Type the following ESQL between the BEGIN and END statements for the Main() function. Use Content Assist (Ctrl + space) to select keywords. DECLARE NAMESPACE statements similar to the statements that are commented on the first two lines are generated when you use Content Assist for the first time to select the SOAP Body element and any IA81CONFIN elements. If you are copying and pasting this code, ensure that you uncomment the DECLARE NAMESPACE statements.
      --DECLARE tns NAMESPACE 'http://schemas.xmlsoap.org/soap/envelope/';
      --DECLARE ns NAMESPACE 'http://www.brokersamplewshost.ibm.com';
      
      	CALL CopyMessageHeaders();
      
      -- Output is MQ, so remove HTTP headers
      	SET OutputRoot.HTTPInputHeader = null;
      
      -- Output is legacy, so set wire format and message name
      	SET OutputRoot.Properties.MessageType = 'msg_tagIA81CONF';
      	SET OutputRoot.Properties.MessageFormat = 'CWF1';
      
      -- Add an MQMD
      	CREATE NEXTSIBLING OF OutputRoot.Properties DOMAIN 'MQMD';
      
      -- Build message to be sent to legacy
      	SET OutputRoot.MRM.MessageId
      	    = InputBody.tns:Body.ns:IA81CONFIN.MessageId;
      	SET OutputRoot.MRM.OrderNumber
          	= InputBody.tns:Body.ns:IA81CONFIN.OrderNumber;
      	SET OutputRoot.MRM.ItemReference
          	= InputBody.tns:Body.ns:IA81CONFIN.ItemReference;
      	SET OutputRoot.MRM.ItemQuantity
          	= InputBody.tns:Body.ns:IA81CONFIN.ItemQuantity;
      	SET OutputRoot.MRM.CustomerNumber
          	= InputBody.tns:Body.ns:IA81CONFIN.CustomerNumber;
      	SET OutputRoot.MRM.DeliveryRef 
          	= InputBody.tns:Body.ns:IA81CONFIN.DeliveryRef;
      	SET OutputRoot.MRM.Confirm 
          	= InputBody.tns:Body.ns:IA81CONFIN.Confirm;
      	SET OutputRoot.MRM.filler1 
          	= InputBody.tns:Body.ns:IA81CONFIN.filler1;
      
      	RETURN TRUE;
    3. Save and close the WSHOST_WSHOST1.esql tab.
  9. Customize the MQOutput to legacy node:
    1. Right-click the MQOutput to legacy node, click Properties.
    2. If you intend to run the legacy application on a different WebSphere MQ queue manager to the broker, select Basic, and set Queue manager name to the name of your legacy application's queue manager. Otherwise, leave it blank.
    3. Set Queue name to WSHOST1_OUT1.
    4. Click Advanced, set Transaction mode to Yes.
    5. Set Message context to Default.
    6. Click Request, and select Request.
    7. Set Reply-to queue to WSHOST1_IN1, then save and close the Properties view.
  10. Customize the Compute1 node:
    1. Right-click the Compute1 node, click Open ESQL.
    2. Code the following ESQL between the BEGIN and END statements for the Main() function. Use Content Assist (Ctrl + space) to select keywords. A DECLARE NAMESPACE statement similar to the statement that is commented on the first line is generated when Content Assist is used for the first time to select the SOAP Body element. Ensure that you uncomment the DECLARE NAMESPACE statements.
      --DECLARE tns NAMESPACE 'http://schemas.xmlsoap.org/soap/envelope/';
      --DECLARE ns NAMESPACE 'http://www.brokersamplewshost.ibm.com';
      
      -- The output message built in this node stores the HTTP context.
      -- Any format may be suitable, but we are using a
      -- self-defined field in a SOAP Header to do this
      -- So the wire format is XML
      -- Create the target message set properties
      
      	SET OutputRoot.Properties.MessageSet = InputRoot.Properties.MessageSet;
      	SET OutputRoot.Properties.MessageType = 'Envelope';
      	SET OutputRoot.Properties.MessageFormat = 'XML1';
      
      -- Create the MQMD and set the CorrelId
      -- The CorrelId needs to be set to the MsgId of the message sent
      -- to the legacy application.  When the reply from the legacy
      -- application is received, we will MQGet from the store
      -- queue with correlid equal to the correlid of the legacy reply
      
      	SET OutputRoot.MQMD.CorrelId
      = InputLocalEnvironment.WrittenDestination.MQ.DestinationData.msgId;
      
      -- Build message to store HTTP context
      
      	SET OutputRoot.MRM.tns:Header.HTTP.RequestIdentifier
          = InputLocalEnvironment.Destination.HTTP.RequestIdentifier;
      
      	RETURN TRUE;
    3. Save and close the WSHOST_WSHOST1.esql tab.
  11. Customize the MQOutput store HTTP state node:
    1. Right-click the MQOutput store HTTP state node, and click Properties.
    2. Click Basic, and set Queue manager name to WSHOST1_STATE1.
    3. Click Advanced and set Transaction mode to Yes.
    4. Set Message context to Default.
    5. Save and close the Properties view.
  12. Customize the MQInput from legacy node:
    1. Right-click the MQInput from legacy node, and click Properties.
    2. Click Basic, and set Queue name to WSHOST1_IN1.
    3. Click Input Message Parsing:
      • For Message domain, select MRM from the list.
      • For Message set, select WSHOST_BUILD_MS1 from the list.
      • For Message type, select msg_tagIA81CONF.
      • For Message format, select CWF1 from the list.
    4. Save and close the Properties view.
  13. Customize the MQGet stored HTTP state node:
    1. Right-click the MQGet stored HTTP node, and click Properties.
    2. Click Basic, and set Queue name to WSHOST1_STATE1.
    3. Click Input Message Parsing:
      • For Message domain, select MRM from the list.
      • For Message set, select WSHOST_BUILD_MS1 from the list.
      • For Message type, enter Envelope.
      • For Message format, select XML1 from the list.
    4. Click Advanced:
      • For Generate mode, select Message and LocalEnvironment from the list.
      • For Copy message, select Copy Entire Message from the list.
    5. Click Request, and select the check box for Get by correlation ID.
    6. Click Result, and set Output data location to OutputLocalEnvironment.
    7. Save and close the Properties view.
  14. Customize the Compute2 node:
    1. Right-click the Compute2 node, and click Properties.
    2. Click Basic, and set Compute mode to LocalEnvironment and Message.
    3. Save and close the Properties view.
    4. Right-click the node, and click Open ESQL.
    5. Type the following ESQL between the BEGIN and END statements for the Main() function, ensure that you uncomment the DECLARE NAMESPACE statements:
      --DECLARE tns NAMESPACE 'http://schemas.xmlsoap.org/soap/envelope/';
      --DECLARE ns NAMESPACE 'http://www.brokersamplewshost.ibm.com';
      
      -- Input is CWF, output is SOAP/XML
      	SET OutputRoot.Properties.MessageSet = InputRoot.Properties.MessageSet;
      	SET OutputRoot.Properties.MessageType = 'Envelope';
      	SET OutputRoot.Properties.MessageFormat = 'XML1';
      	SET OutputRoot.MRM.tns:Body.ns:IA81CONFOUT = InputRoot.MRM;
      
      -- Set the http reply identifier
      	SET OutputLocalEnvironment.Destination.HTTP.RequestIdentifier =
       CAST(InputLocalEnvironment.MRM.tns:Header.HTTP.RequestIdentifier AS BLOB);
      	
      	RETURN TRUE;
  15. Save and close the WSHOST_WSHOST1.esql tab.
  16. Save and close WSHOST_WSHOST1.msgflow.
  17. If you intend to run the legacy application on a different WebSphere MQ queue manager to the broker, define the legacy application's input queue to the legacy application's queue manager. Use the appropriate WebSphere MQ utility to enter the following queue definition:

    DEFINE QLOCAL(WSHOST1_OUT1) REPLACE

Building the Web Service Client sample

All the files that you need to run the Web Service Client sample are supplied, but if you prefer to create the sample yourself, complete the following steps:

To build the Web Service Client sample:

  1. Import the Web Service sample from the Samples Gallery, and build the Web Service Host sample if you have not already done so, so that the C header file is available for you to use, see Web Services using HTTP nodes sample. Create a message set to serve both the Web service format message (XML) and the legacy format (CWF).
    1. Start the IBM Integration Toolkit.
    2. Click File > New > Message Set.
    3. Set Message set name to WSCLIENT_MS1.
    4. Set Message set project name to WSCLIENT_BUILD_MSP1, then click Next.
    5. In the Select the type of message data that you will be working with most often field, select XML documents (general), select Binary data (for example, C or COBOL structures), click Finish.
    6. On the messageSet.mset tab, under Properties Hierarchy, right-click Binary1, select Rename and enter the new name CWF1, click Finish.
    7. Save and close messageSet.mset.
  2. Import a C header file which maps the input and output message of the legacy application:
    1. Copy file legacyservice.h from project WSHOST_LEGACY1, and paste it into project WSCLIENT_BUILD_MSP1.
    2. Create a message definition file from the C header file:
      1. In the Application Development view, under WSCLIENT_BUILD_MSP1, right-click legacyservice.h, then click New > Message Definition File From > C Header File.
      2. Ensure Message set is set to /WSCLIENT_BUILD_MSP1/WSCLIENT_MS1, click Next.
      3. In the "Source structures" pane, click tagIA81BUY, click the right-arrow (>) button, click tagIA81CONF, click the right-arrow (>) button, then click Select all > Finish.
    3. Save and close legacyservice.mxsd.
  3. Import the WSDL for the Web service.
    1. Click File > Import > General > File System > Next.
    2. Browse in your workspace to select the wsdl directory in the WSHOST_MSP1 project, click OK, select the wsdl check box.
    3. Set Into folder to WSCLIENT_MSP1, click Finish.
    4. Create a message definition file from the WSDL:
      1. In the Application Development view, in project WSCLIENT_MSP1 right-click WSHOST_BUILD_MS1Service.wsdl, click New > Message Definition File.
      2. For Select the target message set select WSCLIENT_MSP1/WSCLIENT_MS1.
      3. Set Message definition file name to WSHOST_BUILD_MS1Service.wsdl.
      4. Under Target Namespace Settings select the Use target namespace check box. Set Prefix to wshost and Namespace to http://www.brokersamplewshost.ibm.com/.
      5. Click Finish.
  4. Create a message flow. The flow takes a HTTP request, runs the legacy application by using WebSphere MQ, and routes information from the legacy application's response to the HTTP requestor.

    To create the message flow:

    1. Click File > New > Integration project.
    2. Set Project name to WSCLIENT_BUILD_MFP1, click Next.
    3. In the "Referenced projects" pane, select the WSCLIENT_BUILD_MSP1 check box, click Finish.
    4. In the Application Development view, right-click WSCLIENT_BUILD_MFP1, click New > Message Flow.
    5. Set Message flow name to WSCLIENT_WSCLIENT1.
    6. Clear the check box for Use broker default schema, set Schema to WSCLIENT_MFP1, click Finish.
    7. In the Message Flow editor, add and rename the nodes listed in the following table.
      For instructions, see Adding a node in the IBM Integration Bus documentation..
      Palette drawers Node type Node name
      WebSphere MQ MQInput MQInput from legacy
      Transformation Compute Compute
      Transformation Compute Compute1
      WebSphere MQ MQReply MQReply
      HTTP HTTPRequest HTTPRequest
    8. Connect the nodes together as shown in the following table.
      For instructions, see Connecting nodes in the IBM Integration Bus documentation..
      Node name Terminal Connect to this node
      MQInput from legacy Out Compute
      Compute Out HTTPRequest
      HTTPRequest Out Compute1
      Compute1 Out MQReply
  5. Customize the MQInput from legacy node:
    1. Right-click the MQInput from legacy node, and click Properties.
    2. Click Basic, and set Queue name to WSCLIENT1_IN1.
    3. Click Input Message Parsing :
      • For Message domain, select MRM from the list.
      • For Message set, select WSCLIENT_MS1 from the list.
      • For Message type, select msg_tagIA81BUY from the list.
      • For Message format, select CWF1 from the list.
    4. Save and close the Properties view.
  6. Customize the Compute node:
    1. Right-click the Compute node, and click Open ESQL.
    2. Type the following ESQL between the BEGIN and END statements for the Main() function. Use Content Assist (Ctrl + space) to select keywords. DECLARE NAMESPACE statements similar to the statements that are commented on the first two lines are generated when you use Content Assist for the first time to select the SOAP Body element and any IA81CONFIN elements. If you are copying and pasting this code, ensure that you uncomment the DECLARE NAMESPACE statements.
      --DECLARE tns NAMESPACE 'http://schemas.xmlsoap.org/soap/envelope/';
      --DECLARE ns NAMESPACE 'http://www.brokersamplewshost.ibm.com';
      
          CALL CopyMessageHeaders();
      
      -- Save the MQMD; sending to HTTP later in the flow destroys it
      	SET Environment.MQMD = InputRoot.MQMD;
          
      -- Input is CWF, Output is SOAP, so set wire format and message name
      	SET OutputRoot.Properties.MessageType = 'Envelope';
      	SET OutputRoot.Properties.MessageFormat = 'XML1';
      
      -- Build message to be sent to web service
      	SET OutputRoot.MRM.tns:Body.ns:IA81CONFIN.MessageId = 'IA81CONF';
      	SET OutputRoot.MRM.tns:Body.ns:IA81CONFIN.OrderNumber = InputBody.OrderNumber;
      	SET OutputRoot.MRM.tns:Body.ns:IA81CONFIN.ItemReference = InputBody.ItemReference;
      	SET OutputRoot.MRM.tns:Body.ns:IA81CONFIN.ItemQuantity = InputBody.ItemQuantity;
      	SET OutputRoot.MRM.tns:Body.ns:IA81CONFIN.CustomerNumber = InputBody.CustomerNumber;
      	SET OutputRoot.MRM.tns:Body.ns:IA81CONFIN.DeliveryRef = ' ';
      	SET OutputRoot.MRM.tns:Body.ns:IA81CONFIN.Confirm = ' ';
      	SET OutputRoot.MRM.tns:Body.ns:IA81CONFIN.filler1 = ' ';
      
      	RETURN TRUE;
    3. Save and close the WSCLIENT_WSCLIENT1.esql tab.
  7. Customize the HTTPRequest node:
    1. Right-click the HTTPRequest node, and click the Properties view.
    2. Select Basic, and set Web service URL to http://localhost:7080/samplebrokerwshost. If the broker hosting the Web service is on a different machine to this broker, or is using a non-default port number, or both, amend this URL as appropriate.
    3. Click Response Message Parsing:
      • For Message domain, select MRM from the list.
      • For Message set, select WSCLIENT_MS1 from the list.
      • For Message type, type Envelope.
      • For Message format, select XML1 from the list.
    4. Save and close the Properties view.
  8. Customize the Compute1 node:
    1. Right-click the Compute1 node, and click Open ESQL.
    2. Type the following ESQL between the BEGIN and END statements for the Main() function. Use Content Assist (Ctrl + space) to select keywords. A DECLARE NAMESPACE statement similar to that commented on the first line is generated when Content Assist is used for the first time to select the SOAP Body element. Ensure that you uncomment the DECLARE NAMESPACE statements.
      --DECLARE tns NAMESPACE 'http://schemas.xmlsoap.org/soap/envelope/';
      --DECLARE ns NAMESPACE 'http://www.brokersamplewshost.ibm.com';
      
          CALL CopyMessageHeaders();
      
      -- Output is MQ, so remove HTTP headers
          SET OutputRoot.HTTPResponseHeader = NULL;
              
      -- Output is CWF, so set the target message set properties
      
      	SET OutputRoot.Properties.MessageType = 'msg_tagIA81CONF';
      	SET OutputRoot.Properties.MessageFormat = 'CWF1';
      
      -- Create an MQMD and restore it to the saved values
      
      	CREATE NEXTSIBLING OF OutputRoot.Properties DOMAIN 'MQMD';
          SET OutputRoot.MQMD = Environment.MQMD;
      
      -- Build message to be sent
      
      	SET OutputRoot.MRM.MessageId = InputBody.tns:Body.ns:IA81CONFOUT.MessageId;
      	SET OutputRoot.MRM.OrderNumber = InputBody.tns:Body.ns:IA81CONFOUT.OrderNumber;
      	SET OutputRoot.MRM.ItemReference = InputBody.tns:Body.ns:IA81CONFOUT.ItemReference;
      	SET OutputRoot.MRM.ItemQuantity = InputBody.tns:Body.ns:IA81CONFOUT.ItemQuantity;
      	SET OutputRoot.MRM.CustomerNumber = InputBody.tns:Body.ns:IA81CONFOUT.CustomerNumber;
      	SET OutputRoot.MRM.DeliveryRef = InputBody.tns:Body.ns:IA81CONFOUT.DeliveryRef;
      	SET OutputRoot.MRM.Confirm = InputBody.tns:Body.ns:IA81CONFOUT.Confirm;						
      	SET OutputRoot.MRM.filler1 = InputBody.tns:Body.ns:IA81CONFOUT.filler1;	
      
      	RETURN TRUE;
  9. Save and close the WSCLIENT_WSCLIENT1.esql tab.
  10. Customize the MQReply node: no customization is required.
  11. Save and close WSCLIENT_WSCLIENT1.msgflow.

Back to sample home