About the HTTP Adapters
The HTTP adapters (EnsLib.HTTP.InboundAdapterOpens in a new tab and EnsLib.HTTP.OutboundAdapterOpens in a new tab) enable your production to send and receive HTTP requests and responses. This topic provides a brief introduction to these adapters.
While InterSystems strongly recommends that you use the Web Gateway to set up communication between a web server and InterSystems IRIS, you can use the inbound adapter if needed.
InterSystems IRIS® data platform also provides specialized business service classes that use these adapters, and one of those might be suitable for your needs. If so, no programming would be needed. See Connectivity Options.
HTTP Inbound Adapter and Helper Classes
The EnsLib.HTTP.InboundAdapterOpens in a new tab is the HTTP listener for custom port listening, XML listening, and/or raw HTML handling. The inbound adapter listens on a private port rather than using a CSP page (which uses the standard web server to handle HTTP requests). For more information about the Web Gateway, see Installing the Web Gateway.
The EnsLib.HTTP.InboundAdapterOpens in a new tab class provides runtime settings that you use to specify items like the following:
A local port, where the adapter will listen for input
A list of IP addresses from which the adapter will accept input (if you want to restrict the possible sources)
Settings that specify whether to use the character set given in the inbound request, and if not, what other character set to use
The inbound HTTP adapter listens on the specified port, reads the input, and sends the input as a stream (either binary or character, depending on the character set in use) to the associated business service. The business service, which you create and configure, uses this stream and communicates with the rest of the production.
When you work with the HTTP inbound adapter, there are two helper classes that you might use: %Library.GlobalCharacterStreamOpens in a new tab and %Library.GlobalBinaryStreamOpens in a new tab. The inbound adapter sends a stream to the associated business service. Specifically, this is an instance of %Library.GlobalCharacterStreamOpens in a new tab or %Library.GlobalBinaryStreamOpens in a new tab, depending on the character set being used. In general, these classes provide methods that you can use to read the contents of the stream, get the length of the stream, read a single line, rewind, append data, and so on. For information on these classes, see Working with Streams.
HTTP Outbound Adapter and Helper Classes
EnsLib.HTTP.OutboundAdapterOpens in a new tab is the adapter for sending HTTP requests outside a production and receiving HTTP responses. This adapter provides settings to control items such as the following:
Server and port to which the adapter will send HTTP requests
URL path for the resource to request, at the given server and port
An optional TLS configuration to use for the connection to the server
Optional information to specify a proxy server through which the adapter can route requests
The adapter provides methods for sending HTTP POST, GET, and PUT actions:
The main methods are PostFormData() and GetFormData(). Each accepts an output argument for the response object, a comma-separated list of form variable names, and a variable number of form variable arguments, one for each of the names in the comma-separated list. If you want to set multiple values for a form variable, you can use the same name multiple times in the list. Of course, you can also use these methods with no form variables to request flat scalar content such as a regular web page.
For situations with a complicated set of form variables, use the methods PostFormDataArray() and GetFormDataArray(). These methods accept a multidimensional array instead of a variable argument list. This can help keep things organized, because you can provide multiple values for a given form variable as subnodes in the array, rather than as multiple entries in the list of names. You can also index the array by form variable name rather than by position.
The low-level worker method SendFormDataArray() is available for situations when you need to use a PUT or some other unusual HTTP request, or where you need to customize aspects of your HTTP request other than form variables or cookies.
The adapter also provides properties and methods to manage cookies.
When you work with the HTTP outbound adapter, there are two helper classes that you can use:
The HTTP outbound adapter uses %Net.HttpRequestOpens in a new tab to encapsulate the HTTP request that it sends.
If you use PostFormData(), GetFormData(), PostFormDataArray(), or GetFormDataArray(), the adapter creates the request automatically and you do not have direct access to it.
However, if you use SendFormDataArray(), you can create an instance of the %Net.HttpRequestOpens in a new tab class, set its properties, and use it to initialize the HTTP request that you send in that method. You use this technique when you need to set properties of the HTTP request (such as the proxy authentication) that cannot be set via the adapter.
In all cases, the HTTP response is encapsulated in an instance of %Net.HttpResponseOpens in a new tab. The %Net.HttpResponseOpens in a new tab class provides methods to access the HTTP headers, as well as properties that contain the body of the response (a stream object), reason codes, the HTTP version of the server, and so on.