⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wsdlpropertyreader.java

📁 sql语句
💻 JAVA
字号:
package org.apache.axis2.tool.codegen.eclipse.util;

import org.apache.axis2.util.URLProcessor;

import javax.wsdl.Definition;
import javax.wsdl.Port;
import javax.wsdl.Service;
import javax.wsdl.factory.WSDLFactory;
import javax.wsdl.xml.WSDLReader;
import javax.xml.namespace.QName;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;



/**
 * This class presents a convenient way of reading the 
 * WSDL file(url) and producing a useful set of information
 * It does NOT use any of the standard WSDL classes from 
 * Axis2, rather it uses wsdl4j to read the wsdl and extract 
 * the properties (This is meant as a convenience for the UI
 * only. We may not need the whole conversion the WSDLpump 
 * goes through)
 * One would need to change this to suit a proper WSDL 
 */
public class WSDLPropertyReader {
    private Definition wsdlDefinition = null;
    
	public void readWSDL(String filepath) throws Exception{
		WSDLReader reader = WSDLFactory.newInstance().newWSDLReader();
		wsdlDefinition = reader.readWSDL(filepath); 
	}
	
	/**
	 * Returns the namespace map from definition
	 * @return
	 */
	public Map getDefinitionNamespaceMap(){
		return wsdlDefinition.getNamespaces();
	}
	
	/**
	 * get the default package derived by the targetNamespace
	 */
	public String packageFromTargetNamespace(){
		return  URLProcessor.makePackageName(wsdlDefinition.getTargetNamespace());
		
	}
	/**
	 * Returns a list of service names
	 * the names are QNames
	 * @return
	 */
	public List getServiceList(){
		List returnList = new ArrayList();
		Service service = null;
		Map serviceMap = wsdlDefinition.getServices();
		if(serviceMap!=null && !serviceMap.isEmpty()){
		   Iterator serviceIterator = serviceMap.values().iterator();
		   while(serviceIterator.hasNext()){
			   service = (Service)serviceIterator.next();
			   returnList.add(service.getQName());
		   }
		}
		
		return returnList;
	}

	/**
	 * Returns a list of ports for a particular service
	 * the names are QNames
	 * @return
	 */
	public List getPortNameList(QName serviceName){
		List returnList = new ArrayList();
		Service service = wsdlDefinition.getService(serviceName);
		Port port = null; 
		if(service!=null){
		   Map portMap = service.getPorts();
		   if (portMap!=null && !portMap.isEmpty()){
			   Iterator portIterator = portMap.values().iterator();
			   while(portIterator.hasNext()){
				 port = (Port)portIterator.next();
				 returnList.add(port.getName());
			   }
		   }
		  
		}
		
		return returnList;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -