Forum Discussion

zkhopekar's avatar
zkhopekar
New Contributor
10 years ago

How to transfer request received in Mock Service into a test step

Hi,

 

I am using a mock service in SoapUI to test the request to request transformation of a webservice.

 

Can someone please tell me how can i capture the request that is received in the mockservice and add it to a test step in my test suit where i have triggered this SOAP request.

 

Any help is HIGHLY appreciated. Thanks

  • Hi,

     

    As I can't remember if it is possible to access a mock request using a property expansion (it may be, but I never have and someone else may be able to help?), my first thought was to:

     

    In the mock's OnRequest script

     

    1.Capture the request data e.g. something like def requestData = mockRequest.requestContent

     

    2.Store it in a Global property e.g. 

     

    import com.eviware.soapui.SoapUI

    SoapUI.globalProperties.setPropertyValue( "requestData", requestData)

     

    3. You can then access this property elsewhere (outside mock scipts etc) using

     

    import com.eviware.soapui.SoapUI

    def requestData = SoapUI.globalProperties.getPropertyValue( "requestData")

     

    Does this sound of any use?

     

    A related, but slightly different mock data transfer situation, including more options for storage, was discussed a while ago in this post: http://community.smartbear.com/t5/SoapUI-Open-Source/Need-to-use-response-elements-from-one-mock-operation-in-another/m-p/98305#M17486

     

    Cheers,

    Rupert

  • rupert_anderson's avatar
    rupert_anderson
    Valued Contributor

    Hi,

     

    As I can't remember if it is possible to access a mock request using a property expansion (it may be, but I never have and someone else may be able to help?), my first thought was to:

     

    In the mock's OnRequest script

     

    1.Capture the request data e.g. something like def requestData = mockRequest.requestContent

     

    2.Store it in a Global property e.g. 

     

    import com.eviware.soapui.SoapUI

    SoapUI.globalProperties.setPropertyValue( "requestData", requestData)

     

    3. You can then access this property elsewhere (outside mock scipts etc) using

     

    import com.eviware.soapui.SoapUI

    def requestData = SoapUI.globalProperties.getPropertyValue( "requestData")

     

    Does this sound of any use?

     

    A related, but slightly different mock data transfer situation, including more options for storage, was discussed a while ago in this post: http://community.smartbear.com/t5/SoapUI-Open-Source/Need-to-use-response-elements-from-one-mock-operation-in-another/m-p/98305#M17486

     

    Cheers,

    Rupert

    • zkhopekar's avatar
      zkhopekar
      New Contributor

      Thank you Rupert! that helped me immensely to update the script i had. Also thanks for the related article im sure ill be using it at some point.

       

      Cheers,

      Zaid

      • rupert_anderson's avatar
        rupert_anderson
        Valued Contributor

        Hi Zaid,

         

        No problem, happy to have helped! :-)

         

        Thanks for the reply and marking the solution as accepted,

         

        Cheers,

        Rup