Forum Discussion

guruprasadt's avatar
guruprasadt
New Contributor
12 years ago

Need Help with SoapUi API

Hi,
I am new to Soap UI and I need to write a java code that makes soapui api calls to a rest web service by setting the request parameters. Can you help lead me to some example code how it is done?

Thank you,
Guruprasad

4 Replies

  • Yes,
    But that is not what i need. The documentation explains on how to test a REST web service using SoapUI UI interface.

    I need to make the same call programatically in Java using the SoapUI apis.

    Example:
    Here is a code snippet to make calls to a soap webservice using the soapui api.

    // create new project
    WsdlProject project = new WsdlProject();

    // import amazon wsdl
    WsdlInterface iface = WsdlInterfaceFactory.importWsdl( "http://www.mycorp.com/somewsdl.wsdl", true )[0];

    // get desired operation
    WsdlOperation operation = (WsdlOperation) iface.getOperationByName( "MyOperation" );

    // create a new empty request for that operation
    WsdlRequest request = operation.addNewRequest( "My request" );

    // generate the request content from the schema
    request.setRequestContent( operation.createRequest( true ) );

    // submit the request
    WsdlSubmit submit = (WsdlSubmit) request.submit( new WsdlSubmitContext(), false );

    // wait for the response
    Response response = submit.getResponse();

    // print the response
    String content = response.getContentAsString();
    System.out.println( content );
    assertNotNull( content );
    assertTrue( content.indexOf( "404 Not Found" ) > 0 );


    I want the code counterpart in soap ui api for the REST Web service.
  • SiKing's avatar
    SiKing
    Community Expert
    !!!Untested!!!
    I believe the "Wsdl" in "WsdlProject" is only historical (SoapUI started as a tool for testing SOAP WS only). Try that code with a REST project.