If you are using HealthShare, and I do believe so, please read the following documentation (login required):

Custom Authentication Processing using the Local ZAUTHENTICATE

There you will find:

Important:

The ZAUTHENTICATE provided with HealthShare includes callbacks that allow you to add custom processing at specific entry points. Do not modify the supplied ZAUTHENTICATE. Instead, add your callback processing as class methods in the class HS.Local.ZAUTHENTICATE

I don't think there is a callback method available.

One option could be to subclass %CSP.REST and use your subclass instead of %CSP.REST.

You subclass can be something like:

Class MyCustomCSP.REST Extends %CSP.REST
{

ClassMethod DispatchRequest(url As %String, method As %String, forwarded As %Boolean = 0, args...) As %Status
{
	Set sc=##super(url,method,forwarded,.args)
	
	; your "onPostDispatch" code here 
	Quit sc
}

}

In fact, for simple XML export (no namespace and other amenities) you can just use XMLExport*() methods.

ClassMethod test()
{
	Set message=##class(Mensajes.Response.Radiologia.NumeroOrdenAcodigoSERAMResponse).%New()
	Set message.resultado.codigo="06050301"
	Set message.resultado.error=##class(EsquemasDatos.Seguridad.Error).%New()
	Set message.resultado.error.codigo=0
	Set message.resultado.error.descripcion="Proceso realizado correctamente"
	
	Set sc=message.resultado.XMLExportToString(.string)
    ; handle sc error here

	Write string,!!
	
	; convert XML string back to object
    Set reader = ##class(%XML.Reader).%New()
    Set sc=reader.OpenString(string)
    ; handle sc error here
    Do reader.Correlate("resultado","EsquemasDatos.Radiologia.Resultado")
    Do reader.Next(.ReturnObject,.sc)
    ; handle sc error here
    Write "ReturnObject is of type ",ReturnObject.%ClassName(1),!
    do ReturnObject.XMLExport(,",indent")
	
	Quit
}

Result:

Do ##class(Mensajes.Response.Radiologia.NumeroOrdenAcodigoSERAMResponse).test()
<resultado><error><codigo>0</codigo><descripcion>Proceso realizado correctamente</descripcion></error><codigo>06050301</codigo></resultado>
 
ReturnObject is of type EsquemasDatos.Radiologia.Resultado
<resultado>
  <error>
    <codigo>0</codigo>
    <descripcion>Proceso realizado correctamente</descripcion>
  </error>
  <codigo>06050301</codigo>
</resultado>

OK, you asked XML string to object 😊

ClassMethod test()
{
	Set message=##class(Mensajes.Response.Radiologia.NumeroOrdenAcodigoSERAMResponse).%New()
	Set message.resultado.codigo="06050301"
	Set message.resultado.error=##class(EsquemasDatos.Seguridad.Error).%New()
	Set message.resultado.error.codigo=0
	Set message.resultado.error.descripcion="Proceso realizado correctamente"
	
	Set writer=##class(%XML.Writer).%New()
	Set writer.Indent=1

	Set sc=writer.OutputToString()
	; handle sc error here
	Set sc=writer.RootObject(message.resultado)
	; handle sc error here
	Set string=writer.GetXMLString()
	Write string,!
	
	; convert XML string back to object
    Set reader = ##class(%XML.Reader).%New()
    Set sc=reader.OpenString(string)
    ; handle sc error here
    Do reader.Correlate("resultado","EsquemasDatos.Radiologia.Resultado")
    Do reader.Next(.ReturnObject,.sc)
    ; handle sc error here
    Write "ReturnObject is of type ",ReturnObject.%ClassName(1),!
    do ReturnObject.XMLExport(,",indent")
	
	Quit
}

Result:

Do ##class(Mensajes.Response.Radiologia.NumeroOrdenAcodigoSERAMResponse).test()
<resultado>
  <error>
    <codigo>0</codigo>
    <descripcion>Proceso realizado correctamente</descripcion>
  </error>
  <codigo>06050301</codigo>
</resultado>
 
ReturnObject is of type EsquemasDatos.Radiologia.Resultado
<resultado>
  <error>
    <codigo>0</codigo>
    <descripcion>Proceso realizado correctamente</descripcion>
  </error>
  <codigo>06050301</codigo>
</resultado>

To export a XML enabled class use %XML.Writer class.

ClassMethod test()
{
	Set message=##class(Mensajes.Response.Radiologia.NumeroOrdenAcodigoSERAMResponse).%New()
	Set message.resultado.codigo="06050301"
	Set message.resultado.error=##class(EsquemasDatos.Seguridad.Error).%New()
	Set message.resultado.error.codigo=0
	Set message.resultado.error.descripcion="Proceso realizado correctamente"
	
	Set writer=##class(%XML.Writer).%New()
	Set writer.Indent=1

	Set sc=writer.OutputToString()
	; handle sc error here
	Set sc=writer.RootObject(message.resultado)
	; handle sc error here
	Set string=writer.GetXMLString()
	Write string,!
	Quit $$$OK
}

In your EsquemasDatos.Radiologia.Resultado class add XMLNAME parameter to obtain the correct (lowercase) tag name:

Class EsquemasDatos.Radiologia.Resultado Extends (%SerialObject, %XML.Adaptor)
{

Parameter XMLNAME = "resultado";

Property error As EsquemasDatos.Seguridad.Error;

Property codigo As %String(MAXLEN = "");

Result:

Do ##class(Mensajes.Response.Radiologia.NumeroOrdenAcodigoSERAMResponse).test()
<resultado>
  <error>
    <codigo>0</codigo>
    <descripcion>Proceso realizado correctamente</descripcion>
  </error>
  <codigo>06050301</codigo>
</resultado>