public static List<String> getOperationList(String wsdlUrl) throws Exception {
Document document = getDefinitionDocument(wsdlUrl);
XPath xpath = getXpath(document);
NodeList operations = DOMUtil.findNodeList(document, "wsdl:definitions/wsdl:portType/wsdl:operation");
// 返回的结果集list
List<String> operationList = new ArrayList<String>();
for (int i = 0; i < operations.getLength(); i++) {
Node operation = operations.item(i);
String operationName = DOMUtil.getNodeName(operation);
if (operationName != null && !"".equals(operationName)) {
log.debug("解析" + wsdlUrl + "中的方法:" + operationName);
operationList.add(operationName);
}
}
//去除重复的operation(soap,get,post)
List<String> result = new ArrayList<String>();
for(int i=0;i<operationList.size()/3;i++){
String method = operationList.get(i);
result.add(i, method);
}
//返回最终结果result
return result;
}
上面方法中用到的架包dom4j,jdom,wsdl4j