User bio
404 bio not found
Member since May 5, 2017
Replies:

When an error has occurred, the return value is not 0. Instead, it is a %Status, and likely already contains the error information you need.

As to your actual question, finding (the id of) the response message header is not trivial. Ensemble Business Services have a %RequestHeader property from which you can take the CorrespondingMessageId, but unfortunately it is only populated if the call did not return an error status. It is still possible, though. You can use the id of the request body to find out what you need. It does need some SQL, though:

ClassMethod GetResponseHeaderId(RequestId As %String, Output sc As %Status) As %String
{
  &sql(SELECT CorrespondingMessageId INTO :ResponseHeaderId
         FROM Ens.MessageHeader
        WHERE MessageBodyId = :RequestId)
  If SQLCODE Set sc = $$$ERROR($$$SQLError, SQLCODE, $Get(%msg))
  
  Set sc = $$$OK
  
  Return ResponseHeaderId
}

With this helper method, you can open the response message header object. Assuming the request body is called CallReq:

  Set Id = ..GetResponseHeaderId(CallReq.%Id(), .sc)
  If 'sc Quit sc
  
  Set RspHdr = ##class(Ens.MessageHeader).%OpenId(Id, , .sc)
  If 'sc Quit sc
  
  $$$LOGINFO("Response is an error: "_RspHdr.IsError)

HTH,
Gertjan.

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