Web Service EventHandler

Overview

The Web Service EventHandler exposes MI AssemblyLines as web services.
All AssemblyLines exposed as web services from the EventHandler are described in a WSDL document. The EventHandler reads this document and searches for these AssemblyLines in the current MI configuration.
Object and transport protocols supported so far are SOAP and HTTP. Thus any SOAP/HTTP client from the Internet can invoke a MI AssemblyLine and obtain its result.

AssemblyLines - WSDL Mapping

If you are not familiar with WSDL and its terms, you can find its specification at http://www.w3.org/TR/wsdl.

WSDL message part types - Java types Mapping

The data types supported by the EventHandler are a subset of the standard XML Schema built-in datatypes. That is why every type is prefixed with "xsd", where the "xsd" prefix is associated with the standard XML Schema URI of "http://www.w3.org/2001/XMLSchema".
For a complete description of XML Schema datatypes see XML Schema Part 2: Datatypes . The Web Service EventHandler currently supports the following XML Schema built-in (xsd) data types (the "Java Type" column contains the Java class to which the corresponding XSD Type maps):

XSD Type

Java Type

xsd:string java.lang.String
xsd:boolean java.lang.Boolean
xsd:byte java.lang.Byte
xsd:short java.lang.Short
xsd:int java.lang.Integer
xsd:long java.lang.Long
xsd:number java.lang.Long
xsd:integer java.lang.Long
xsd:double java.lang.Double
xsd:decimal java.lang.Double
xsd:float java.lang.Float
xsd:dateTime java.util.Date

Note: According to the XSD specification the dateTime serialized string must conform to the following format: yyyy-MM-ddTHH:mm:ss, where "yyyy" designates the 4-digit year, "MM" - the 2-digit month, "dd" - the 2-digit day, "T" - the separator, "HH" - the 2-digit hour, "mm" - the 2-digit minutes and "ss" - the 2-digit seconds (e.g. 1990-10-10T18:10:00). Even-though the XSD dateTime type does not accept a string specifying the date only (1990-10-10 would not be an acceptable xsd:dateTime string), the WS EventHandler accepts this kind of date string and constructs a java.util.Date object with the time set to 00:00:00.

Note: The Web Service EventHandler currently supports simple data types only - complex data types are not currently supported.

 

Using the EventHandler

  1. First, you have to create the AssemblyLines that you wish to expose as web services through the WS EventHandler. When creating your AssemblyLines you might want to look at the "Setting an AssemblyLine's result Entry Attributes' data types" section. You should be aware of the AssemblyLines' input and result Entries' Attributes.
  2. After identifying the AssemblyLines and their input and result Entry structures, you have to create a WSDL document that describes those AssemblyLines. You can do this from the "Configuration" tab of the EventHandler, where a utility for WSDL generation can be found (see the "Automatic WSDL Generation" section below).
  3. Now you have to configure the WS EventHandler specifying the URL to the WSDL file you have created and the TCP Port where the WS EventHandler will accept clients. There are some more configuration parameters that you will find in the EventHandler's "Configuration" tab: "Service operations", "WSDL File Name", "Web Service URL" - they all do not affect the work flow of the EventHandler; they do represent a utility for automatic generation of WSDL documents and their usage is described in the "Automatic WSDL Generation" section below.
  4. Run the WS EventHandler. It will start accepting client (SOAP/HTTP) requests. Each SOAP request is (1) parsed; (2) validated against the WSDL definition; (3) the required AssemblyLine is run with initial Entry created from the SOAP request input values; (3) the AssemblyLine's result Entry is validated against the WSDL definition; (4) a SOAP response is generated from the AssemblyLine's result Entry; (5) the SOAP response is sent to the client over HTTP.
  5. Now the WS EventHandler's web services can be accessed by any SOAP client (including the WS Connector).
 
Setting an AssemblyLine's result Entry Attributes' data types

