Forum Discussion

白夜有点黑's avatar
白夜有点黑
Contributor
5 years ago
Solved

How to get Remote Address value in SoapUI?

As we know, one domain may how more instance Servers (with different IPs) to handle requests, and all requests are assigned by Load Balance. Now I have a scenario need to get the instance server machine ip (which showed as "Remote Address"  property in Chrome Dev Tools View) in SoapUI,  how to do this?

  • avidCoder's avatar
    avidCoder
    5 years ago

    I got your problem. But, Not sure about how to replicate this problem. Anyway, You can use Java servlet code. method name is getRemoteAddr() to fetch it.

     

    There are plenty of links in google.

6 Replies

  • avidCoder's avatar
    avidCoder
    Super Contributor

    I hope this code can help you out:-

    def httpResponseHeaders = context.testCase.testSteps["Request_ Name"].testRequest.response.responseHeaders
    def st = httpResponseHeaders.entrySet().getAt(0).getValue() //In this case Remote address is at 0th position, you can change it based on your header result
    log.info st
    • 白夜有点黑's avatar
      白夜有点黑
      Contributor
      Thanks for your response, but it's not works for me. Looks the "Remote Address" most likely Request property but not Response propery, I did run the code as your solution, but the Response did not give any IP here. And My Response As Below: HTTP/1.1 200 OK Date: Tue, 21 May 2019 09:47:11 GMT Content-Type: image/gif Content-Length: 43 Connection: close Set-Cookie: _id=abcd; expires=Thu, 20-May-21 09:47:11 GMT; path=/ P3P: policyref="/w3c/p3p.xml", CP="CUR ADM OUR NOR STA NID" Cache-Control: private,no-store,no-cache,must-revalidate,proxy-revalidate,no-transform,max-age=0 Pragma: no-cache Expires: 0 X-Frame-Options: ALLOW-FROM GIF89a
      • avidCoder's avatar
        avidCoder
        Super Contributor

        In the screenshot which you have attached earlier, Remote Address Key is there. So, I gave solution based on that. Now, in the response, you are not getting that header key.

        HTTP/1.1 200 OK 
        Date: Tue, 21 May 2019 09:47:11 GMT 
        Content-Type: image/gif 
        Content-Length: 43 
        Connection: close 
        Set-Cookie: _id=abcd; expires=Thu, 20-May-21 09:47:11 GMT; path=/ 
        P3P: policyref="/w3c/p3p.xml", CP="CUR ADM OUR NOR STA NID" 
        Cache-Control: private,no-store,no-cache,must-revalidate,proxy-revalidate,no-transform,max-age=0 Pragma: no-cache Expires: 0 X-Frame-Options: ALLOW-FROM GIF89a

        So, How I am gonna check the Remote Address key out of it?