Mike
Mike

Reputation: 919

Can web service testing done using SOAPUI tool be done in Java completely?

In SOAP UI Web service testing, User imports the Project in to the work space and mentions the End point. Enters the required data in the Request xml and runs to get the resulting response in xml format.

Is there a way we can achieve this using Java only without using the SoapUI tool. I guess the steps should be:

  1. Create a Wsdl Project.
  2. Create a xml request (in the required format)
  3. Send the request to the end point (How to do this?)
  4. Receive response and verify it.

Please help me how to do this using Java only(without using SOAP UI tool). Any links/code will be greatly helpful.

Thanks, Mike

Upvotes: 1

Views: 5318

Answers (2)

yadou
yadou

Reputation: 31

Use soapUI API. ; Here are some useful links: http://www.soapui.org/Developers-Corner/integrating-with-soapui.html http://pritikaur23.wordpress.com/2013/06/16/saving-a-soapui-project-and-sending-requests-using-soapui-api/

I used the following code to create a project:

File projectFile = new File(filePath);
SoapUI.setSoapUICore(new StandaloneSoapUICore(true));
WsdlProject project = new WsdlProject();
project.setName(projectName);

WsdlInterface[] wsdls = WsdlImporter.importWsdl(project, url);
for (WsdlInterface wsdl : wsdls) {
  int c = wsdl.getOperationCount();
  String reqContent = "";
  for (int j = 0; j < c; j++) {
    WsdlOperation op = wsdl.getOperationAt(j);
    reqContent = op.createRequest(true);
    WsdlRequest req = op.addNewRequest(requestName);
    req.setRequestContent(reqContent );
  }
}
project.saveIn(projectFile);
SoapUI.shutdown();

Upvotes: 3

Rachel
Rachel

Reputation: 103397

You can create client and pass in HTTP Request test request populated with needed parameter for testing purpose, below mention question has some useful insights.

Java Web service testing

Upvotes: 1

Related Questions