1

I have a wsdl url using which I have to create a template file which has the list of the parameters for a particular API and create a pojo file for that request. I tried using soapui-api but I was unable to do so because of unable to fulfill the dependencies (Followed all the stackoverflow help to resolve the jar issues but it did not work):

Code:

WsdlProject project = new WsdlProject();
        WsdlInterface[] wsdls = WsdlImporter.importWsdl(project, "http://XXXXX?wsdl");
        WsdlInterface wsdl = wsdls[0];
        for (com.eviware.soapui.model.iface.Operation operation : wsdl.getOperationList()) {
            WsdlOperation wsdlOperation = (WsdlOperation) operation;
            System.out.println("OP:"+wsdlOperation.getName());
            System.out.println("Request:");
            System.out.println(wsdlOperation.createRequest(true));
            System.out.println("Response:"); System.out.println(wsdlOperation.createResponse(true));
    }

Another approach in which I tried to parse the wsdl url using parser and get the list of names of the possible requests. I was able to get the request list but not the parameters required to create that request.

 WSDLParser parser = new WSDLParser();
    Definitions wsdl = parser.parse("http://XXXX?wsdl");
    String str = wsdl.getLocalBindings().toString();

for(Message msg : wsdl.getMessages()) {
      for (Part part : msg.getParts()) {
            System.out.println(part.getElement());
       }
 }

Please help me on how to get the list of parameters from a wsdl url by either of the one approach.

LearningToCode
  • 392
  • 5
  • 18

1 Answers1

0

well there are various stranded approach available for this , try and search for WS-import tool which is one of tools to do this .

This is the simple and best example here

WS_Import_tool

one more way of doing this is -

Apache_CFX

If you want to generate them using eclipse - that is also possible .

Check it out -

How do you convert WSDLs to Java classes using Eclipse?

What errors you are facing for SOAP UI You can reffer this link for trouble shooting

Generate_java_from_Wsdl

Ashish Shetkar
  • 1,414
  • 2
  • 18
  • 35