Forum Discussion

DMc-Cabe's avatar
DMc-Cabe
Occasional Contributor
11 years ago

[Resolved] httpbuilder support?

Hi There

I'm trying to use httpbuilder to verify if certain urls which I'm passing into the get requests are valid. (I was hoping I could verify this by returning the header and asserting the page size) I have copied all of the appropriate jar file dependencies into bin/ext dir of soapUI pro but I'm still getting the following error when i execute my script

"Startup failed: Script6.groovy: 9: unable to resolve class groovyx.net.http.HTTPBuilder @ line 9, column 1. import groovyx.net.http.HTTPBuilder ^ org.codehaus.groovy.syntax.SyntaxException: unable to resolve class groovyx.net.http.HTTPBuilder @ line 9, column 1. at ...."

import groovyx.net.http.HTTPBuilder
import static groovyx.net.http.Method.*
import static groovyx.net.http.ContentType.*

any suggestions on what else i could try in order to get this working please?

alternatively, could you suggest any other method for me to pass multiple different urls which have extracted from json nodes in a search response, so that I can verify that each url resolves to a valid html page?
  • redfish4ktc2's avatar
    redfish4ktc2
    Super Contributor
    I guess this feature is not in groovy-all jar embedded with soapui
    Add the httpbuilder jars (with dependencies if any) in the ext directory. If this does not work, put it in the lib directory
  • DMc-Cabe's avatar
    DMc-Cabe
    Occasional Contributor
    thanks for the suggestion - I have the jar files in both /lib and /bin/ext and i'm still getting the same error
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi,

    Extra libraries should be added to the 'lib' folder. Have you closed/reopened SoapUI Pro after adding the jar files?

    Regards,

    Giscard
    SmartBear Support
  • DMc-Cabe's avatar
    DMc-Cabe
    Occasional Contributor
    Ok copying into /lib seems to have resolved that part of my problem

    I'm now getting a different error "could not initialize groovyx.net.http.ParserRegistry"

    I've seen a ticket on this forum with the same problem but no solution i'm afraid

    viewtopic.php?f=5&t=17430
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi,

    Do you have an import statement that covers that class?
    import groovyx.net.http.ParserRegistry perhaps?

    Regards,

    Giscard
    SmartBear Support
  • DMc-Cabe's avatar
    DMc-Cabe
    Occasional Contributor
    I do - here's a sample http.get script which I'm trying run

    import org.codehaus.groovy.runtime.StackTraceUtils

    import groovyx.net.http.HTTPBuilder
    import groovyx.net.http.ParserRegistry
    import static groovyx.net.http.Method.GET
    import static groovyx.net.http.ContentType.TEXT


    def http = new HTTPBuilder('http://www.google.com')

    http.get( path : '/search',
    contentType : TEXT,
    query : [q:'Groovy'] ) { resp, reader ->

    println "response status: ${resp.statusLine}"
    println 'Headers: -----------'
    resp.headers.each { h ->
    println " ${h.name} : ${h.value}"
    }
    println 'Response data: -----'
    System.out << reader
    println '\n--------------------'
    }
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi,

    What is the exact version of the jar file that you have added?

    Thanks,

    Giscard
    SmartBear Support
  • DMc-Cabe's avatar
    DMc-Cabe
    Occasional Contributor
    eventually got it working - I cleared out the bin/ext dir and copied back in all the http-builder-0.6 jar files including all dependencies My groovy script is now working !!

    thanks