cancel
Showing results for 
Search instead for 
Did you mean: 

Fetching inputs from basic auth account

aditya_gupta41
Contributor

Hello Experts,

I have an interface that is to be created over 3 different SOAP request as a positive flow.
Login → Check/update Data → Logout

The first step of Login requires username and password to be sent along the SOAP request.
The Envelope loops like this:

<env:Envelope
    xmlns:env="http://www.w3.org/2003/05/soap-envelope"
    xmlns:ns0="http://siemens.com/agilews">
    <env:Header/>
    <env:Body>
        <ns0:login
            xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
            <credentials>
                <username>$credentials.username</username>
                <password>$credentials.password</password>
                <application>$credentials.application</application>
            </credentials>
        </ns0:login>
    </env:Body>
</env:Envelope>

Now I can hardcode $credentials.application but from business POV, I cannot do the same for username and password. Is there any way in which I can create a basic auth account using this username and password and fetch it as a flat value and pass it in SOAP?

Thanks in Advance

1 ACCEPTED SOLUTION

aditya_gupta41
Contributor

Hello,

I am getting below error when writing above expressions in HTTP Entity:

failure:
“HTTP Entity: Cannot lookup a property on a null value”
value:
“Please check expression syntax and data types.”
reason:
“Please check expression syntax and data types.”

I have created a REST POST basic auth account with username and password.

Do you have any suggestion?

Thanks,
Aditya

View solution in original post

5 REPLIES 5

del
Contributor III

@aditya.gupta41,

I tested a few things with the SOAP snap, but I could not get my ideas to work. However, I had more success testing an idea with the REST POST snap, which does allow you to access the account.username and account.password fields of a REST Basic Auth account.

You could potentially use the REST POST snap with the SOAP endpoint URL as the Service URL value, add the basic auth account to the snap, and use the following as an expression in the HTTP Entity field.

'<env:Envelope
    xmlns:env="http://www.w3.org/2003/05/soap-envelope"
    xmlns:ns0="http://siemens.com/agilews">
    <env:Header/>
    <env:Body>
        <ns0:login
            xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
            <credentials>
                <username>' + account.username + '</username>
                <password>' + account.password + '</password>
                <application>' + $credentials.application + '</application>
            </credentials>
        </ns0:login>
    </env:Body>
</env:Envelope>'

(Note 1: I tried the same with the HTTP Client snap, but it didn’t seem to have access to the account properties)

(Note 2: The account properties feature of the REST snaps is not publicly documented as far as I can tell, but it has been referenced by SnapLogic employees in multiple community posts; so keep that consideration in mind. I use it in multiple scenarios for hiding API keys)

@del
Do you have any suggestions to above error?

Thanks

@aditya.gupta41 ,

My first thoughts are that you have variables in your HTTP Entity code that do not have values from upstream. REST Post is likely not null-safe. I posted my sample code based on your originally posted code. So, if you’re using my sample, you need to make sure $credentials.application is populated upstream, modify the variable for your case, or remove it from your test.

Second thought is you may have put a ‘$’ in front of ‘account.username’ or ‘account.password’ and it is treating it like a variable instead of the account object.

If those thoughts are not the case, can you post the contents of the HTTP Entity?

Hello @del ,

The solution worked as soon as we mapped ‘$credentials.application’.

Thanks for your help.