Thembelani Mlalazi · Sep 25, 2019

Soap Service How to pass a Stream Response

I have been trying to pass a %Global  character stream back on a Soap Response has anyone one out there done it before please help with guide lines on how to achieve this thanks in advance just some working sample code and will take it from there thanks again

4 0 5 250
Log in or sign up to continue


Could you please provide more details? Are you creating SOAP WebService in Caché and want to return stream data? Or is it a SOAP client connecting to some external webservice?

Generally for WebService you define return type as %Stream.GlobalCharacter,  then create and fill the stream object and that's it.

Example of web method returning stream data:

Method GetStream(text As %String) As %Stream.GlobalCharacter [ WebMethod ]
 set stream=##class(%Stream.GlobalCharacter).%New()
 Do stream.WriteLine("First Line")
 Do stream.WriteLine("Second Line")
 Do stream.WriteLine("Last Line with Text: "_text)
 Quit stream
Is this what you are looking for?

@Tomas Vaverka 
Yes that right but I know that the question may be was not clear I have an object class which has two properties one a string and a stream and was trying to pass that object ,all I could do was pass a string and an empty stream  but I have read around the stream and found out that I can pass a stream as a stream but not inside an object thanks again

i guess you are setting the stream incorrectly . Could you please post your specific code.

Are you asking about something like this?  From an Ensemble perspective this is returning something of type %GlobalCharacterStream.  There is no wrapper class around the %GlobalCharacterStream.  For the consumer of your web service this will appear as a string in the WSDL.
Method SomeMethodName(FacilityID As %String) As %GlobalCharacterStream [ WebMethod ]

// where the response of this method is an object of type %GlobalCharacterStream
quit ##class(SomeClassName).ReturnAStream(FacilityID)