Forum Discussion

Bill_In_Irvine's avatar
Bill_In_Irvine
Contributor
7 years ago
Solved

missing several packages from eviware - groovy allows only SoapUI, model, and support.

Made a mistake by posting this in open source SoapUI. (moderators, there should be a way for moving posts between discussion groups).   Anyway here is my problem:    I am using Ready! API 2.0 and...
  • Bill_In_Irvine's avatar
    Bill_In_Irvine
    7 years ago
    I put a ticket in. The answer I got is that some of the objects have late binding and won't appear in code completion. 
     
    One way to load APIs, I am told is use the getContextClassLoader(): Here is an example SmartBear suggested that worked for me so com.eviweare.soapui.impl - though not appearing in code completion, was proven to work as though it is activated by late binding:
     
    import com.eviware.soapui.impl.support.HttpUtils
     
    log.info "version? " + context.getProperty( "version" )
    HttpUtils.extractHost("http://service.com")

    Thread.currentThread().getContextClassLoader().addURL(new URL('file:///home/billmartin/SmartBear2/ReadyAPI-2.0.2/lib/commons-math-1.2.jar'))
    def number = Class.forName("org.apache.commons.math.complex.Complex").newInstance(1, 2)
    log.info("The real part is $number.real")
     
    I also figured out a way to update the header inside my groovy script based on seeing on some thread this code:
     
     
    import com.eviware.soapui.support.types.StringToStringMap
    def headers = new StringToStringMap()

    headers.put( "Content-Type", "application/json") // Replace values with those you need
    log.info "Added Content-Type: application/json"
    request.requestHeaders = headers

    log.info "headers size now: " + (request.requestHeaders.size())
    log.info request.requestHeaders
     
    I haven't come across any information about late binding in the documentation. This information might help other people to use the Ready! API SoapUI API 
     
    thanks
     
    Bill