Question
· Sep 6

Question if it is possible to receive a REST call to an EnsLib.HTTP.InboundAdapter

Hello everyone!
I need to build something that will receive a REST request. As of now I have tried my luck with using an EnsLib.HTTP.InboundAdapter. But i am not so sure how I am supposed to configure it to be able to receive the REST request together with the JSON body.
I have specified the OnProcessInput in the adapter so that it receives a GlobalCharacterStream. However, I have not had any good luck finding out to actually make the request to the EnsLib.HTTP.InboundAdapter. 
I would be really thankful if you could let me know if it is possible for an EnsLib.HTTP.InboundAdapter to actually receive Rest request, and if so how that would be achieved. 
Thank you beforehand!

Discussion (8)3
Log in or sign up to continue

We sent the EnsLib.HTTP.GenericService into a process that did this, hope it helps.

Include Ensemble

Class Component.httpResendMessage Extends Ens.BusinessProcess
{

Method OnRequest(pRequest As EnsLib.HTTP.GenericMessage, Output pResponse As EnsLib.HTTP.GenericMessage) As %Status
{     

    set tSC=$$$OK
    namespace = $REPLACE(pRequest.HTTPHeaders.GetAt("IParams_1"),"namespace=","")
    ClientDocGUID= $REPLACE(pRequest.HTTPHeaders.GetAt("IParams_2"),"ClientDocGUID=","")
   

   s pResponse=##class(EnsLib.HTTP.GenericMessage).%New()
   set pResponseBody=##Class(%Stream.GlobalCharacter).%New()
   d pResponseBody.Write("<HTML><HEAD>Uh oh.</HEAD><BODY><BR><STRONG>Error: Invalid Patient ID</STRONG></BODY></HTML>")
   do pResponseBody.Rewind()
   d pResponse.HTTPHeaders.SetAt("HTTP/1.1 400 Bad Request","StatusLine")
   d pResponse.HTTPHeaders.SetAt("text/html; charset=utf-8","Content-Type")
   do pResponse.StreamSet(pResponseBody)
quit tSC
}  

}

To receive REST call directly into a Business Service is not the most recommended because you can't apply any kind of access restriction to the service. What I always recommend is to create a web application managed by a class that extends from %CSP.Rest and resend the JSON received to the Business Service.

You can see an example on this article:

https://community.intersystems.com/post/creating-rest-service-iris

I feel there could be some options. Direct access restriction can potentially be applied on service by settings AllowedIPAddresses AND / OR enforcing clientside certificates on SSLConfig. Infrastructure firewall is also a possibility. If offloading authentication and TLS with standard requests, basic authentication at the webserver configuration is also viable. As REST parameters or HTTP Headers, could also validate against Integration Credentials Store.