Question
· Dec 11, 2019

Issue with parsing a form variable of a HTTP POST request

Hi everyone, 

I am currently sending an HTTP POST request to an  EnsLib.HTTP.Service service (which has an EnsLib.HTTP.InboundAdapter associated). 

Here the request URL: http://10.41.11.210:57772/csp/healthshare/dce/POSTServiceClass.cls?rpyTo...

From the documentation I have read (https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls?KEY=EHTTP_inbound) I get that the form variables are written into the request body in case of a POST. I have also implemented the OnInint() is this way to enable the form variables parsing: 

 Method OnInit() As %Status
{
    Set ..Adapter.ParseBodyFormVars=1
    Quit 1
}

The OnProcessImput of the service is implemented in this way: 

Class POSTServiceClass Extends (EnsLib.HTTP.Service, HS.Util.Trace.Helper)
{
Parameter CONTENTTYPE = "text/xml";
Property TargetProcess As %String(MAXLEN = 250) [ Required ]; .
Property isServerFault As %Boolean;
Method OnInit() As %Status
{
    Set ..Adapter.ParseBodyFormVars=1
    Quit 1
}
Method OnProcessInput(pInput As %GlobalCharacterStream, Output pOutput As %GlobalCharacterStream, ByRef pHint As %String) As %Status
{
set ..isServerFault = $$$YES  // Server Fault by default #dim token As %String
if '$isObject(pInput) || (pInput.Size = 0) 
{
set ..isServerFault = $$$NO  
quit $$$ERROR($$$GeneralError, "Null request")
}
#dim inMsg As HS.Message.XMLMessage = ##class(HS.Message.XMLMessage).%New()
set inMsg.ContentStream=pInput
#dim outMsg As HS.Message.XMLMessage = "" 
#dim sc As %Status = ..SendRequestSync(..TargetProcess, inMsg, .outMsg) 
if $$$ISERR(sc) quit sc // check if we have a good response
if '$isObject(outMsg) || 'outMsg.%Extends("HS.Message.XMLMessage") quit $$$ERROR($$$GeneralError, "Null or incorrect response") set pOutput = outMsg.ContentStream
quit $$$OK
}

I was expecting to find my form variable (rpyToken) into the contentStream of the isMsg XMLMessage but there isn't. 

Can someone explain me what is my mistake?

Thank you in advance.

Discussion (1)1
Log in or sign up to continue