Get complexTypes or parameters from a WSDL file

How to get complex types programmatically from a WSDL file?

I need to get complex types from the Adobe echo character. https://secure.echosign.com/services/EchoSignDocumentService19?wsdl

There are already some questions on this topic, but no one has a useful answer. So, I am raising this question again.

This is the code I wrote but no luck.

public class wsdlReader {
    public static void main(String[] args) {
        try {
            WSDLFactory factory = WSDLFactory.newInstance();
            WSDLReader reader = factory.newWSDLReader();

            reader.setFeature("javax.wsdl.verbose", false);
            reader.setFeature("javax.wsdl.importDocuments", true);
            Definition def = reader.readWSDL(null, "https://secure.echosign.com/services/EchoSignDocumentService19?wsdl");
            Map services = def.getServices();
            Iterator servicesIterator = services.values().iterator();
            def.getTypes();
            while (servicesIterator.hasNext()) 
            {
                Service service = (Service) servicesIterator.next();
                Map ports = service.getPorts();
                Iterator portsIterator = ports.keySet().iterator();
                while (portsIterator.hasNext())
                {
                    String strPort = portsIterator.next().toString();
                    Port port = service.getPort(strPort);
                    Binding binding = port.getBinding();
                    PortType portType = binding.getPortType();

                    List operations = portType.getOperations();
                    Iterator opIterator = operations.iterator();

                    while (opIterator.hasNext()) 
                    {
                        Operation operation = (Operation) opIterator.next();
                        if (!operation.isUndefined()) 
                        {
                            Input inDef = operation.getInput();
                            Map params = operation.getInput().getMessage().getParts();
                            Iterator paramsIterator = params.keySet().iterator();
                            int n = 1;
                            StringBuffer sbParams = new StringBuffer();
                            while (paramsIterator.hasNext())
                            {
                                PartImpl iParam = (PartImpl) params.get(paramsIterator.next());
                                if (iParam.getTypeName() == null) {
                                    sbParams.append(iParam.getElementName().getLocalPart()).append(" p").append(n).append(",");
                                    n++;
                                } else if (iParam.getElementName() == null) {
                                    sbParams.append(iParam.getTypeName().getLocalPart()).append(" ").append(iParam.getName()).append(", ");
                                } else {
                                    System.err.println("sicis .:.");
                                }
                            }
                            System.out.println(sbParams);
                            if (sbParams.length() > 0) {
                                sbParams.delete(sbParams.length() - 1, sbParams.length());
                            }
                        }
                    }
                }
            }
        } catch (WSDLException e) {
            e.printStackTrace();
        }
    }
}

Any help or suggestion would be really helpful.

thank

+4
source share

All Articles