Forum Discussion

parmeet's avatar
parmeet
Occasional Contributor
15 years ago

Code doesn't work

This code i found on the link http://www.soapui.org/architecture/integration.html

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

// import amazon wsdl
WsdlInterface iface = project.importWsdl( "http://localhost:8082/soapui-tests/test1/TestService.wsdl", true )[0];

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

// 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  );


Its not updated is it ?
Seems like public WsdlInterface[] importWsdl(java.lang.String url, boolean createRequests) has been deprecated .. Please help !!

1 Reply

  • parmeet's avatar
    parmeet
    Occasional Contributor
    Hi,

      I finally got it to work .. Made some changes .. Here's the code

    import java.io.IOException;

    import com.eviware.soapui.impl.wsdl.WsdlProject;
    import com.eviware.soapui.impl.wsdl.WsdlInterface;
    import com.eviware.soapui.impl.WsdlInterfaceFactory;
    import com.eviware.soapui.impl.wsdl.WsdlOperation;
    import com.eviware.soapui.impl.wsdl.WsdlRequest;
    import com.eviware.soapui.impl.wsdl.WsdlSubmit;
    import com.eviware.soapui.impl.wsdl.WsdlSubmitContext;

    import org.apache.xmlbeans.XmlException;
    import org.junit.Assert;
    import com.eviware.soapui.impl.wsdl.submit.transports.http.support.attachments.WsdlSinglePartHttpResponse;
    import com.eviware.soapui.model.iface.Request.SubmitException;
    import com.eviware.soapui.support.SoapUIException;


    public class basic {

    public static void main(String[] args) throws SubmitException, XmlException, IOException, SoapUIException{
    // create new project
    WsdlProject project = new WsdlProject();

    // import service
    WsdlInterface iface = WsdlInterfaceFactory.importWsdl( project, "http://192.168.0.153:8080/axis2/services/Calculator?wsdl", true )[0];

    // get "GetPage" operation
    WsdlOperation operation = (WsdlOperation) iface.getOperationByName( "add" );

    // 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(request), false );

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

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

    }
    }


    My question is :- Now what if i want to send parameters along with the request ..  (the add operation takes 2 numbers)

    Help !!!!!!!!!!!!!
    Thank you !!