App Connect

App Connect

Join this online user group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  Extracting faultstring from a SOAP fault in ESQL

    Posted Wed May 10, 2023 08:17 AM

    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
    ------------------------------


  • 2.  RE: Extracting faultstring from a SOAP fault in ESQL

    Posted Thu May 11, 2023 02:11 AM

    Hello

    could it be that you are missing namspece? Or that you need to add a soap extract after the request?

    Regards,
    Kjetil Svihus



    ------------------------------
    Kjetil Svihus
    ------------------------------



  • 3.  RE: Extracting faultstring from a SOAP fault in ESQL

    Posted Fri May 12, 2023 07:56 AM

    Hi Willem,

    you're missing a namespace on the Fault element. Trying using anonymous reference to namespace if you're not sure.

    ex. InputRoot.SOAP.Body.*:Fault.*:Faultstring

    Regards
    H




  • 4.  RE: Extracting faultstring from a SOAP fault in ESQL

    Posted Thu May 11, 2023 02:17 AM
    Edited by Lars Dehli Thu May 11, 2023 02:23 AM

    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
    ------------------------------



  • 5.  RE: Extracting faultstring from a SOAP fault in ESQL

    Posted Thu May 11, 2023 05:13 AM
    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





  • 6.  RE: Extracting faultstring from a SOAP fault in ESQL

    Posted Fri May 12, 2023 03:12 AM

    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...



    ------------------------------
    Matthew Golby-Kirk
    Winchester
    ------------------------------