Forum Discussion

BA_Service_Haus's avatar
BA_Service_Haus
Regular Contributor
12 years ago

Validate against WSDL

Hi,

I have another problem now.
As I always want to validate against the services-wsdl (not the cached one), I wrote the following code:
def wsdlcontext = new com.eviware.soapui.impl.wsdl.support.wsdl.WsdlContext(url);
try{wsdlcontext.load()}catch(error){...

But in case of basic authentication this fails.
Do you know how to set basic authentication to load the wsdl properly?

8 Replies

  • BA_Service_Haus's avatar
    BA_Service_Haus
    Regular Contributor
    Hi,

    thanks, but the links didn't help me.
    Here is my scenario:
    - run a testcase from commandline
    - the first teststep validates the request schema against the current URL (this is to ensure, the request is correct and not out of date)
    - so I add a script-teststep to the testcase as shown in my first post

    The script loads the WSDL (defined by a URL) and then does the validation.
    But if BasicAuthentication is required to access the WSDL, loading fails.

    So do you know the groovy code to use BasicAuth when accessing a WSDL?
  • Hi,

    Try to set the basic authentication using script,


    for( testCase in testRunner.testCase.testSuite.project.testSuites["TestSuiteName"].getTestCaseList() ) {
    log.info("Setting HTTP basic auth for all WSDL test requests in test case ["+
    testCase.getLabel()+"]")
    for( testStep in testCase.getTestStepList() ) {
    if( testStep instanceof WsdlTestRequestStep ) {
    testStep.getTestRequest()
    .setUsername(testSuite
    .getPropertyValue("basicAuthUser"))
    testStep.getTestRequest()
    .setPassword(testSuite
    .getPropertyValue("basicAuthPass"))
    }
    }
    }


    Thanks,
    Jeshtha
  • BA_Service_Haus's avatar
    BA_Service_Haus
    Regular Contributor
    Hello,

    1) I could not check the suggested solution because of an compiler error "...unable to resolve class WsdlTestRequestStep..."
    2) I don't think this will solve my problem because the BasicAuth-data is already set for this testcase (in the Auth-tab).

    When running this testcase manually, a dialog is shown, requesting the basic-authentication data (like when creating a new project using a basicAuth protected wsdl)
    So I guess, the code line wsdlcontext.load() causes this dialog. What I want is to set basic auth data before, to avoid this dialog.
    But I don't know how to do this. Is there any way to load the wsdl with groovy code and setting password and username?
    e.g.
    wsdlcontext.load(username, password)
  • BA_Service_Haus's avatar
    BA_Service_Haus
    Regular Contributor
    Hi,

    I tried to open a case, but wasn't able to.
    When I click the submit button nothing happens.
    I found that choosing the 2nd categorie (What the question is about?) resets both categories to "Please select one...".

    Anyway, I don't think this is necessary.
    In fact all I want is a hint about a proper groovy-code.
  • Hi,

    For the error you receive, add this before the script,
    import com.eviware.soapui.impl.wsdl.teststeps.*

    Thanks,
    Jeshtha
  • BA_Service_Haus's avatar
    BA_Service_Haus
    Regular Contributor
    Hi,

    this avoided the error, but didn't help me to solve my problem.
    Again: I don't think this can be solved by soapUI settings.
    The Auth-Settings of a testcase (as far as I understand) are only related to sending (request) and recieving (response).
    But within a (my) script-assertion these settings are not applied.