Forum Discussion

chaitanya509's avatar
chaitanya509
Occasional Contributor
3 years ago

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

9 Replies

  • richie's avatar
    richie
    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 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 

    • chaitanya509's avatar
      chaitanya509
      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 ?

       

      Thanks 

      Chaitanya

  • ChrisAdams's avatar
    ChrisAdams
    Champion Level 3

    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.

    • chaitanya509's avatar
      chaitanya509
      Occasional Contributor

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

       

      Thanks 

      Chaitanya

      • ChrisAdams's avatar
        ChrisAdams
        Champion Level 3

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

        ā€ƒ