Hitachi Vantara Pentaho Community Forums
Results 1 to 10 of 10

Thread: send a login request and retrieve token in a txt file

  1. #1
    Join Date
    May 2014
    Posts
    19

    Default send a login request and retrieve token in a txt file

    Hi,

    i'm trying to to send a login request and retrieve the token which is in the response
    i used the HTTP Client and then i do not knowh what to do


    HTTP Client---------->Text File output

    HTTP Clien = here i put the url where i want to login and Http Login = username and HTTP Password = my password

    Text File output = pointing to an empty txt file, in the Field i put token and string as type

    when i execute the transformation, it executes without error but there is nothing in the txt file

    please i need help
    thank you

  2. #2
    Join Date
    Jun 2012
    Posts
    5,534

    Default

    The first thing you should do is to use a tool like curl to successfully retrieve that token.
    That way you find out if your problems are with Kettle or with HTTP.
    So long, and thanks for all the fish.

  3. #3
    Join Date
    May 2014
    Posts
    19

    Default

    I can retrieve the token without problem with soapui using a groovy step for example.
    i want to the same thing kettle.
    i do not know hwo to configure the part for retrieving the token in text file.

  4. #4
    Join Date
    Jun 2012
    Posts
    5,534

    Default

    Your first description made me think of a simple download, suddenly it's all about WSDL.
    Some people use Web-Service-Lookup successfully, I heard.
    But you can use HTTP-Client, too, of course.
    Isn't the security token part of a SOAP Response?
    You'll need a Get-Data-From-XML step, then, to extract the token into a variable for example.
    So long, and thanks for all the fish.

  5. #5
    Join Date
    May 2014
    Posts
    19

    Default

    Hi Marabu,

    so i change my keetle project to this HTTP Client------>Text file output------>Get Data from XML-------->Text file output2
    HTTP Client = i send a login request
    Text file output = i retrieve the login response in xml format
    Get data from xml = i try to retrieve the token number from the response
    Text file output2 = i save the token number in a txt file

    With soapui, to retrieve the token i can use a groovy step and it works.

    -i tried the Get data from XML file, it did not work because the token is in json format inside a xml file.
    -See my xml file is the response after a login request:

    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns="https://zato.io/ns/20130518">
    <soap:Body>
    <login_resp>
    <zato_env>
    <cid>K07FKWNDQVMZTW4JTWZMCNFJJBTQ</cid>
    <result>ZATO_OK</result>
    </zato_env>
    <item>
    <response>{"timestamp": "2015-11-30T17:05:37Z", "data": {"profile": null, "token": "16e5fdcd-fa18-4795-a037-d81ae2e273e2", "endpoints": [{"label": "app", "branches"}, "success": true}</response>
    </item>
    </login_resp>
    </soap:Body>
    </soap:Envelope>

    login request is:
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:gar="app1.app.v1.soap">
    <soapenv:Header/>
    <soapenv:Body>
    <gar:login_req>
    <gar:username>username</gar:username>
    <garassword>password</garassword>
    </gar:login_req>
    </soapenv:Body>
    </soapenv:Envelope>

  6. #6
    Join Date
    Jun 2012
    Posts
    5,534

    Default

    So it's HTTP-Client, then.
    You don't have to write the login response to a file, Get-Data-From-XML can read it from a field.
    Also, you can add a JSON-Input step to extract the token.
    And still you don't need to write the token to a file.
    The token is valid for a session, so why not let it persist via Set-Variable?
    So long, and thanks for all the fish.

  7. #7
    Join Date
    May 2014
    Posts
    19

    Default

    Hi Marabu,

    the step Get date from xml is not working in my case nor Json input step,
    these two methods cannot find element in xml file
    the json is nested inside an xml format

  8. #8
    Join Date
    Jun 2012
    Posts
    5,534

    Default

    Here's the proof of concept I expected from you.
    Don't try with the damaged SOAP response from your opening post (unbalanced parantheses etc.)
    Attached Files Attached Files
    So long, and thanks for all the fish.

  9. #9
    Join Date
    May 2014
    Posts
    19

    Default

    I still do not understand how to achieve my goal.
    your example is working fine if in get data at data we put the response in xml format
    but how to get this response , from which step?

    to get the response, i triend this:
    Generate rows---->HTTP client----->Text file output (response.xml)

    but what should i put in generate rows? as i understanf i cannot use HTTP client without nothing before

    Thank you for your help

  10. #10
    Join Date
    Jun 2012
    Posts
    5,534

    Default

    You set Limit to the number of requests you want to make - since you want to acquire a session token, set Limit = 1.
    You can leave the field list empty and specify all the configuration options literally or via variables in HTTP-Client.
    Instead of Text-File-Output you can use Set-Variable to save the token you extracted with Get-Data-From-XML and JSON-Input.

    Generate-Rows => HTTP-Client => Get-Data-From-XML => JSON-Input => Set-Variable
    So long, and thanks for all the fish.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.