Passing the SOAP Request from File
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Passing the SOAP Request from File
Hi
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
Chaitanya
- Labels:
-
SOAP
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 really....you 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!
cheers
rich
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 ?
Thanks
Chaitanya
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
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.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes Chris thats correct, i want to call this web service with this huge payload request which is present in that file.
Thanks
Chaitanya
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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...
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Firstly, your test should look something like the below where the Groovy Script is before the web service call.
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.
All you have to do is replace the payload with the call to you Groovy script. E.g.
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.
