Skip to main content

Specifying Custom Transport from a Web Client

By default, if you use an InterSystems IRIS® data platform web client, the web client uses HTTP to transport the SOAP message to the web service and to receive the response. You can define and use your own transport class.

Background

To communicate with the web service that it uses, an InterSystems IRIS web client requires a transport class. The transport class contains parameters, properties, and methods related to communication. The overall communication works as follows:

  1. When a web client proxy method is run, the web client instance checks the value of its Transport property.

    If this property is null, the web client instance uses itself as the transport class instance. You can instead set the Transport property equal to an instance of some other suitable class, if you have defined such a class.

  2. The web client instance executes the DoSOAPRequest() method of the transport class, passing the following arguments:

    1. The OREF of the web client class.

    2. A string that specifies the SOAP action.

    3. A stream containing the request encoded in UTF-8.

    4. (By reference) A stream containing the response.

  3. The web client instance checks the status of the result and acts accordingly.

For HTTP transport, the DoSOAPRequest() method includes the following logic:

  1. Create a request object (an instance of %Net.HttpRequestOpens in a new tab) and set its properties. Here, the method uses values of the properties of the web client instance, in particular HttpRequestHeaderCharset and other HTTP-related properties.

  2. Go through the headers in the SOAP request and initialize the headers in the request object.

  3. Execute the Post() method of the request object, which is a suitable action for HTTP transport.

  4. Get the response and return that.

Important:

Do not directly use the DoSOAPRequest() method of %SOAP.WebClientOpens in a new tab. No guarantee is made about its behavior or future operation. The preceding summary is provided only as a general tip.

Defining Custom Transport for an InterSystems IRIS Web Client

To enable an InterSystems IRIS web client to use custom transport, define a custom transport class. Then after you create an instance of the web client, set its Transport property equal to an instance of the transport class.

The requirements for the transport class are as follows:

  • The class must be instantiable (that is, non-abstract).

  • The class must implement the DoSOAPRequest() method as described below.

The DoSOAPRequest() method should transport the request to the web service and obtain the response. The signature of this method must be as follows:

Method DoSOAPRequest(webClient,action,requestStream, responseStream) As %Status 
  • webClient is the OREF of the web client class.

  • action is a %StringOpens in a new tab that specifies the SOAP action.

  • requestStream is a stream containing the request encoded in UTF-8.

  • responseStream is a %FileBinaryStreamOpens in a new tab argument that DoSOAPRequest() uses to write the response. This stream must contain data in the character set specified by the encoding attribute of the ?xml directive. UTF-8 is recommended.

FeedbackOpens in a new tab