Hi Willem.
I would put a Trace Node with a $Root pattern to trace out the message before the Compute Node. This should show you the shape of the message entering the node which you can check against your ESQL. If you still can't make it work, paste the Trace Node output here...
Original Message:
Sent: Thu May 11, 2023 05:12 AM
From: Willem Kunkels
Subject: Extracting faultstring from a SOAP fault in ESQL
Hello,
I already tried both suggestions (Soap extract and namespace), I never got that to work either. What I eventually did was using a mapping node, which worked.
Still curious though about how to get this to work in ESQL.
Thanks to the people who replies thusfar.
Willem
Original Message:
Sent: 5/11/2023 2:17:00 AM
From: Lars Dehli
Subject: RE: Extracting faultstring from a SOAP fault in ESQL
Hi Willem!
I would guess there are namespaces involved here. Since you haven't specified any,then your references to the tree is probably incorrect. Are you able to do the same call from another tool, like soapUI? The result there will show you the nesseccarry namespaces. I belive that you will not be able to see the namespaces in the ACE debugger.
You can include the namespaces in your code like f.ex:
DECLARE soapenv NAMESPACE 'http://schemas.xmlsoap.org/soap/envelope/'; -- To declare namespace variable
InputRoot.SOAP.soapenv:Body.xyz -- To reference the tree - notice the syntax used with a namespace . namespace variable followed by : (.soapenv:)
It is also possible to use wildcards for namepsaces, such as:
InputRoot.SOAP.Body.*:Fault.*:faultstring
But I would reccommend to use actual namespaces.
EDIT: You should also have some degree of auto complete if you have imported the WSDL files, try something like:
SET xyz = InputRoot.SOAP. - then do ctrl + space.
Hope it helps.
Cheers,
Lars
------------------------------
Lars Dehli
Original Message:
Sent: Wed May 10, 2023 05:03 AM
From: Willem Kunkels
Subject: Extracting faultstring from a SOAP fault in ESQL
Dear fellow app connect developers,
I am using a SOAPRequest node to call a SOAP 1.1 service. That service responds with a SOAP fault. So far, exactly what I am expecting. I want to extract the faultstring from the SOAP fault so that I send it back in a JSON response to a caller of the flow.
I tried this:
/* * Set indication in the Environment that a SOAP fault has occurred. */ CREATE COMPUTE MODULE WAR03_LIMS_ACTIVATE_PROJECT_Handle_SOAP_Fault CREATE FUNCTION Main() RETURNS BOOLEAN BEGIN -- Set SOAP fault occured. SET Environment.Variables.soapFaultOccurred = TRUE; -- Set the reason for the SOAP fault IF (COALESCE(InputRoot.SOAP.Body.Fault.faultstring, '') = '') THEN SET Environment.Variables.soapFaultReason = 'The reason is unknown'; ELSE SET Environment.Variables.soapFaultReason = InputRoot.SOAP.Body.Fault.faultstring; END IF; RETURN TRUE; END;END MODULE;
The result is always 'The reason is unknown'. I have searched for examples which extract the faultstring but have been unable to find any. Has anyone come across the same and managed to achieve this?
Thanks
Willem Kunkels
------------------------------
Willem Kunkels
Senior Software Engineer
Koopman International BV
Amsterdam
+31204947893
------------------------------