Ask a Question

Passing the SOAP Request from File

Occasional Contributor

Passing the SOAP Request from File



I have to make a SOAP webservice call with a huge request which is there in a file, is it possible to pass this request xml file from SOAP UI to make a web service call ? can you please provide some pointers for this ?


Thanks in advance 


Community Hero

Hey @chaitanya509 


so you have a SOAP request that you won't to setup in SoapUI - is that correct?


The easiest way to do this is to Import the .wsdl (web service definition language file) which is a file that describes the SOAP webservice, the requests and the endpoint.


Once you've imported the .wsdl, a SOAP Service with the different operations/requests defined in your .wsdl will be automatically generated along with the schema valid payload (also defined via  the .wsdl).


you can then create SOAP test steps which are children of the operations/requests defined in the SOAP Service.


That's about it might have to do some additional stuff to enable the authentication on your requests  but that  all depends on what is contained within your .wsdl file.


SO - first thing you need to do - ask your developers for the .wsdl for the SOAP service you need to create requests for, then import the file and go from there!





if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
Occasional Contributor

Thanks Rich, I have already done this setup and i could make a simple request call successfully.


But in real use case the request xml is very huge which is present in a xml file, so i am looking ways to pass this request xml file to this web service.


Is that possible with soap ui ? Can you please point some references ?




Community Leader


I read this as.....

"I have a huge request payload and I don't want to clog up SoapUI with it.  Is is possible for SoapUI to load the contents of this file into a SoapUI request and then run the request?"


If so, then yes.  But before I describe, please let me know that is what you want.

Occasional Contributor

Yes Chris thats correct, i want to call this web service with this huge payload request which is present in that file. 




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"...


// 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;"Opening Payload file ${fileName}.");

try {
	returnValue = new File(fullFilePath).text;
} catch(FileNotFoundException e){;
}catch(IOException 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...

Screenshot 2021-09-22 083650.png

Occasional 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 

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.

Occasional 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 






Firstly, your test should look something like the below where the Groovy Script is before the web service call.

Screenshot 2021-09-23 082055.png

When you want to run this, run the whole test.


Secondly, where to paste in the script command.  Below is an example service that passes a JSON body.  You can see the JSON payload I want to submit here.

Screenshot 2021-09-23 083016.png


All you have to do is replace the payload with the call to you Groovy script.  E.g.

Screenshot 2021-09-23 083513.png


A couple of additional points here.  You will have noticed that my example contained a JSON payload and not XML.  I've done this sort of things with both.  To fix my example to work with XML all I need to change is the Media Type.  In the screenshot above, just above the bottom pane, there is a dropdown.  You'll need either application/xml or test/xml, though I imagine you've done this correctly if the service does indeed work with XML payload in the request and not in file.


Once you've done that, run the whole test.  If the service call doesn't work, the Raw tab can be really helpful.  The Raw is only populated once the test request is made.  What is shows you is the full and actual request SoapUI sent to your service.

Screenshot 2021-09-23 083928.png


Showing results for 
Search instead for 
Did you mean: