Forum Discussion
Yes Chris thats correct, i want to call this web service with this huge payload request which is present in that file.
Thanks
Chaitanya
You need a couple of steps to achieve this. Firstly, a Groovy Script to load the file and secondly, the service call itself.
The Groovy script step must come before the service call. Here's an example, let's call the step "Get Payload - Groovy Script"...
import java.io.File;
// Basic code to reference the file.
def fullFolderPath = "C:\some folder\sub folder\";
def fileName = "payload.txt"
def fullFilePath = fullFolderPath + fileName;
// This var will contain the contents of the file.
String returnValue;
log.info("Opening Payload file ${fileName}.");
try {
returnValue = new File(fullFilePath).text;
} catch(FileNotFoundException e){
log.info(e);
}catch(IOException e){
log.info(e);
}
return returnValue;
Then, in the payload section of the request, you can 'call and pull in the result' of the Groovy script by entering...
${Get Payload - Groovy Script#result}
Here's a screenshot to reinforce...
 
- chaitanya5094 years agoOccasional Contributor
Thanks Chris ! I am able to get the data from the file , Can you please let me know how can i call this groovy script from my SOAP Request payload. when i am trying to access the script from SOAP request xml window like ${NameofStep#Result} i am getting "Invalid request" error
- ChrisAdams4 years agoChampion Level 3
Hi, I know you have said the payload is large, but have you tried calling the request with payload pasted in? Might be worth trying just to ensure the request and payload are correct.
- chaitanya5094 years agoOccasional Contributor
For now i am trying with simple payload from the file using this groovy setup. I tried the same file payload by pasting in the xml window of the request and it is working fine.
When test the groovy script alone in am getting the result back from the return variable "returnValue"
what i am not sure is if i am calling the groovy script correctly from the request. i have added the screen shot how i am calling the script from request please let me know if that is correct
Related Content
- 6 years ago
Recent Discussions
- 15 years ago