question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Variables in included files

See original GitHub issue

When I use an include file with < the environment variables within are not processed.

I would like to call my authenticate.http which returns a token from within another http file.

Working Example:

# @name authenticate
POST http://{{host}}:{{port}}/lagan/services/FLAuth HTTP/1.1
Content-Type: text/xml
SOAPAction: authenticate

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:flt="http://www.lagan.com/wsdl/FLTypes" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
   <soapenv:Header>
    <wsse:Security>
      <wsse:UsernameToken xmlns:wsse='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd' >
        <wsse:Username>{{username}}</wsse:Username>
        <wsse:Password Type='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText'>
           {{password}}
        </wsse:Password>
      </wsse:UsernameToken>
    </wsse:Security>
   </soapenv:Header>
  <soapenv:Body>
    <authenticate xmlns=""/>
  </soapenv:Body>
</soapenv:Envelope>

###

@binary-token = {{authenticate.response.body.//*[name()='wsse:BinarySecurityToken']}}

# @name retrieveCaseDetails
POST http://{{host}}:{{port}}/lagan/services/FL HTTP/1.1
Content-Type: text/xml
SOAPAction: retrieveCaseDetails

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:flt="http://www.lagan.com/wsdl/FLTypes" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
   <soapenv:Header>
    <wsse:Security>
    	<wsse:BinarySecurityToken>{{binary-token}}</wsse:BinarySecurityToken>
    </wsse:Security>
   </soapenv:Header>
   <soapenv:Body>
      <flt:FWTCaseFullDetailsRequest>
         <flt:CaseReference>BAE4LCM5-101002585690</flt:CaseReference>
         <!--1 or more repetitions:-->
         <Option>all</Option><!-- all, core, eforms-r, eforms-rw, events, form, fullform, notes, tasks, workflow, interactions, eform-data -->
      </flt:FWTCaseFullDetailsRequest>
	</soapenv:Body>
</soapenv:Envelope>

###

This works and grabs the {{binary-token}}. But I’d like to put the authenticate into it’s own file for reuse with other .http files.

Failing Example:

# @name authenticate
POST http://{{host}}:{{port}}/lagan/services/FLAuth HTTP/1.1
Content-Type: text/xml
SOAPAction: authenticate

< authenticate.http

@binary-token = {{authenticate.response.body.//*[name()='wsse:BinarySecurityToken']}}

# @name retrieveCaseDetails
POST http://{{host}}:{{port}}/lagan/services/FL HTTP/1.1
Content-Type: text/xml
SOAPAction: retrieveCaseDetails

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:flt="http://www.lagan.com/wsdl/FLTypes" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
   <soapenv:Header>
    <wsse:Security>
    	<wsse:BinarySecurityToken>{{binary-token}}</wsse:BinarySecurityToken>
    </wsse:Security>
   </soapenv:Header>
   <soapenv:Body>
      <flt:FWTCaseFullDetailsRequest>
         <flt:CaseReference>BAE4LCM5-101002585690</flt:CaseReference>
         <!--1 or more repetitions:-->
         <Option>all</Option><!-- all, core, eforms-r, eforms-rw, events, form, fullform, notes, tasks, workflow, interactions, eform-data -->
      </flt:FWTCaseFullDetailsRequest>
	</soapenv:Body>
</soapenv:Envelope>

###

But the {{username}} and {{password}} in authenticate.http are treated as plain-text literals.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Huachaocommented, Jul 16, 2019

@warlord0 sorry, I misunderstand your case, and resolving variables in imported body file is not supported currently.

0reactions
warlord0commented, Jul 16, 2019

Thank for the reply.

Keep up the great work. Loving this extension. Made documentation and samples a breeze.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Passing a variable from one php include file to another
The parent file has access to variables in both included files. When including files in PHP, it acts like the code exists within...
Read more >
Variables scope in included files - Dev Talk
"When a file is included, the code it contains inherits the variable scope of the line on which the include occurs. Any variables...
Read more >
include - Manual
When a file is included, the code it contains inherits the variable scope of the line on which the include occurs. Any variables...
Read more >
Variables in #include files
Hi I writing a script, for organization, I want all ancillary variables in a different *.au3 file and all the main functions in...
Read more >
Using Variables
Defining variables in included files and roles . You can define variables in reusable variables files and/or in reusable roles. When you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found