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?
Comments
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.
Class is in one server (Server A) and Production in a different server (Server B) and different namespace
In that case you need to implement REST API and call that.
Are you in the interop context? If yes, SendSync/SendAsync should be available for you.
If not, check this article.
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.