IBM BPM, V8.0.1, All platforms > Create processes in IBM Process Designer > Modeling processes > Integrating with web services, Java and databases > Web services compatibility

Use a SOAP connector to call a web service

Once you know the web service works, you should test it from within Process Designer.

These steps show you how to test your web service.

You can see the following steps with screen captures from a previous version in this technote.


Procedure

  1. Create a new Integration Service. Select Implementation > +. From the menu, select Implementation Service.

  2. In the dialog that opens, enter a name and click Finish.
  3. Beneath TOOLKITS, expand SystemData and select Implementation. Locate the Call WebService via SOAP component and drag it onto the diagram.

  4. Drag a Server Scriplet from the right-side palette to your diagram. Place it to the left of Call WebService via SOAP.
  5. Connect the lines. Start should connect to the Untitled server scriptlet. The Untitled server scriptlet should connect to Call WebService via SOAP. Call WebService via SOAP should connect to End.

  6. Select the Call WebService via SOAP component. Select the Data Mapping tab in the Properties view.

    You should be able to identify all of the inputs required except for the request input.

    • wsdlURL maps to the URL address.
    • serviceNS maps to the targetNamespace value.
    • serviceName maps to the service name value.
    • destinationAddress maps to the soap:address location value.
    • soapAction maps to the soap:operation soapAction value.

  7. The request input includes your variable inputs. In this example, we use the server scriptlet to create the XML input.

    1. Open the variables tab and create a new private variable called request with an XMLElement type.
    2. Return to the diagram view and rename the server scriptlet to Set Request.

    3. Select the Implementation tab from the Properties view for the server scriptlet and bind the implementation to your request variable. Click Select and click the request variable from the menu.

    4. Copy your entire XML input from soapUI and paste it into the server scriptlet implementation.
    5. Bind your request variable to the request input of the SOAP Connector. Return to the Data Mapping section of the Call Web Service via SOAP component and, using Select, map request (XMLElement) to the request variable you just created.

  8. In a similar manner, create a variable called response of type XMLElement, and bind it to the output of the SOAP Connector; that is, the Call Web Service via SOAP component. At this point, you should be able to test your service using hard-coded values.

  9. Run the service in debug mode to see the response placed into your response variable. If it worked correctly, you are ready to add input variables to your service and map them into your request variable in the server scriptlet. The following example only has one input:

    1. Add an input variable to your service.

    2. Use <#= #> notation to include JavaScript in your server scriptlet.

      For example if your input variable was degreesF. the implementation code referring to it would be <# = tw.local.degreesF #>. Now your service input will determine the input to the SOAP Connector.

  10. Use Xpath to map your response variable into proper outputs. This example uses a single output variable (_degreesC).

    1. Add a Server Script to the end of your service

    2. Use Xpath to map the XML response into the output variables.

      For example:

      1. This Xpath expression returns a node list of all 'Page' nodes until the VisioDocument/Pages node:

        xml.xpath("VisioDocument/Pages/Page");

        You might need to experiment with having or not having a slash at the beginning depending on the structure of the XML.

      2. This Xpath expression returns a node list of all 'Master' nodes that have the NameU attribute equal to 'Horizontal holder':

        xml.xpath("VisioDocument/Masters/Master[@NameU='Horizontal holder']");

      3. In either case, you need to know the node path and namespace. The following Xpath expression ignores the depth and ignores namespaces. It is the same as i, except it ignores namespace and depth of 'Page' node:

        xml.xpath = "//*[local-name()='Page']";

        In any case, the result is a nodelist that can be used something like:

        var nodeList = xml.xpath(...);
        tw.local.objArray = new tw.object.listOf.myObj();
         //If name node always exists as a child
         obj.name = nodeList[i].name[0].getText();
         tw.local.objArray[tw.local.objArray.listLength] = obj;}

Web services compatibility