Written by

Question Eddy Gallo · Aug 26, 2024

Send a request from a class to a different server business service

I have this code and I need to send 

Set tRequest= ##class(Testing.Messages.GatewayCreateFacilityRequest).%New()

Set tRequest.facilityCode ="VINUSE"

 Set tResponse = ##class(Testing.Messages.GatewayCreateFacilityResponse).%New()

need to send a request to a new server:

Server: ECR10 

Namespace: ECR

Business Service: Healthix.Common.Verato.Gateway.Service.HubQueryService

set tResponse = ##class(Testing.Gateway.Service.HubQueryService).%New().CreateFacility(tRequest)

How do I add code to send it to the ECR10 server?

Product version: IRIS 2024.1

Comments

Clayton Lewis · Aug 26, 2024

Assuming this is code that runs outside of a Production and is trying to invoke a Business Service that does run within a Production in the same Namespace, the approach would be generally like this:

1) Create an instance of the Business Service:

    set tSC = ##class(Ens.Director).CreateBusinessService(tServiceName, .tServiceInstance)

2) Invoke the Business Service:

        set tSC = tServiceInstance.ProcessInput(tRequest, .tResponse)

This technique is used for SOAP services, REST APIs, and Tasks that invoke functionality provided by a Production.

0
Eddy Gallo  Aug 26, 2024 to Clayton Lewis

Class is in one server (Server A) and Production in a different server (Server B) and different namespace

0
Eduard Lebedyuk  Aug 26, 2024 to Eddy Gallo

In that case you need to implement REST API and call that.

0
David.Satorres6134 · Aug 27, 2024

Hello Eddy,

You might try this:

##class(HS.Hub.HSWS.WebServicesClientAPI).WebMethod("AddFacility").Invoke(##this,"http://www.intersystems.com/hs/hub/hsws/HS.Hub.HSWS.WebServices.AddFacility",pRequest,.pResponse)

There is an AddFacility method in HS.Hub.HSWS.WebServicesClientAPI.

0