Thanks Phil. Can you provide more detail on how to create a business service with the EnsLib.HTTP.InboundAdapter to receive the JSON message on a REST end point? Would it allow external systems to post to with JSON data via http potocol (i.e. with header 'Content-Type: application/json')?
That would be the first step. I will worry about putting the JSON data in a message structure and passing it to and using it in the business process next.
Updated (jul 4th):
I followed the documentation on EnsLib.HTTP.InboundAdapter and created a business service, and a request message class. So how do I go about testing it after instantiate this business service? What is would be the URL I post to? What other configuration do I have to do?
Class DEVTEST01PKG.HL7ProductionTest01.MyNewWebService Extends EnsLib.HTTP.Service
{
Parameter ADAPTER = "EnsLib.HTTP.InboundAdapter";
Method OnProcessInput(pInput As %GlobalCharacterStream, pOutput As %RegisteredObject) As %Status
{
set tsc=$$$OK
Set tData=pInput.Read(,.tSC)
If $$$ISERR(tSC)
{
do $System.Status.DisplayError(tSC)
}
//create request object to send
Set tRequest=##class(DEVTEST01PKG.HL7ProductionTest01.MyTestRequestMsg).%New()
//use a delimiter to separate the form variables
Set list=$LISTFROMSTRING(tData,"&")
//examine each element and extract the relevant data
Set ptr=0
While $LISTNEXT(list,ptr,key) {
If $PIECE(key,"=") = "MRN" {
Set tRequest.MRN = $PIECE(key,"=",2)
}
Elseif $PIECE(key,"=") = "name" {
SET tRequest.name = $PIECE(key,"=",2)
}
Elseif $PIECE(key,"=") = "NoteID" {
Set tRequest.NoteID = $PIECE(key,"=",2)
}
}
//send to lookup process
Set tSC=..SendRequestSync("EHTTP.LookupProcess",tRequest,.tResponse)
//define output for OnProcessInput
Set pOutput=tResponse
Quit tSC
}
Method OnInit() As %Status
{
Set ..Adapter.ParseBodyFormVars=1
Quit 1
}
}
W
Thanks, Robert and Scott. It works now.
W
Jeff,
Thank you, Your are right, I missed the Doc Name.
Wil.