JSON message transmission

瀏覽次數:131 次
跳到第一則未讀訊息

Douglas Clayton

未讀,
2022年6月28日 上午11:41:582022/6/28
收件者:Hardhats
Just dipping my toes into JSON. Noticed a few Kernel JSON utilities. What transmission methods are people using to send and receive JSON messages to external servers?  I've mostly used HL7 messaging, so JSON syntax and transmission is new to me.

Coty Embry

未讀,
2022年6月28日 下午1:25:372022/6/28
收件者:hard...@googlegroups.com
We dont have the craziest setup but I just use GET and POST requests to respond to the client with JSON. I dont typically send JSON back to the server running MUMPS/CACHE though


On Jun 28, 2022, at 10:42 AM, Douglas Clayton <douglas...@gmail.com> wrote:

Just dipping my toes into JSON. Noticed a few Kernel JSON utilities. What transmission methods are people using to send and receive JSON messages to external servers?  I've mostly used HL7 messaging, so JSON syntax and transmission is new to me.

--
--
http://groups.google.com/group/Hardhats
To unsubscribe, send email to Hardhats+u...@googlegroups.com

---
You received this message because you are subscribed to the Google Groups "Hardhats" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hardhats+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hardhats/e825c85e-3625-42d5-8b71-12daa8c4ec4bn%40googlegroups.com.

OldMster

未讀,
2022年6月28日 下午3:57:242022/6/28
收件者:Hardhats
I use JSON for the REST API used with MGWEB to send request to and get data from YottaDB servers.  Rob Tweed of MGateway has a very good JSON->M array  parsing utility available, I believe it is available on the MGateway web site.  It's been a year or so since I got it, so I don't remember where.

Generating JSON is easy, parsing it, not so much :-)  HL7 is easy to do both.

Mark


Raman Sailopal

未讀,
2022年6月28日 下午4:07:342022/6/28
收件者:Hardhats,

Sam Habiel

未讀,
2022年6月28日 下午4:41:142022/6/28
收件者:hardhats
If you are a VistA programmer, you will be required to use XLFJSON.

As far as how people use it these days in VistA, RPC remains king, but
what I am seeing is that people create JSON input and output via the
RPC broker. It's becoming more and more common.

--Sam
> To view this discussion on the web visit https://groups.google.com/d/msgid/hardhats/CAHUezNw1zbgaHEDYu6OvtELbMeHby%2BGhNN8121xqDsmPe5WYqQ%40mail.gmail.com.

Douglas Clayton

未讀,
2022年7月26日 下午1:52:402022/7/26
收件者:Hardhats
Awesome! Thank you!

Douglas Clayton

未讀,
2022年7月26日 下午3:17:502022/7/26
收件者:Hardhats
Are you using the HTTP Client helper $$GETURL^XTHC10 to get and post? Does that support HTTPS as well?  Thanks!

Sam Habiel

未讀,
2022年7月26日 下午4:30:282022/7/26
收件者:hardhats
$$GETURL^XTHC10 does not support HTTPS.

