Consuming Web services

The Designer provides one builder to call all types of services. We can use the Service Call builder to consume SOAP and HTTP Get or Post services whether they have associated WSDL documents or not. Most services published to the public UDDI registries and the xmethods.org site have associated WSDL documents, so the following documentation assumes that a WSDL document exists for the web service to consume. If you are calling web services not described by a WSDL document, the steps are similar if not the same, except that you will need to know about the inputs to the service, so that we can configure the service call to pass the appropriate inputs.

The following steps outline the process of consuming a web service:

  1. Find URL to WSDL document for service.

  2. Add a service call to a model .

  3. Use the outputs.

 

Finding WSDL Documents for Services

We can find the WSDL documents for the services you want to call either on a public Web site like xmethods.com, in a public UDDI registry hosted by IBM, Microsoft , or some other company, or in a private UDDI registry hosted within your own company or by a partner.

The xmethods.com site consistently updates the list of available services and provides all the information (including the WSDL document) needed to call the services listed on their site.

 

Add a Service Call to a Model

We can add a service call to a model by adding a Service Call builder call to the model. If the service you are calling takes an XML structure as an input, the Service Call builder adds a schema to the model that describes that XML structure. We can use this schema to add a variable to your model in which we can specify all of the required input values. We can then use methods to process user input or perform other logic and set the values in the service input variable.

To create an inputs variable for a service call:

  1. Add a Service Call builder call to your model. See "How to Use the Service Call Builder" for specific information. When you add the Service Call builder call to your model, take note of the type specified for any XML inputs. You will set the inputs variable you create to be of this type.

  2. Add a variable to the model. When you set the type for the variable, notice that there are more than the usual types listed. Set the variable to be of the type specified for the XML input to the service.

  3. When you select a complex type defined by a schema (as you have just done), the Variable builder's builder call editor displays a Populate with Sample Data button. Click this button to "pre-set" your service inputs variable.

Now that you have sample data in the variable, you can set the individual element values with methods in your model or by simply editing the XML in the Variable's builder call editor.

To actually call the service, call the ServiceCallName.invoke method from an action list or a method. For example, to execute the service call from a method:

webAppAccess.callMethod("ServiceCallName.invoke");

In an Action List builder, the ServiceCallName.invoke() method can be selected from the Action Chooser, displayed by clicking the ellipsis [...] button.

 

Using the Outputs from a Service

Once you call the service, the Factory servlet stores the results in the ServiceCallName_reply variable. If the service returns XML, the service call builder also adds a schema that defines the service results and we can use this schema to create "typed" variables that reference a particular node in the results structure.