How to get all SOAP Operations or Requests from WSDL file using Java: In this tutorial will see how to get all SOAP Operations/Requests using the WSDL file.

Create a Simple maven project and add below PluginRepositories your POM.

<pluginRepositories>
		<pluginRepository>
			<id>SmartBearPluginRepository</id>
			<url>http://www.soapui.org/repository/maven2/</url>
		</pluginRepository>
</pluginRepositories>

Next, Add Below repository to your POM

<repositories>
		<repository>
			<id>smartbear</id>
			<name>smartbear repository</name>
			<url>http://smartbearsoftware.com/repository/maven2</url>
		</repository>
</repositories>

Then add the dependency

<dependency>
    <groupId>com.smartbear.soapui</groupId>
    <artifactId>soapui</artifactId>
    <version>5.2.1</version>
</dependency>

Create Java Class with name SoapServicesRequests and add  below code

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.support.wsdl.WsdlImporter;
import com.eviware.soapui.model.iface.Operation;

public class SoapServicesRequests {
	 public static void main(String[] args) throws Exception {
	        WsdlProject project = new WsdlProject();
	      
              // we can directly download the wsdl file from URL
	      //  WsdlInterface[] wsdls = WsdlImporter.importWsdl(project, "http://localhost:8080/Service?wsdl");
	        WsdlInterface[] wsdls = WsdlImporter.importWsdl(project, "WSDL file path location in your local drive ");
	        WsdlInterface wsdl = wsdls[0];
	        String endPoints[] = wsdl.getEndpoints();
	        for(String endPoint:endPoints){
	        	System.out.println("End Point URL"+endPoint);
	        }
	        for (Operation operation : wsdl.getOperationList()) {
	            WsdlOperation wsdlOperation = (WsdlOperation) operation;
	          System.out.println("Request:\n"+wsdlOperation.createRequest(true));

	          wsdlOperation.release();
	        }
	        wsdl.release();
	        project.release();

	        //System.exit(0);
	    }
}

In below line copy  your WSDL file path

WsdlInterface[] wsdls = WsdlImporter.importWsdl(project, “WSDL file path location in your local drive “);

Run the Class file to log the List of operations

Thanks

Also Read: How to Get all jsonpaths from JSON

How to get all SOAP Operations or Requests from WSDL file using Java

Leave a Reply

Your email address will not be published. Required fields are marked *