0

I am trying to call the SOAPUI classes directly in my units test , so that I can directly provide the link to the WSDL and call individual operations.

The reason behind doing this is , I intend to create individual test cases and suites using these classes (without having to use the actual UI)

I am referring to the example on this page on the SOAPUI website. I have downloaded all dependencies required for SoapUI maven plugin listed here

After fixing the project buildpath for the following code:

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;

public class someClassName
{
  // Create new wsdl project
  WsdlProject wsdlProject = new WsdlProject();

  // Import webservice wsdl
  WsdlInterface iface = WsdlInterfaceFactory.importWsdl(wsdlProject , "http://localhost:8080/MyWebService/MyWebService?wsdl", true)[0];

  // Get desired operation
  WsdlOperation someOp = (WsdlOperation) iface.getOperationByName("someOpName");

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

  // Generate the request content from the schema
  someOpRequest.setRequestContent(someOp.createRequest(true));

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

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

  // Print the response
  String content = response.getContentAsString();
  System.out.println(content);
}

I am getting compilation error: .

Syntax error on token "setRequestContent", Identifier expected after this token . 

Has any one else tried to run this example ? It would be great if some one can point me out to a clearer and detailed online tutorial/blog on this topic.

Chiseled
  • 2,280
  • 8
  • 33
  • 59
  • Can you share your code for more clarity? A quick fix is to check if you have replaced the API URL "http://www.mycorp.com/somewsdl.wsdl" with some running api url as this is the sample url. – Rupendra Mar 31 '15 at 20:55
  • You said: "I have downloaded all dependencies required for SoapUI maven plugin". You know that each of those have dependencies of their own, right? – SiKing Mar 31 '15 at 21:31
  • @SiKing I mavenized my project in Eclipse and added all dependencies of "soapui-maven-plugin" in pom.xml of my existing project and updated the maven project configuration. Maven is not able to download many of the jars and is hence eroring out. – Chiseled Apr 01 '15 at 14:26
  • @SiKing Its impossible to locate each dependency and their individual dependency manually. Any suggestions ?? – Chiseled Apr 01 '15 at 14:28
  • In your project, change the dependency to just soapui, instead of the soapui-maven-plugin. – SiKing Apr 01 '15 at 14:32
  • @SiKing Ths SOAPUI website link suggests to use all dependencies specified in the " soapui-maven-plugin" project. Here is link to its pom.xml https://github.com/SmartBear/soapui/blob/next/soapui-maven-plugin/project.xml – Chiseled Apr 01 '15 at 14:43

1 Answers1

0

I got this working my mavenizing my project in eclipse and adding "soapui-maven-plugin" dependencies my pom.xml. To get this working I included the following repositories in my project's pom.xml.

I am posting this for those who may run into the same issue:

      <repositories>
        <repository>
            <id>maven2</id>
            <url>https://www.soapui.org/repository/maven2/</url>
        </repository>
        <repository>
            <id>activation</id>
            <url>https://www.soapui.org/repository/activation/jars</url>
        </repository>
        <repository>
            <id>xmlbeans</id>
            <url>https://www.soapui.org/repository/xmlbeans/jars</url>
        </repository>
        <repository>
            <id>bouncycastle</id>
            <url>https://www.soapui.org/repository/bouncycastle/jars</url>
        </repository>
        <repository>
            <id>javamail</id>
            <url>https://www.soapui.org/repository/javamail/jars</url>
        </repository>
    </repositories>

I am new to maven and from what I have read in forums , seems like including multiple repositories in the pom is a bad practice.

I did what was needed to get the code working. All maven gurus feel free to improve this answer.

I also came across this useful link that throws light on why there are missing dependencies for "soapui-maven-plugin" , that is if you are using the central maven repository.

Chiseled
  • 2,280
  • 8
  • 33
  • 59