目标:我想读取 WSDL 并打印 WSDL、复杂类型和复杂类型定义中的服务。工作过:我使用 WSDL4J 来读取 WSDL 并成功打印服务及其参数(复杂类型)。现在我想阅读 XSD 中可用的复杂类型定义。我无法读取 XSD 。有什么办法吗?我得到 XSModel 为空import java.util.ArrayList;import java.util.Collection;import java.util.List;import java.util.Map;import javax.wsdl.BindingOperation;import javax.wsdl.Definition;import javax.wsdl.WSDLException;import javax.wsdl.xml.WSDLReader;import org.w3c.dom.bootstrap.DOMImplementationRegistry;import com.ibm.wsdl.BindingImpl;import com.ibm.wsdl.xml.WSDLReaderImpl;import com.sun.org.apache.xerces.internal.impl.xs.XSImplementationImpl;import com.sun.org.apache.xerces.internal.xs.XSLoader;import com.sun.org.apache.xerces.internal.xs.XSModel;public class WSDLDetails { public static void main(String[] args) { try { String wsdlURL = "https://abc.xyz.com/webservice/MessagingSevice?WSDL"; String xsdURL = "https://abc.xyz.com/webservice/MessagingSevice?xsd=1"; java.lang.System.setProperty("https.protocols", "TLSv1.2"); getAllBindingOperation(wsdlURL); readXSD(xsdURL); } catch (Exception e) { e.printStackTrace(); } } public static List<String> getAllBindingOperation(String wsdlUrl) { List<BindingOperation> operationList = new ArrayList(); List<String> nameList = new ArrayList(); try { WSDLReader reader = new WSDLReaderImpl(); reader.setFeature("javax.wsdl.verbose", false); Definition definition = reader.readWSDL(wsdlUrl.toString()); Map<String, BindingImpl> defMap = definition.getAllBindings(); Collection<BindingImpl> collection = defMap.values(); for (BindingImpl binding : collection) { operationList.addAll(binding.getBindingOperations()); }
添加回答
举报
0/150
提交
取消