XML to Flat File

64 views
Skip to first unread message

Nunziato, Mark G

unread,
Apr 23, 2012, 2:16:21 PM4/23/12
to ensemble-in...@googlegroups.com

Hello,

 

We have an XML Document coming into Ensemble and then writing out to a flat file.  If we receive a document that is very large, the XML is being truncated.  The Business Service is setup to a %GlobalStream and we do receive smaller XML documents.

 

Any help is appreciated.

 

Class SoarianFinancialGL.SFGLXMLBS Extends Ens.BusinessService [ ProcedureBlock ]
{

Property SendAcknowledgement As %Boolean [ InitialExpression = ];

Parameter ADAPTER = "SoarianFinancialGL.SFGLCountedAdapter";

Method OnProcessInput(pInput As %RegisteredObject, Output pOutput As %IO.StringStream) As %Status
{

                pInput.Rewind()
                set request = ##class(SoarianFinancialGL.SFGLXMLRequest).%New()
                request.data.CopyFrom(pInput)
                request.data.Rewind()
 
                //set tSC = ..SendRequestAsync("SoarianFinancialGL.SFGLBP",request)
                set tsc = ..SendRequestAsync("SaveXMLtoFileBO",request)
               
                w:..SendAcknowledgement "L"_$C(6)_"000008",*-3
               
                quit tSC
}

}

 

 

 

Mark Nunziato

 

Albany Medical Center

Integration Services

Nun...@Mail.AMC.EDU

518-262-8754

 

 

Dale du Preez

unread,
Apr 23, 2012, 2:22:45 PM4/23/12
to Ensemble-in...@googlegroups.com
Hi Mark,

Can you also post the code for the adapter you are using? I can't tell whether that may be part of the issue, but it's possible. Once thing you might want to help determine the point at which this is a problem is working out what pInput.Size is at the start of OnProcessInput() -- if it's already truncated, the issue must be in the adapter code.

Dale
--
You received this message because you are subscribed to the Google Groups "InterSystems: Ensemble in Healthcare Community" group.
To post to this group, send email to Ensemble-in...@googlegroups.com
To unsubscribe from this group, send email to Ensemble-in-Healt...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/Ensemble-in-Healthcare?hl=en

Nunziato, Mark G

unread,
Apr 23, 2012, 3:01:13 PM4/23/12
to ensemble-in...@googlegroups.com

Hi Dale,

 

Below is the CountedAdapter Code we are using:

 

