kaushikragavan
12 years agoNew Contributor
Passing argument to an operation
Hi,
I am a newbie to SOAPUI and trying to integrate the source with my application.
I am trying the example from the soapui website and having some issues while passing an argument to an operation.
package com.ws.test;
import java.util.ArrayList;
import java.util.List;
import javax.wsdl.BindingInput;
import javax.wsdl.BindingOperation;
import javax.wsdl.Definition;
import javax.wsdl.Operation;
import com.eviware.soapui.impl.WsdlInterfaceFactory;
import com.eviware.soapui.impl.wsdl.WsdlInterface;
import com.eviware.soapui.impl.wsdl.WsdlOperation;
import com.eviware.soapui.impl.wsdl.WsdlProject;
import com.eviware.soapui.impl.wsdl.WsdlRequest;
import com.eviware.soapui.impl.wsdl.WsdlSubmit;
import com.eviware.soapui.impl.wsdl.WsdlSubmitContext;
import com.eviware.soapui.model.iface.Response;
import com.eviware.soapui.support.SoapUIException;
public class SoapMain extends SoapUIException {
private static final long serialVersionUID = 1L;
public static void main(String[] args) {
try {
// create new project
WsdlProject project = new WsdlProject();
long startTime = System.currentTimeMillis();
// import amazon wsdl
WsdlInterface iface = WsdlInterfaceFactory.importWsdl( project, "http://xxxxxx?WSDL", true )[0];
// get desired operation
WsdlOperation operation = (WsdlOperation) iface.getOperationByName( "getDisplay");
//iface.findBindingOperation(definition, bindingOperationName, inputName, outputName)
WsdlRequest request = operation.addNewRequest( "My request" );
// generate the request content from the schema
request.setRequestContent( operation.createRequest( true ) );
// submit the request
@SuppressWarnings("rawtypes")
WsdlSubmit submit = (WsdlSubmit) request.submit( new WsdlSubmitContext(request), false );
// wait for the response
Response response = submit.getResponse();
// print the response
String content = response.getContentAsString();
System.out.println( content );
long endTime = System.currentTimeMillis();
System.out.println("WS using SoapUI client took " + (endTime - startTime) + " milliseconds");
} catch (Exception e) {
}
}
}
If I pass an argument to iface.getOperationByName( "getDisplay(keys,"EN"")"), the WSDL doesn`t get imported and the connection is closed. I am working with SOAPUI 4.6.1 version.
I am a newbie to SOAPUI and trying to integrate the source with my application.
I am trying the example from the soapui website and having some issues while passing an argument to an operation.
package com.ws.test;
import java.util.ArrayList;
import java.util.List;
import javax.wsdl.BindingInput;
import javax.wsdl.BindingOperation;
import javax.wsdl.Definition;
import javax.wsdl.Operation;
import com.eviware.soapui.impl.WsdlInterfaceFactory;
import com.eviware.soapui.impl.wsdl.WsdlInterface;
import com.eviware.soapui.impl.wsdl.WsdlOperation;
import com.eviware.soapui.impl.wsdl.WsdlProject;
import com.eviware.soapui.impl.wsdl.WsdlRequest;
import com.eviware.soapui.impl.wsdl.WsdlSubmit;
import com.eviware.soapui.impl.wsdl.WsdlSubmitContext;
import com.eviware.soapui.model.iface.Response;
import com.eviware.soapui.support.SoapUIException;
public class SoapMain extends SoapUIException {
private static final long serialVersionUID = 1L;
public static void main(String[] args) {
try {
// create new project
WsdlProject project = new WsdlProject();
long startTime = System.currentTimeMillis();
// import amazon wsdl
WsdlInterface iface = WsdlInterfaceFactory.importWsdl( project, "http://xxxxxx?WSDL", true )[0];
// get desired operation
WsdlOperation operation = (WsdlOperation) iface.getOperationByName( "getDisplay");
//iface.findBindingOperation(definition, bindingOperationName, inputName, outputName)
WsdlRequest request = operation.addNewRequest( "My request" );
// generate the request content from the schema
request.setRequestContent( operation.createRequest( true ) );
// submit the request
@SuppressWarnings("rawtypes")
WsdlSubmit submit = (WsdlSubmit) request.submit( new WsdlSubmitContext(request), false );
// wait for the response
Response response = submit.getResponse();
// print the response
String content = response.getContentAsString();
System.out.println( content );
long endTime = System.currentTimeMillis();
System.out.println("WS using SoapUI client took " + (endTime - startTime) + " milliseconds");
} catch (Exception e) {
}
}
}
If I pass an argument to iface.getOperationByName( "getDisplay(keys,"EN"")"), the WSDL doesn`t get imported and the connection is closed. I am working with SOAPUI 4.6.1 version.