How the pass a session ID for a SOAP API in ADF

Remon van Ramele 0 Reputation points
2023-01-28T22:42:24.6466667+00:00

Hi all,

Struggling for a while now with creating an API request in ADF to load data from a SOAP API. I'm having difficulties with passing a session ID to another API request which will provide the transactional data.

  • step 1: API request (OpenSession) to get a session ID
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:soap1="http://www.e-boekhouden.nl/soap">
   <soap:Header/>
   <soap:Body>
      <soap1:OpenSession>
         <!--Optional:-->
         <soap1:Username>bifirst</soap1:Username>
         <!--Optional:-->
         <soap1:SecurityCode1>XXXXXXXX</soap1:SecurityCode1>
         <!--Optional:-->
         <soap1:SecurityCode2>XXXXXXXX</soap1:SecurityCode2>
         <!--Optional:-->
         <soap1:Source>?</soap1:Source>
      </soap1:OpenSession>
   </soap:Body>
</soap:Envelope>

output

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <soap:Body>
      <OpenSessionResponse xmlns="http://www.e-boekhouden.nl/soap">
         <OpenSessionResult>
            <ErrorMsg>
               <LastErrorCode/>
               <LastErrorDescription/>
            </ErrorMsg>
            <SessionID>{BDA87C20-7B5E-4441-8237-4876528DD79D}</SessionID>
         </OpenSessionResult>
      </OpenSessionResponse>
   </soap:Body>
</soap:Envelope>
  • Step 2: Run API request to get the mutations (GetMutaties API)
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:soap1="http://www.e-boekhouden.nl/soap">
   <soap:Header/>
   <soap:Body>
      <soap1:GetMutaties>
         <!--Optional:-->
         <soap1:SessionID>{BDA87C20-7B5E-4441-8237-4876528DD79D}</soap1:SessionID>
         <!--Optional:-->
         <soap1:SecurityCode2>XXXXX</soap1:SecurityCode2>
         <!--Optional:-->
         <soap1:cFilter>
         </soap1:cFilter>
      </soap1:GetMutaties>
   </soap:Body>
</soap:Envelope>

When I manually add the session ID to the GetMutaties API it works fine (till the session ends off course..)

Below a screendump of how I have done this in SOAPUI, and this works fine.

User's image

Can anyone please help me with how I can handle this in ADF?

Many thanks in advance!

Kind Regards,

Remon

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
9,648 questions
{count} votes

1 answer

Sort by: Most helpful
  1. MartinJaffer-MSFT 26,036 Reputation points
    2023-01-30T18:10:58.7133333+00:00

    @Remon van Ramele Hello and welcome to Microsoft Q&A.

    I understand you aren't sure how to put together a 2-step operation for getting XML from REST api.

    For you first step, use a Web activity, not a copy activity. The benefit of using Web activity, is you can directly reference the output, unlike most Copy Activity.

    To make things easier, let us put a Set Variable between the Web activity and the Copy activity. To this Set Variable we will give an expression something like @activity('Get Session token').output.value['soap:Envelope']['soap:Body'].OpenSessionResponse.OpenSessionResult.SessionID

    Without a ready api to test again, I'm not 100% sure the envelope and body are needed. I put them in bracket notation so I could quote in case the : caused problems.

    Once you have the id (including the { }) in the variable, inserting it into the body of your request becomes easier, taking the form of @{variables('tokenVar')} . The outer { } serve to tell ADF where the expression ends and the literal text resumes. Also converts the contents to string.

    
             <soap1:SessionID>@{variables('tokenVar'}</soap1:SessionID>
    
    0 comments No comments