5

如何以编程方式从 WSDL 文件中获取复杂类型?

我必须从 Adob​​e 回声符号中获取复杂类型。 https://secure.echosign.com/services/EchoSignDocumentService19?wsdl

已经有一些关于这个主题的问题,但没有一个有用的答案。所以,我再次提出这个问题。

这是我写的代码,但没有运气。

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();
        }
    }
}

任何帮助或建议都会非常有帮助。

谢谢

4

0 回答 0