Avalados por :

Cómo verificar si un archivo XML está vacío antes de enviarlo con el adaptador HTTPS

  • Creado 01/03/2024
  • Modificado 01/03/2024
  • 27 Vistas
0
Cargando...

Estoy utilizando el adaptador Https para enviar el archivo xml. En mi escenario, debo verificar si el archivo está vacío o no; si está vacío, debería finalizar, si contiene datos xml, debería continuar. ¿Alguien puede sugerirme cómo lograr esto, por favor?

Pedro Pascal
Se unió el 07/03/2018
Pinterest
Telegram
Linkedin
Whatsapp

4 Respuestas

0
Cargando...

Hola vikranthrokz0074_2 ,

Podrías usar el paso [Router] y mantener una condición para verificar si el recuento del nodo es mayor que 0.

/root/count(ChileElementName)>0

¡Espero que esto te ayude!

Gracias y saludos,

Praveen T

Respondido el 15/04/2024
LUCIANO RIOJA GHIOTTO
Se unió el 13/07/2019
0
Cargando...

Hola vikranthrokz0074_2

No, eso no funcionará. Pero te sugiero que pruebes las sugerencias en tu sistema real. En cuanto a la expresión no XML: mencioné que las condiciones de XPath (= XML) no funcionarán si la carga útil está vacía. Fallará en tiempo de ejecución.

Saludos,

Morten

Respondido el 15/04/2024
LUCIANO RIOJA GHIOTTO
Se unió el 13/07/2019
0
Cargando...

Hola Morten,

¿Puedo usar ${in.body.length}="0" para mi escenario? ¿Es preferible? En el ejemplo anterior has dado una expresión no xml, pero en mi caso el archivo de entrada es xml, ¿funcionará para ello?

Respondido el 15/04/2024
LUCIANO RIOJA GHIOTTO
Se unió el 13/07/2019
0
Cargando...

Hi Vikranth

The Router step is the way forward, as Sriprasad and Praveen points out. However, the routing condition is not straightforward. Using an XPath condition will fail if there is no payload at all. And as for the alternative (a Simple expression language expression), I don't know if it's doable.

What will work, though, is to test for an empty payload in a Groovy script before the Router, store the result in a property and then branch on that property. Here's the script:

import com.sap.gateway.ip.core.customdev.util.Message

def Message processData(Message message) {
    def body = message.getBody(String)
    message.setProperty('EmptyPayload', body == null || body.isEmpty())
    return message
}

This stores true or false in the property called EmptyPayload.

Next, create a Router where the default route is the not empty case (i.e. where you want to do some work). The other route has the following non-XML routing condition:

${property.EmptyPayload} = 'true'

This branch you can terminate with an End Message event.

So your configuration would look something like this:

Regards,

Morten

config.png
Respondido el 15/04/2024
LUCIANO RIOJA GHIOTTO
Se unió el 13/07/2019

contacto@primeinstitute.com

(+51) 1641 9379
(+57) 1489 6964

© 2024 Copyright. Todos los derechos reservados.

Desarrollado por Prime Institute

¡Hola! Soy Diana, asesora académica de Prime Institute, indícame en que curso estas interesado, saludos!
Hola ¿Puedo ayudarte?