Most packages today in VistA use HWSC (https://www.va.gov/vdl/application.asp?appid=180) to do TLS communication. I ported HWSC to GT.M/YottaDB; but I think you are working on Cache.

--Sam

Douglas Clayton

未讀,
2022年7月28日 晚上9:18:082022/7/28
收件者:Hardhats
Yes, working on Cache.

Thurber, Joseph H

未讀,
2022年7月29日 上午8:19:312022/7/29
收件者:hard...@googlegroups.com

Maybe I’m on the wrong track, but just in case you haven’t considered this.  If you are using a relatively modern version of Cache, you can create a class that extends %CSP.REST.  Note that I believe Yottadb/Octo has similar utilities.  I created a very simple example shown below.  It is loosely based on the samples.docserver class that comes with Cache.  I created a simple global called ^AirMachines and I can send GET requests with curl (or just http from a browser) and get back data.  The results formatting is based on the format requested.  Note that the method ListOneAirMachine is written to return just text regardless of the call, but the other method, ListAirMachines, can return JSON if requested.  I am a relative novice on Cache so someone with more experience can likely enhance this answer!

 

 

Class AirMachines.RESTServer Extends %CSP.REST

{
XData UrlMap [ XMLNamespace = "http://www.intersystems.com/urlmap]
{
<Routes>
   <Route Url="/AirMachines" Method="GET" Call="ListAirMachines"/>
   <Route Url="/AirMachines/:recnum" Method="GET" Call="ListOneAirMachine"/>
  </Routes>
}

ClassMethod ListOneAirMachine(recnum As %String)
{
  #dim tSC As %Status = $$$OK
  #dim AX As %Integer = +$G(recnum)
  IF AX'>0 D  Q tSC
  ."<p>You must provide a valid numeric record number!</p>"
  IF '$D(^AirMachines(AX)) D  Q tSC
  ."<p>Record "_AX_" does not exist!"
  "<p>("_AX_") "_$P($G(^AirMachines(AX)),"^",1,6)_"</p>"
  tSC
}

ClassMethod ListAirMachines() As %Status
{
   #dim tSC As %Status = $$$OK
   //#dim e As %Exception.AbstractException
   #dim tNS As %String
   #; If we have been asked for json
    If $Get(%request.CgiEnvs("HTTP_ACCEPT"))="application/json" 
    {        
        #; Set the response header to JSON
        Set %response.ContentType="application/json"
        
        #; Create a JSON proxy
        Set tProxy = ##class(%ZEN.proxyObject).%New()
        
        #; And a list to hold the data
        Set tList=##class(%Library.ListOfDataTypes).%New()
        
        #; Add the data to the list
        Set tNS=0 F  SET tNS=$O(^AirMachines(tNS)) Q:(tNS'>0)  D
        .Set CallSign=$P($G(^AirMachines(tNS)),"^",1)
        .CallSign '="" D
        ..Do tList.Insert(CallSign)        
        
        #; Set the namespace property
        Set tProxy.airmachines=tList
        
        #; Output the JSON
        Do tProxy.%ToJSON()
   
   else 
   {
     Set tNS=0 F  SET tNS=$O(^AirMachines(tNS)) Q:tNS'>0 D
     ."<p>("_tNS_") "_$P($G(^AirMachines(tNS)),"^",1,6)_"</p>"
   }   
   Quit tSC
}
}

 

 

And if you ask for this data in JSON: (ip address “redacted”)

 

curl -H "Accept:application/json" http://10.10.10.10:57772/AirMachines/AirMachines

{

        "airmachines":["N9169U","N5016T","N9616F","N94296","N7648Q","N4426X","N174EH","N331SD","N222ES","N40VF","N14056"

        ]

}

 

Keep in mind that this does consume a Cache license.

 

From: hard...@googlegroups.com <hard...@googlegroups.com> On Behalf Of Douglas Clayton
Sent: Thursday, July 28, 2022 9:18 PM
To: Hardhats <hard...@googlegroups.com>
Subject: [External] Re: [Hardhats] JSON message transmission

 

CAUTION: External email. Do not click links or open attachments unless you verify. Send all suspicious email as an attachment to Report Spam.

 




Email correspondence to and from this address is subject to the North Carolina Public Records Law and may be disclosed to third parties by an authorized State official. Unauthorized disclosure of juvenile, health, legally privileged, or otherwise confidential information, including confidential information relating to an ongoing State procurement effort, is prohibited by law. If you have received this email in error, please notify the sender immediately and delete all records of this email.

Douglas Clayton

未讀,
2022年8月2日 上午8:37:372022/8/2
收件者:Hardhats
If I were using POST^XOBWLIB or $$GETURL^XTHC10 to send orders to an external server and the external server was to provide an order update at a later time. The external server would have to use another transmission method like an RPC call to update the VistA system?  Is there support for HTTP POSTS requests from external systems to update VistA? Thanks!  

Sam Habiel

未讀,
2022年8月2日 上午8:52:412022/8/2
收件者:hardhats
Sadly, no. Nothing official in the VA. There's https://github.com/shabiel/M-Web-Server, incidentally, derived from work done in the VA.

--Sam

Douglas Clayton

未讀,
2022年8月2日 上午8:56:132022/8/2
收件者:Hardhats
Thanks Sam!

Kekoa

未讀,
2022年8月4日 凌晨1:45:262022/8/4
收件者:Hardhats
You may use ObjectScript to receive a mutual HTTPS POST to update VistA. HTTP is not allowed.
回覆所有人
回覆作者
轉寄
0 則新訊息