Class SoarianFinancialGL.SFGLCountedAdapter Extends EnsLib.TCP.CountedInboundAdapter [ ProcedureBlock ]
{

Method ReadCountedStream(ByRef pStream As %CharacterStream, pCharset As %String = "", pStartTimeout As %Numeric = -1, pChunkTimeout As %Numeric = 60, pInbound As %Boolean = 0) As %Status
{
                Set tSC=$$$OK, $ZT="TrapRS"
                Do {
                                If 'pInbound {
                                                $$$sysTRACE("Waiting to read counted data block from "_..IOAddr_" into Stream using charset '"_pCharset_"' with timeout="_pStartTimeout)
                                }
                                Do SetIO^%NLS("RAW") ; Switch to RAW input mode
                                //start altered code (adjusted for 9 byte header)
                                If -1=pStartTimeout Read tLenStr#9 Set tTimedOut = 0 }
                                Else Read tLenStr#9:pStartTimeout  Set tTimedOut = '$Test }
                                Set $ZT="Trap"
                                If tTimedOut Set tSC = $$$ERROR($$$EnsErrTCPReadBlockSizeTimeoutExpired,pStartTimeout,4) Quit }
                               
                                #; Convert to integer
                                Set tLen=+$E(tLenStr,3,9)-9 //since length includes the header need to minus that for actual data length
                                set header = tLenStr
                                Quit:0=tLen
                                //end altered code
                                Set tTable = ##class(%IO.I.TranslationDevice).GetCharEncodingTable(pCharset)
                                If "RAW"=tTable {
                                                $$$sysTRACE("Got block count="_tLen_", waiting to read (raw) with timeout="_pChunkTimeout)
                                                Set tSC = pStream.InputFromDevice(.tLen,pChunkTimeout) Quit:$$$ISERR(tSC)
                                Else {
                                                $$$sysTRACE("Got block count="_tLen_", waiting to read in 8k chunks using charset '"_pCharset_"' with chunk timeout="_pChunkTimeout)
                                                Set tStream = ##Class(%Library.FileCharacterStream).%New() $$$ASSERT($IsObject(tStream))
                                                Set tLeft = tLen, tMaxChunk=$$$GetClassParameter("%Library.FileCharacterStream","MAXLOCALSIZE")
                                                set ^mas(2) = "in here"
                                                While tLeft>0 {
                                                                Set tChunkSize = $select(tLeft>tMaxChunk:tMaxChunk,1:tLeft)
                                                                Set tStartTime=$zh
                                                                Read data#tChunkSize:pChunkTimeout  If '$Test {
                                                                                If $zh-tStartTime < pChunkTimeout Set tSC = $$$EnsError($$$EnsErrTCPReadBlockSize,pChunkTimeout,tChunkSize,"("_$L(data)_"):"_data) Quit }
                                                                                Else Set tSC = $$$EnsError($$$EnsErrTCPReadTimeoutExpired,pChunkTimeout,tChunkSize,pCharset) Quit }
                                                                }
                                                                $$$sysTRACE("Got data chunk, size="_$length(data)_"/"_tChunkSize)
                                                                Set tLeft = tLeft-$length(data)
                                                                Do tStream.Write(data) ; Save out to the stream from the data we read in from the socket
                                                }
                                                Set tStream.TranslateTable = tTable, tSC = pStream.CopyFrom(tStream) Quit:$$$ISERR(tSC)
                                                $$$sysTRACE("Converted("_tLen_") input bytes to ("_pStream.Size_") characters using charset '"_pCharset_"', table '"_tTable_"'")
                                }
                                $$$sysTRACE("TCP Read block("_pStream.Size_")")
                While (0)
Exit
                Quit tSC
TrapRS
                Set $ZT="", tSC=$$$SystemErrorType("Block Count")
                Goto Exit
Trap
                Set $ZT="", tSC=$$$SystemError
                Goto Exit
}

James MacKeith

unread,
Apr 23, 2012, 4:00:02 PM4/23/12
to ensemble-in...@googlegroups.com
Hi Mark

Is the length declared in the header being sent and read correctly?

If you enable tracing (^Ens.Debug("TraceCat"))  what trace messages you get. Also be worth putting in a trace for tLenStr.

Kind regards

James
From: "Nunziato, Mark G" <Nun...@mail.amc.edu>
Reply-To: "ensemble-in...@googlegroups.com" <ensemble-in...@googlegroups.com>
Date: Mon, 23 Apr 2012 15:01:13 -0400
To: "ensemble-in...@googlegroups.com" <ensemble-in...@googlegroups.com>
Subject: RE: [InterSystems-EnsHlth] XML to Flat File

Nunziato, Mark G

unread,
Apr 24, 2012, 10:10:31 AM4/24/12
to ensemble-in...@googlegroups.com

Hi James,

 

We entered Globals to capture the length and it looks like it caps at 49991.  Please see below:

 

^IS=49991

^IS(1472)=49991

^IS(3976)=49991

^IS(4420)=49991

^IS(4592)=49991

 

Having the Counted Adapter set to %CharacterStream, I would think it wouldn’t care of the length?

 

Thanks

 

Mark

James MacKeith

unread,
Apr 24, 2012, 1:32:42 PM4/24/12
to ensemble-in...@googlegroups.com
Hi Mark 

Thanks. What is tLenStr = to? Based on your code below I'd say tLenStr="xx50000xx" and therefore it reads in 49991 bytes.

I think the Event log with ^Ens.Debug("TraceCat") set as well as value of tLenStr would be useful.
Reply all
Reply to author
Forward
0 new messages