Forum Discussion

Varthini's avatar
Varthini
Occasional Contributor
12 years ago

Display the request from the project xml file

We are trying to send the request from the browser to the web service and display the response back in the browser. We are getting the response in the browser. But we are not able to load the request from the project xml file in the browser(Though we are able to display the request from the wsdl). We are able to get the test step names but we are not getting the request printed even in the console. Could anyone give the solution for this?

4 Replies

  • Varthini's avatar
    Varthini
    Occasional Contributor
    Hi Paul,
    Thanks for your response. Following is the lines of code you asked for.

    WsdlProject project = new WsdlProject(File.separatorChar+"Project.xml");
    TestSuite testSuite = project.getTestSuiteByName("SampleProject");
    TestCase testCase = testSuite.getTestCaseByName("Create");

    By parsing this way we are able to get all the interfaces and their requests and also the test suite and test step names. We have the requests for each test step in project.xml.But we are not able to retrieve them. Please help in solving.Thanks in advance.
  • PaulDonny's avatar
    PaulDonny
    Regular Contributor
    Great, I have extensive knowledge in this area actually.

    I have a posting here that might help with further questions.

    As for getting the request, if you want it from all test steps in that TestCase, just do the following


    String requestXml;
    for (TestStep step:testCase.getTestStepList()) {
    requestXml = step.getPropertyValue("Request");
    }


    This snippet should be functional in Java, you may need to switch : to in for Groovy to use it. I didn't test it out but I am 99% confident it will work.
  • Varthini's avatar
    Varthini
    Occasional Contributor
    It worked !! Thank you so much. Will post if we have any other doubts. Thanks once again:)