Forum Discussion

fsking's avatar
fsking
New Contributor
7 years ago

Require SOAP Action on a mock response teststep

For mock services there is a property "Require SOAP Action" I can set, to ensure the service consumer sends the proper SOAP action.

For a mock response teststep I can't find that property. Is there an easy way to make sure in a mock response teststep that:

  1.  a header SOAPAction is sent
  2. this SOAPAction header equals the soap action of the selected action in this step

Both can be done with a validation, but then I would have to find and fill the correct soapaction (and type the header) manually for every step. It would be much easier and less error prone to do that when the correct soap action is read from the selected action for the teststep.

 

Is there a way to do that?

5 Replies

  • groovyguy's avatar
    groovyguy
    Champion Level 1

    I hope this fits your use case, here's what I did: I set up a SOAP VirtResponse test step and had it built from an Operation on a wsdl and schema. Using an external client, I ran a test against the listening port with an external client. If my client's SOAPAction matched, the request went through.


    If the SOAPAction did not match, my client received an error. I think that meets what you want? The test step virt response will provide an error to the client if the SOAPAction does not match what was selected.

    • fsking's avatar
      fsking
      New Contributor

      Hi msiadak, thanks for your response. I think I did exactly the same as you describe, but SoapUI NG doesn't validate for SOAPAction.

       

      What I did was create a new VirtResponse Step, selected the operation and interface, filled the port and path and clicked OK. Next filled the response message.

      When running the test with an incorrect SOAPAction, the step still validates and no error is returned to sender.

      Is there some setting or property I can change to make my SoapUI NG work the same as yours?

  • nmrao's avatar
    nmrao
    Champion Level 3

    You should be able to get it using below statement in the Script Dispatch:

    log.info mockRequest.requestHeaders['SOAPAction'][0]

    • fsking's avatar
      fsking
      New Contributor

      Hi nmrao, thanks for your reply. Am I correct in my understanding that the log.info will log this in the Script log, but not do any validation on it? Cause that's what it's doing with me.

      • nmrao's avatar
        nmrao
        Champion Level 3

        fsking

        That is correct. It justs logs the result and does not validate.

        If you want to validate, then do:

         

        //Assign expected soap action value below
        
        def expected = 'your soap action'
        
        def actual = mockRequest.requestHeaders['SOAPAction'][0]
        
        
        assert expected == actual, 'Soap Action not matching'