Forum Discussion

kaushikragavan's avatar
kaushikragavan
New Contributor
12 years ago

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.
  • SiKing's avatar
    SiKing
    Community Expert
    kaushikragavan wrote:
    If I pass an argument to iface.getOperationByName( "getDisplay(keys,"EN"")"), the WSDL doesn`t get imported and the connection is closed.

    Do you seriously have all those enclosed quotes?
  • SiKing wrote:
    kaushikragavan wrote:
    If I pass an argument to iface.getOperationByName( "getDisplay(keys,"EN"")"), the WSDL doesn`t get imported and the connection is closed.

    Do you seriously have all those enclosed quotes?


    OOPS! that`s a typo. I am trying to call a getDisplay operation, iface.getOperationByName( "getDisplay(keys,"EN")"),where 'keys' is an argument of type List<String>