User bio
404 bio not found
Member since May 12, 2023
Replies:

To create a SOAP service refer to this documentation Creating SOAP Web Services in IRIS. Within your Method you should be able to call a StoredProc and convert the output to the one required by the service.

However it is not that simple to call a SOAP service directly from browser, please refer to this StackOverflow question to see possible solutions and limitations. I would consider exposing it as REST service. Either way the service needs to be exposed on the same domain as your webpage to avoid CORS.

This worked for me as well. In my case I was parsing an XML file ANSI encoded without proper header. Once the stream hit a special charachter (in my case "à") it wouldn't recognize it. I presume  %XML.XPATH.Document and  %XML.TextReader default to UTF-8 in this case, after converting the stream I was able to parse without issues.

set cda2Stream = ##class(%Stream.FileBinary).%New()
$$$ThrowOnError(cda2Stream.LinkToFile(cda2FileName))
// Converting to UTF-8 encoding as the original stream is ANSI encoded without proper header
set convertedStream = ##class(%Stream.GlobalBinary).%New()
while 'cda2Stream.AtEnd {
	$$$ThrowOnError(convertedStream.WriteLine($zconvert(cda2Stream.ReadLine(),"O","UTF8")))
}
// Parsing the converted stream
$$$ThrowOnError(##class(%XML.TextReader).ParseStream(convertedStream,.Textreader))
$$$ThrowOnError(##class(%XML.XPATH.Document).CreateFromStream(convertedStream,.XpathDoc))
set XpathDoc.PrefixMappings = "s urn:hl7-org:v3"

I think XML would be the best way, especially if you want to do it programmatically. This snippet will export your table to the specified folder

ClassMethod ExportTable(table As %String, path As %String)
{
	set class = $replace($replace(table,"_",""),"SQLUser.","User.")
	set sqlQuery = "select $listbuild(%Id,'"_class_"') as oid from "_table
	
	set rset = ##class(%SQL.Statement).%ExecDirect(,sqlQuery)
	while rset.%Next() {
		set elements(rset.%Get("oid"))=""
	}
	
	do ##class(XML.Element).Export(.elements, path_"/"table_".xml", "r")
}

And then you import it on the other instance with:

##class(XML.Element).Load(file,"/overwriteguid/notransaction/changecontrolskipevents")

The advantage of this solution is that it uses %GUIDs as identifiers, as such you can add/edit data on your target system and it won't be overwritten when importing the file. 

An alternative way without having direct access to file system would be use a JDBC client with export functionality. I use DBeaver and you can right click on your query/table -> Execute -> Export from query:

 

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