You can set the data type of an Attribute of the result Entry of your AssemblyLine by using the "Attribute map" of the last Connector in your AssemblyLine in the following way:

  1. Go to the "Attribute Map" section of the last Connector in your AssemblyLine.
  2. Select the Attribute whose data type you want to set.
  3. Set the "Attribute mapping mode" to "Advanced".
  4. Let's suppose that you have an Attribute called "age" and you want to set its value type to java.lang.Integer.
  5. Type the following in the script edit box:
    ret.value = new java.lang.Integer(integer_as_string);
    where integer_as_string is the string representation of the "age" Attribute value. If, for example, you have used the default ("Simple") Attribute mapping mode for the "age" Attribute until now (i.e. you don't need any additional processing in the Attribute map), then all you need to type is:
    ret.value = new java.lang.Integer(conn.getAttribute("age").getValue());
    In this way the "age" Attribute will be stored in your AssemblyLine result Entry as a java.lang.Integer.
 
Event properties

After processing a request the Web Service EventHandler deliveres the event associated with this request to the business logic defined by the user in the "Action Map" section of the MI Admin. The following properties are assigned to the event object (availablve in the "Action Map"):

Connection properties:

Property Description
tcp.remoteIP Connection's remote IP address.
tcp.remotePort Connection's remote port.
tcp.remoteHost Connection's remote host name.
tcp.localIP The local IP address.
tcp.localPort The local port where the EventHandler listens for requests.
tcp.localHost The local host name.

Web service properties:

Property Description
event.originator The Web Service EventHandler instance that processed the request.
event.successfulALExecution A java.lang.Boolean value: "true" if the requested AssemblyLine has been successfully executed; "false" - otherwise.
event.responseSent A java.lang.Boolean value: "true" if any response has been sent; "false" - otherwise.
event.assemblyLineName The name of the AssemblyLine executed. This property is set only when "event.successfulALExecution" value is "true".
event.inputEntry An Entry object which Attributes correspond to the input parameters of the request. This property is set only when "event.successfulALExecution" value is "true".
event.outputEntry An Entry object which Attributes correspond to the output parameters of the response. This property is set only when "event.successfulALExecution" value is "true".

 

Configuration

Parameter

Description

class com.architech.switchboard.WebServiceSwitchboard
wsdlURL The URL of the WSDL document.
tcpPort The port where the EventHandler will accept SOAP/HTTP requests.
userComment Put your own comments here.
debug Specifies whether more detailed debug information will be written to the log file.

 

Automatic WSDL Generation

You can automatically generate the WSDL file from the "Configuration" tab of the Web Service EventHandler. Please note that the parameters represented by the user interface controls "Service operations", "WSDL File Name", "Web Service URL" are not part of the Web Service EventHandler configuration - they represent a utility for generating WSDL documents (i.e. for translating the MI AssemblyLines into WSDL).
In the "Available AssemblyLines" list box (the right one) you can see the AssemblyLines from the current MI configuration that are available for exposing in a WSDL document. The "Exposed AssemblyLines" list box (the left one) contains the AssemblyLines that will be exposed as web service operations in the WSDL document that will be created. If you want to expose an AssemblyLine in the WSDL document, select this AssemblyLine from the "Available AssemblyLines" list box and push the " < " (left arrow) button - the AssemblyLine will move to the "Exposed AssemblyLines" list. If you don't want to expose an AssemblyLine already moved to the "Exposed AssemblyLines" list, select this AssemblyLine from the list and push the " > " (right arrow) button - the AssemblyLine will move to the "Available AssemblyLines" list.

To generate a WSDL file do the following:

  1. Move all the AssemblyLines you wish to expose as web services to the "Exposed AssemblyLines" list box.
  2. Type the file path of the WSDL file you wish to create in the "WSDL File Name" text box.
  3. Type the URL of your web service in the "Web Service URL" text box. The URL of the web service should reference the computer and port on which you will run the Web Service EventHandler (for example "http://215.50.1.100:8080/").
  4. Push the "Create WSDL" button to actually create the WSDL file.
Important: Currently this utility does not process AssemblyLines input and result Entry Attributes, i.e. it does not perform the mapping between Entry Attributes and WSDL message parts . That is why it does not fill in the WSDL message parts in the WSDL documents it creates. You have to manually fill in the WSDL message parts in the generated WSDL files. For a short example demonstrating how to fill in WSDL message parts see below.

Filling in the WSDL message parts manually
The WSDL generation utility creates WSDL message parts but leaves them empty, like this:
	  <message name="Request">
		<part name="" type="xsd:"/>
	  </message>
	  
WSDL defines Request and Response messages. The WSDL generation utility generates message names by appending the suffix "Request" or "Response" to the name of the AssemblyLine. You should note that the words "request" and "response" apply to the request and response of a web service as viewed from a client application. Since the AssemblyLine operates on the server side of a web service, the "request" to the web service operation is mapped to the input Entry for the AssemblyLine, while the "response" of the web service operation is created from the result Entry of the AssemblyLine.

Let us assume that your sample AssemblyLine is called "TestAssemblyLine" and that it requires an input Entry, which contains a single attribute called "city" of type "string". This piece of information is encoded in a WSDL message part in the following way:

	  <message name="TestAssemblyLineRequest">
		<part name="city" type="xsd:string"/>
	  </message>
	  
Let us assume again that your sample AssemblyLine outputs an Entry, which contains two attributes: one called "population" of type "int" and the other called "is_capital" of type "boolean". This piece of information is encoded in WSDL message parts in the following way:
	  <message name="TestAssemblyLineResponse">
		<part name="population" type="xsd:int"/>
		<part name="is_capital" type="xsd:boolean"/>
	  </message>
	  
Please note that the order in which WSDL messages (requests and responses) appear in the WSDL file is not important.

 

Installation

Refer to the installation document for the Web Service Connector (WebServiceConnector.htm)