Home > Class Reference > ENSLIB namespace > EnsLib.HTTP.Service


class EnsLib.HTTP.Service extends Ens.BusinessService, %CSP.Page

Abstract base class for HTTP-based BusinessService classes. Can use a HTTP.InboundAdapter listener, or the standard CSP service mechanism, or both. In order for the CSP mechanism to work, Web Services derived from this class must be configured either with their configuration name the same as their class name, or the invoking URL must include ?CfgItem= giving the config item name, or using a CSP application with a DispatchClass configured and the config item name as the next URL piece after the application name. (Configured Services exposed using the HTTP Inbound Adapter may also be invoked with this URL parameter but because each configured Inbound Adapter listens on its own TCP/IP port this parameter is just a safety check for them.)

Property Inventory

Method Inventory


parameter ADAPTER = EnsLib.HTTP.InboundAdapter;
Name of the adapter class - override this to "" if you want to use only the regular HTTP mechanism and not the custom-port HTTP InboundAdapter.
Set this to make page parse form variables from the form body in case of a form POST
Set this to remove CSP Gateway inserted Content stream attributes (e.g. FileName, MimeSection)
parameter SETTINGS = EnableStandardRequests:Connection;
Inherited description: List of properties can be set as settings in the configuration file format is a comma separated list of property names
Set this to 0 to prevent normalizing of HTTP header variable names to lowercase


property CSPNoCharSetConvert as %Boolean [ InitialExpression = 0 ];
When receiving via the CSP Gateway if the %response.ContentType=text/... or the %response.CharSet is specified then CSP will normally convert to the target charset when writing the response. This property is used to set the %response.NoCharSetConvert property.
The default is to have the CSP Gateway convert to the target charset.
For passthrough (generic) this might need to be checked so that the CSP Gateway does not convert.
If %response.NoCharSetConvert is set to true in custom code that will take precedence over this property being false.
Property methods: CSPNoCharSetConvertDisplayToLogical(), CSPNoCharSetConvertGet(), CSPNoCharSetConvertIsValid(), CSPNoCharSetConvertLogicalToDisplay(), CSPNoCharSetConvertNormalize(), CSPNoCharSetConvertSet()
property EnableStandardRequests as %Boolean [ InitialExpression = 1 ];
Listen via the CSP WebServer in addition to listening on the HTTP.InboundAdapter's custom local port, if the Adapter is defined/

Note that SSLConfig only applies to the custom local port. To use SSL via the CSP WebServer, you must configure the WebServer separately.

If the Service is invoked via the CSP WebServer, the ?CfgItem= URL parameter may be used to distinguish between multiple configured same-class Services but the standard csp/namespace/classname URL must be used.

Property methods: EnableStandardRequestsDisplayToLogical(), EnableStandardRequestsGet(), EnableStandardRequestsIsValid(), EnableStandardRequestsLogicalToDisplay(), EnableStandardRequestsNormalize(), EnableStandardRequestsSet()


abstract method OnAdapterHTTPResponse(ByRef pStatus As %Status, ByRef pHTTPResponseStatus As %String, ByRef pBodyLen As %Integer, ByRef pResponseBodyStream As %Stream.Object, ByRef pMainResponseHeader As %String, ByRef pHeaderExtra As %String) [ Language = objectscript ]
Callback for allowing Service to override and control construction of the HTTP response if invoked via the HTTP Inbound Adapter Override this method in your Service class to customize the HTTP response

Each argument may be overridden to change a particular aspect of the HTTP response pStatus is the status code that resulted from the HTTP call to the adapter pHTTPResponseStatus is the HTTP status that will be reported to the HTTP client pBodyLen is the response body size in bytes that will be reported to the HTTP client pResponseBodyStream is the stream or string whose contents will be returned as the HTTP response message body pMainResponseHeader if returned with content will be used verbatim as the HTTP header pHeaderExtra if returned will be used to override the standard no-cache header declarations or append to pMainResponseHeader

classmethod OnErrorStream(pStatus As %Status, pInstance As EnsLib.HTTP.Service) [ Language = objectscript ]
Control the type and content of error returned to the HTTP caller
classmethod OnHTTPHeader(ByRef OutputBody As %Boolean) as %Status [ Language = objectscript ]
Ensure no call to %response.WriteHTTPHeader() before OnPage(); ServerOnly and not Abstract to ensure $$$cMETHrunnable
method OnInit() as %Status [ Language = objectscript ]
Inherited description: This user callback method is called via initConfig() from %OnNew() or in the case of SOAP Services from OnPreSOAP()
classmethod OnPageError(ByRef pStatus As %Status) [ Language = objectscript ]
Inherited description: Event handler for any error that occurs on the page. If an error occurs and this method is defined it calls this method passing it the error code by reference. You may change the error code if wished, if you set it to $$$OK then it will cancel the error and the CSP error page will not be displayed.
classmethod findDataNotInQuery(Output pDataPairs As %String) as %Status [ Language = objectscript ]
Helper method to compare %request.Data with Query string parameters.
classmethod restoreFormEncoded(pBody As %Stream.Object = "") as %Status [ Language = objectscript ]
Put form urlencoded data back into the body since it is parsed in .Data array
classmethod restoreMultipart(ByRef pBody As %Stream.Object = "", Output pBoundary As %String = "") [ Language = objectscript ]
Put %request.MimeData into pBody if %request.MimeData contains at least one MPC Do not generate a boundary if not in the source.

Inherited Members

Inherited Properties

Inherited Methods