Question
· Feb 10, 2020

How could we debug a web service?‽

Hello,

 

We would like help to know why our web service which gets Patient's ID number, does not accept messages?

 

We observe its Event Log, and it contains the following pattern:

 

 

We detail each log to give info to discover what's happening:

First there is a new connection:

 

Then it suddenly disconnects

 

After that it looks like the service restarts:

The next one is interesting: it outputs that UTF-8 encoding is invalid, inside EnsLib.SOAP.InboundAdapter

We have searched for UTF-8 inside SOAP.InboundAdaptar and we find it here:

Set tCT=$S(tCST:"binary/CST; charset=UTF-8", ""'=tCT:tCT, 0=tLen:"", tSOAP12:"application/soap+xml", 1:"text/xml")

After this, the following two logs are related with not having a TCP connection opened:


ERROR <Ens>ErrException: <UNDEFINED>zOnConnected+158 ^EnsLib.SOAP.InboundAdapter.1 *tSOAP12 -- - registrado como '-'
número - @'
Set:""=$G(tStreamOut)||($IsObject(tStreamOut)&&'tStreamOut.Size&&$S(tStreamOut.%Extends("%Library.AbstractStream"):'$D(tStreamOut.Attributes),1:1)) tStreamOut=..faultString(tSC,..BusinessHost,$S(tSOAP12:"1.2",1:"1.1"))'

Besides there is a new disconnection:


 TCP closes:

And it shows a new Error and Warning related to TCP connection:


ERROR <Ens>ErrException: <UNDEFINED>zOnConnected+158 ^EnsLib.SOAP.InboundAdapter.1 *tSOAP12 -- - registrado como '-'
número - @'
Set:""=$G(tStreamOut)||($IsObject(tStreamOut)&&'tStreamOut.Size&&$S(tStreamOut.%Extends("%Library.AbstractStream"):'$D(tStreamOut.Attributes),1:1)) tStreamOut=..faultString(tSC,..BusinessHost,$S(tSOAP12:"1.2",1:"1.1"))'
 


Terminating Job 1513 / 'Servicios.GestionPacientes.ConsultaPacientesv01r00'
with Status = ERROR <Ens>ErrException: <UNDEFINED>zOnConnected+158 ^EnsLib.SOAP.InboundAdapter.1 *tSOAP12 -- - registrado como '-'
número - @'
Set:""=$G(tStreamOut)||($IsObject(tStreamOut)&&'tStreamOut.Size&&$S(tStreamOut.%Extends("%Library.AbstractStream"):'$D(tStreamOut.Attributes),1:1)) tStreamOut=..faultString(tSC,..BusinessHost,$S(tSOAP12:"1.2",1:"1.1"))', %QuitTask=1

 

As we see it looks like there is something related to utf-8 encoding.

In addition our web service code is the following:

Class Servicios.GestionPacientes.ConsultaPacientesv01r00 Extends (EnsLib.SOAP.Service, ITB.HL7.BS.XMLService) [ ProcedureBlock ]
{

Parameter ADAPTER = "EnsLib.SOAP.InboundAdapter";

/// Nombre del WebService
Parameter SERVICENAME = "ConsultaPacientesv01r00";

/// Namespace SOAP para el Servicio Web
Parameter NAMESPACE = "http://Servicios/GestionPacientes";

/// Se utilizarán namespaces de clases referenciadas en WSDL
Parameter USECLASSNAMESPACES = 1;

/// Use xsi:type attribute for literal types.
Parameter OUTPUTTYPEATTRIBUTE = 0;

/// Determines handling of Security header.
Parameter SECURITYIN = "ALLOW";

/// This is the SOAP version supported by the service.
Parameter SOAPVERSION = 1.1;

/// Non-default elementFormQualified for types XML namespace.
Parameter ELEMENTQUALIFIED = 0;

ClassMethod IsServiceEnabled() As %Boolean
{
    #dim tSC as %Status
    #dim productionName as %String
    #dim productionStatus as %Integer
    set tSC= ##class(Ens.Director).GetProductionStatus(.productionName,.productionStatus)
    
    #dim config as Ens.Config.Production
    set config = ##class(Ens.Config.Production).%OpenId(productionName)
    #dim item as Ens.Config.Item
    set item=config.FindItemByConfigName(..%ClassName(1))
   
    quit item.Enabled
}

Method findCandidatesXML(mensEntrada As %XML.String) As %XML.String(XMLNAME="mensSalida") [ Final, ProcedureBlock = 1, SoapAction = "http://Servicios/GestionPacientes/findCandidatesXML", SoapBindingStyle = document, SoapBodyUse = literal, WebMethod ]
{
    #dim tSC as %Status
    if ('..IsServiceEnabled()){
        set tSC = $SYSTEM.Status.Error(60333,"Web Service Not Enabled")
        if $$$ISERR(tSC) do ..ReturnMethodStatusFault(tSC)
    }
     
     set pRequest = ##class(Mensajes.Request.GestionPacientes.GestionPacientesRequest).%New()
    set pPesponse = ##Class(Mensajes.Response.GestionPacientes.operacionResponse).%New()
    
    // string to stream
    set pInputStream = ##class(%Stream.GlobalCharacter).%New()
    do pInputStream.Write($zcvt(mensEntrada,"O","UTF8"))
    
    // convert incoming HL7 (xml) to ER7
    set tSC = ..StreamProcessInput(pInputStream,.ackCommit,1,0,.msgER7)
    if $$$ISERR(tSC) $$$ThrowStatus(tSC)
    
    set pRequest.mensaje = msgER7
    
    //proceso el mensaje
    set tSC = ..SendRequestAsync("EnrutadorConsultaPaciente",pRequest, .pPesponse)
    if $$$ISERR(tSC){ $$$TRACE("Error en la llamada al destino"_$system.Status.GetErrorText(tSC))}
    
    set mensSalida = ##class(%XML.String).%New()
    set mensSalida = ##class(ITB.HL7.Util.Convert).ER7ToXML(pPesponse)

    Quit mensSalida
}

Method findCandidatesER7(mensEntrada As %String) As %String(XMLNAME="mensSalida") [ Final, ProcedureBlock = 1, SoapAction = "http://SCS.Servicios/GestionPacientes/findCandidatesER7", SoapBindingStyle = document, SoapBodyUse = literal, WebMethod ]
{
    set mensajeHL7 = ##class(EnsLib.HL7.Message).ImportFromString(mensEntrada)

    //Establece DocType
    set tipo = mensajeHL7.GetValueAt("1:9.3")
    do mensajeHL7.DocTypeSet("2.5:"_tipo)
    do ..OnProcessInput(mensajeHL7, .pResponse)
    
    Quit pResponse.OutputToString()
}

Method OnProcessInput(pInput As Ens.Request, ByRef pOutput As Ens.Response) As %Status
{
    Quit ..SendRequestSync("EnrutadorConsultaPaciente",pInput,.pOutput)
}

ClassMethod OnGetConnections(Output pArray As %String, item As Ens.Config.Item)
{
  Set (tValue,tIndex)=""
  For {
    Set tIndex = item.Settings.Next(tIndex) Quit:tIndex=""
    Set tSetting = item.Settings.GetAt(tIndex)
    If (tSetting.Name="Target"){
    if tValue="" {         
    Set tValue=tSetting.Value
}else{
    Set tValue=tValue_","_tSetting.Value
}
}
  }
  For i=1:1:$L(tValue,",") {
   Set tOne=$P(tValue,",",i)
   Continue:""=tOne
   Set pArray(tOne)=""
  }
  Quit
}

}

 

How could we debug this web service, in an effective way?

 

We have read:

Discussion (3)2
Log in or sign up to continue

 In addition we have tested sending an HL7 message from a test operation to the bussiness service, here is the example messag:

MSH|^~\&|7edit||7edit||20200210093324||QBP^Q21|MSG-20200210-093324-0270|P|2.5
QPD|MessageQueryName
RCP

Then, we see the following trace:


ERROR <Ens>ErrOutConnectionLost: Se ha perdido conexión HL7 Read con  - detectado mediante ERROR #5002: Error de cache: <READ>zReadLine+11^%IO.DeviceStream.1


So it looks like our service refuses to accept input HL7 messages.

In the Production we see it gets stucked:

And our service:

Shows no results:

Besides, we have checked our operation is referencing service's host and port:

 

How could we debug this bussiness service?