Forum Discussion

schill's avatar
schill
New Contributor
8 years ago

Groovy - HTTPBuilder - PKIX Path building Failed Error

I'm fairly new to Groovy & SoapUING. I hope someone on this forum can help me figure out and fix this error. Thanks!

 

What I'm trying to do: Iterate through each db row item in a table and use that as input to make a HTTPBuilder request (GET or POST) either as a query in path (add baseURL/path/hello) or through parameters(add baseURL/path?searchNode="hello"). The baseURL is something like thishttps://search-test-env.ser.com.

 

Where I'm getting stuck: When I try to post a request through HTTPBuilder.

 

Error: PKIX Path Building Failed

 

Other related information:

  • Code is in Groovy.
  • Using ReadyAPI to run the scripts.
  • Recently imported the httpbuilder jar into ReadyAPI/lib folder along with some dependencies. Of the dependencies available with httpbuilder, ReadyAPI already had few so I only picked up the ones missing. jar names in screen shot.
  • The Service works with a manual request without groovy (simple GET on the baseURL/path) and it also works with query by string or by parameter.
  • The certificate is already available in the Keystore. Tried using keytool (available in ReadyAPI/bin folder) command through cmd but receiving a filenotfound error). Tried to import into the ReadyAPI\jre\lib\security.

Code:

 

 

def qryPrmRqstHTTPBldr( pBaseUrl, pPath, pQuery, pMethod ) {
    def ret = null
    def http = new HTTPBuilder()
    def meth

    if ( pMethod == 'GET') {
            meth = Method.GET
    }
    else if ( pMethod == 'POST') {
            meth = Method.POST
    }
    // perform a GET/POST request, expecting TEXT response
    http.request(pBaseUrl, meth, ContentType.TEXT) { req ->
        uri.path = pPath
        uri.query = pQuery
        /*
        headers.'User-Agent'         = 'Apache-HttpClient/4.5.1 (Java/1.8.0_66)'
        headers.'Host'               = 'xxx-xx-xxx.xxx.xxx'
        headers.'Accept-Encoding'    = 'gzip,deflate'
        headers.'Connection'         = 'Keep-Alive'
        */
        log.info "HERE 12"
        log.info System.getProperty("java.runtime.version")
        log.info System.getProperty("javax.net.ssl.trustStore")
        log.info System.getProperty("javax.net.ssl.keyStore")
        log.info System.getProperty("java.home")
        log.info System.getProperty("java.class.path")        

        // response handler for a success response code
        response.success = { resp, reader ->
            log.info "HERE 13"
                println "response status: ${resp.statusLine}"
                println 'Headers: -----------'
            log.info "HERE 15"

                ret = reader.getText()
            log.info "HERE 16"

                println 'Response data: -----'
                println ret
                println '--------------------'
            }
    }
    log.info "HERE 17"
      return ret
}