User bio
404 bio not found
Member since Feb 19, 2016
Replies:

Thank you Enrico for your quick answer. I'm almost there.
To be more precise, we access the fileshare through a EnsLib.FTP.OutboundAdapter, through the method  ..Adapter.GetStream(pRequest.StringValue, .tStream) .

pRequest.StringValue contains the file-share path of the file I want to return.

Here is the full method : 

/// Return the CDA XML file as a %Stream.GlobalBinary
Method GetSoarianXMLCDA(pRequest As Ens.StringRequest, pResponse As %Stream.GlobalBinary) As %Status
{
// Create the variable tSC (temporary Status Code)
Set tSC = $$$OK

try{
    //Create the stream
    Set tStream=##class(%Stream.GlobalBinary).%New()
   
    //set the files path to the FTP Adapter
    Set tSC = ..Adapter.GetStream(pRequest.StringValue, .tStream)
    If $$$ISERR(tSC){
       $$$LOGERROR("Error while retrieving Stream from CDA file : tSC = " _ tSC)
    }

   $$$ASSERT($IsObject(tStream))

 //call here Do ##class(Ens.Util.XML.Reader).ChangeXMLStreamEncoding...
    
If tStream.SizeGet() > 0{
    Set pResponse = tStream
}
else{
          $$$LOGERROR("CDA file " _ pRequest.StringValue _" is empty or null")
       }
}
catch ex {
   $$$LOGERROR(##class(%SYSTEM.Status).GetErrorText(ex.AsStatus()))
   Set tSC = ex.AsStatus()

    Quit tSC
}

The FTP adapter method ..Adapter.GetStream returns a  %GlobalBinaryStream If I read the adapter's code correctly.

Could you please tell me how to use ChangeXMLStreamEncoding() in this methode above ? 

Thanks again

Fred

Thanks for yours answers, I tried your solutions, but it is hard and did not give good results.

To simplify my explanation : I'm reading an XML file from a file-share, and I want to change the XML header encoding from UTF8 to ISO-8859-1, if it happens sometimes.
So the result of my new method should transform the potential header
<?xml version="1.0" encoding="UTF8"?>   

to a new header

<?xml version="1.0" encoding="ISO-8859-1"?>  

Certifications & Credly badges:
Frederic has no Certifications & Credly badges yet.
Global Masters badges:
Frederic has no Global Masters badges yet.
Followers:
Frederic has no followers yet.
Following:
Frederic has not followed anybody yet.