Forum Discussion

Defender's avatar
Defender
Contributor
13 years ago

[Resolved] Access to resources from the code

Hi!
I need to know the resource structure of my project from the GroovyScript test step. I tried to find it in WsdlProject class (I use SOAP requests in my project) but it contains only methods to access test suites, not resources.
Could you please advice me how I can do this?

The answer on JavaScript is preferred.

5 Replies

  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Could you please clarify what you mean by resources in this context?

    Regards

    Henrik
    SmartBear Stockholm
  • Hi Henrik,

    The project usually consists of resources that are the source for the requests & test suites which contains the test cases.

    For example, let's I have a service with endpoint like http://myserver.com/myservice
    I use the GET request like GET http://myserver.com/myservice/myresource?myId=1
    In such a case I have to create the resource names myResource with parameter myId with type of request.

    So I mean this "myResource" under "resource" term.

    Hope this answers your question,

    Dmitry.
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Thank you for the clarification. Strictly speaking, it's called Resources in REST and Operations in SOAP.

    Anyway, you can access both operations and resources like this (the example below can be applied to the Sample Project):

    import com.eviware.soapui.impl.wsdl.WsdlInterface

    myInterface = (WsdlInterface) testRunner.testCase.testSuite.project.getInterfaceByName("SampleServiceSoapBinding")
    myOperation = myInterface.getOperationByName("login")
    myRequest = myOperation.getRequestByName("Request 1")


    Hope this is what you were looking for!

    Henrik
    SmartBear Stockholm