Forum Discussion

S_Seydel's avatar
S_Seydel
Contributor
9 years ago

Display requests sent from external client to mock service

Hi,

 

in my scenario the application to test sends soap requests to an external web service, I want to validate the requests sent by our application and therefore simulate the external web service the requests are sent to by using a SoapUI mock service.

 

What I already have is a running mock service in SoapUI built from the web service's wsdl file. When sending soap requests from the application to test running on a web server on a virtual machine to the mock service, the application shows a message that it could successfully connect to the web service.

If I shut off the mock service in SoapUI, the application shows a connection failure, so I'm sure it really sends it's requests to the mock service.

 

My first problem is that in SoapUI the requests sent from the application to the mock service are not displayed. I expected to see them in the 'Last Request' tab for the response of the operation the request was sent to.

 

My second problem is, that the response specified does not seem to be sent to the application to test, from which the request was sent to the mock service.

 

To make a long question short:

How do I display in SoapUI requests sent from an application on my web server to the mock service, and how do I let the mock service sent the specified response back to my application?

 

 

Many thanks in advance.

  • Thank you for your reply.

     

    In the end the solution was to change the host name in the mock service options.

    For some reason when the host computer's name was entered, as automatically done by SoapUI, the behaviour was as described above. After I changed it to the host computer's IP the requests sent are displayed under the 'Last Request' tab in the response window, as I hoped for and responses are sent back.

3 Replies

  • Thank you for your reply.

     

    In the end the solution was to change the host name in the mock service options.

    For some reason when the host computer's name was entered, as automatically done by SoapUI, the behaviour was as described above. After I changed it to the host computer's IP the requests sent are displayed under the 'Last Request' tab in the response window, as I hoped for and responses are sent back.

    • rupert_anderson's avatar
      rupert_anderson
      Valued Contributor

      Ok, that makes sense. If you're happy to, please mark the post as solved to guide others, maybe setting your post as the solution.

      Thanks,

      Rup

  • rupert_anderson's avatar
    rupert_anderson
    Valued Contributor

    Hi,

     

    This should be possible with some Groovy scripting in the mock.

     

    Under the mock operation, if you select DISPATCH: SCRIPT, then you can get hold of the mock request and also extract parts of it e.g.

     

    def requestXMLHolder = new com.eviware.soapui.support.XmlHolder(mockRequest.requestContent)
    requestXMLHolder.declareNamespace("inv","http://soapui.cookbook.samples/schema/invoice")
    def requestInvoiceNo=requestXMLHolder.getNodeValue("//inv:createInvoice[1]/inv:invoiceNo[1]")

     Then, you could try logging it explicitly e.g. like in this post:

     

    http://community.smartbear.com/t5/SoapUI-Open-Source/Log-entire-REST-request-in-a-mock-rest-service/m-p/101705#M17856

     

    Or writing the request XML to a file, something similar (but not exactly the same) is shown here:

     

    http://community.smartbear.com/t5/SoapUI-NG/Capturing-Request-and-Response-XML-in-log-file/m-p/15991/highlight/true#M7091

     

    Does that give you enough to go on?

     

    Regards,

    Rup