Published on InterSystems Developer Community (https://community.intersystems.com)

Home > Cache Ensemble

Question
Jimmy Christian · Jun 25, 2019

Cache Ensemble

Hello,

Working on to learn very basic CUSTOM Business Service which sends to a  EnsLib.File.PassthroughOperation.

But operation is not writing to File and erroring out (No Stream contained in StreamContainer Request")'.

How do convert the object to STREAM and wrap in the StreamContainer so the operation does not error and write to a file.

Thanks.

Persistent Class

Class Hospital.PatientApptRequest Extends %Persistent
{
Property PatientId As %Stream.FileCharacter;
Property PatientName As %Stream.FileCharacter;
..

 

Custom Service reads from a file

Method OnProcessInput(pInput As %FileCharacterStream, Output pOutput As %RegisteredObject) As %Status
{
set tSC = $$$OK
    set pInput.LineTerminator=$c(10)
try 
{
while 'pInput.AtEnd {
          set tMsg = ##class(Hospital.PatientApptRequest).%New()
          
          set tLine = pInput.ReadLine()
          set tMsg.PatientId = tLine
          
          set tLine = pInput.ReadLine()
          set tMsg.PatientName = tLine
          
          do pInput.ReadLine()
          
          set tRequest1=##class(Ens.StreamContainer).%New(tMsg)
      
          set tSC = ..SendRequestAsync(..TargetConfigNames,tRequest1)
} }
catch ex 
{
set tSC = ex.AsStatus()
}
quit tSC
}
 

Sample File contents

1

ABC

 

2

DEF

Thanks,

Jimmy Christian.

#Business Operation #Business Service #ObjectScript #Ensemble

Source URL:https://community.intersystems.com/post/cache-ensemble