相对而言。Eclipse API中国的数据是比较小的。但Eclipse的API提供了许多的。非常强大。

实例,eclipse的Eclipse API 提供 org.eclipse.wst.wsdl包裹,它提供了大量的类来解决WSDL档。

。其提供的API简单易懂。并且其API是和专业术语相应起来的,比方,

一个WSDL文档通常包括7个重要的元素。即types、import、message、portType、operation、binding、 service元素。

这些元素嵌套在definitions元素中,

(1) Definitions是WSDL文档的根元素。相应于这个类: org.eclipse.wst.wsdl.Definition 其它的对象都能够通过这个对象获得

(2) Types - 数据类型定义的容器,它使用某种类型系统(一般地使用XML Schema中的类型系统)。

(3) Message - 通信消息的数据结构的抽象类型化定义。使用Types所定义的类型来定义整个消息的数据结构。 

(4) PortType - 对于某个訪问入口点类型所支持的操作的抽象集合。这些操作能够由一个或多个服务訪问点来支持。

 (子节点) Operation - 对服务中所支持的操作的抽象描写叙述。一般单个Operation描写叙述了一个訪问入口的请求/响应消息对。

(5) Binding - 特定port类型的详细协议和数据格式规范的绑定。

(6) Service- 相关服务訪问点的集合。

(子节点) Port - 定义为协议/数据格式绑定与详细Web訪问地址组合的单个服务訪问点。

以下是代码实例:

import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set; import javax.wsdl.Message;
import javax.wsdl.Part;
import javax.wsdl.PortType;
import javax.xml.namespace.QName; import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.wst.wsdl.Definition;
import org.eclipse.wst.wsdl.Types;
import org.eclipse.wst.wsdl.internal.impl.PartImpl;
import org.eclipse.wst.wsdl.internal.util.WSDLResourceFactoryImpl;
import org.eclipse.wst.wsdl.util.WSDLResourceImpl;
import org.eclipse.xsd.XSDElementDeclaration;
import org.eclipse.xsd.XSDSchema;
import org.eclipse.xsd.util.XSDResourceImpl;
import org.junit.Test;
import org.junit.Before; public class WSDLParserWithEclipse {
Definition definition=null;
String wsdlPathString="E:/HelloEclipse-EMF-WSDL-XSD/test.wsdl"; @Before
public void setup(){
ResourceSet resourceSet = new ResourceSetImpl();
Resource.Factory.Registry registry = resourceSet.getResourceFactoryRegistry();
Map extensionToFactoryMap = registry.getExtensionToFactoryMap();
extensionToFactoryMap.put("wsdl", new WSDLResourceFactoryImpl());
File wsdlFile =new File(wsdlPathString);
URI uri = URI.createFileURI(wsdlFile.getAbsolutePath());
// You can avoid this cast, but will have to cast anyway later to get the Definition out the resource contents
WSDLResourceImpl wsdlResource = (WSDLResourceImpl) resourceSet.createResource(uri);
try {
wsdlResource.load(null);
definition = wsdlResource.getDefinition();
}catch(Exception e){
e.printStackTrace();
}
} @Test
public void testTypes(){
Types types = definition.getETypes();
List schemas = types.getSchemas("http://www.xxxxx.com/problem");
XSDSchema schema = (XSDSchema) schemas.get(0);
org.eclipse.xsd.util.XSDResourceImpl.serialize(System.out, schema.getElement());
} @Test
public void testMessage(){
Map messages=definition.getMessages();
System.out.println("The message size is:"+messages.size());
Set setMessages=messages.keySet();
Iterator iteratorMessages=setMessages.iterator();
while(iteratorMessages.hasNext()){
QName key=(QName)iteratorMessages.next();
Message message=(Message)messages.get(key);
//{http://www.xxxxx.com/problem}getKeysSoapIn
//System.out.println("Message Name:"+message.getQName());
if(message.getQName().toString().indexOf("getKeysSoapIn")>0){
System.out.println("Message Name:"+message.getQName());
Map partsMap=message.getParts();
//org.eclipse.xsd.impl.XSDElementDeclarationImpl
System.out.println("Message Part size for getKeysSoapIn message is:"+partsMap.size());
PartImpl part= (PartImpl)partsMap.get("problem");
XSDElementDeclaration xsdElementDeclaration=part.getElementDeclaration();
XSDResourceImpl.serialize(System.out, xsdElementDeclaration.getElement());
}
}
}
@Test
public void testPortType(){
Map portTypes=definition.getPortTypes();
System.out.println("Port Type size:"+portTypes.size());
if(portTypes!=null&&portTypes.size()>0){
Set set=portTypes.keySet();
Iterator iterator=set.iterator();
while(iterator.hasNext()){
QName object=(QName)iterator.next();
PortType portType=(PortType)portTypes.get(object);
System.out.println("Port Type name:"+portType.getQName());
org.eclipse.xsd.util.XSDResourceImpl.serialize(System.out, portType.getDocumentationElement());
}
}
} }

版权声明:本文博主原创文章,博客,未经同意不得转载。

如何使用Eclipse API 提供 org.eclipse.wst.wsdl 要解决阅读WSDL档?的更多相关文章

  1. 【eclipse插件开发实战】Eclipse插件开发4——插件JDE、PDE开发方式及plugin.xml配置文件结构

    Eclipse插件开发4--插件JDE.PDE开发方式及plugin.xml配置文件结构 开发方式分为:java开发环境JDE开发插件的方式和插件开发环境PDE开发插件方式. 插件通过添加到预定义的扩 ...

  2. 【eclipse插件开发实战】Eclipse插件开发2——SWT

    Eclipse插件开发实战2--SWT 一.SWT简介 SWT(StandardWidget Toolkit) 标准小窗口工具箱,一开源的GUI编程框架,与AWT/Swing有相似的用处,eclips ...

  3. 【eclipse插件开发实战】Eclipse插件开发1——eclipse内核结构、扩展点机制

    Eclipse插件开发实战1--eclipse内核结构.扩展点机制 一.前言 本系列总体介绍eclipse插件开发基本理论.插件项目结构及开发步骤,最后再给出两个插件开发实例. 总体安排结构如下: 1 ...

  4. eclipse中的js文件报错的解决办法

    在使用别人的项目的时候,导入到eclipse中发现js文件报错,解决办法是关闭eclipse的js校验功能. 三个步骤: 1. 右键点击项目->properties->Validation ...

  5. eclipse启动报错eclipse failed to create the java virutal machine

    早上一来,我的eclipse就无法启动了,错误就是这句话: eclipse failed to create the java virutal machine 直译就是eclipse无法创建JAVA虚 ...

  6. 打开Eclipse时出现"The Eclipse executable launcher was unable to locate its companion shared library"情况的解决办法

    在网上有坑,各种解决方法都有,但似乎我这台64位机器不太给面子,都不能解决: 结果自己找到了解决办法,总结了一下,大多数软件出问题,如果卸载了重新装还是出现问题,一般都是注册表残留的问题: 将ecli ...

  7. 启动 Eclipse 弹出“Failed to load the JNI shared library jvm.dll”错误的解决方法!&&在eclipse.ini中为eclipse指定jdk启动

    参考:http://blog.csdn.net/zyz511919766/article/details/7442633 http://blog.sina.com.cn/s/blog_028f0c1c ...

  8. 让32位Eclipse和64位Eclipse同时在64的Windows7上运行

    转自让32位Eclipse和64位Eclipse同时在64的Windows7上运行 参考这篇文章:http://wenku.baidu.com/view/57994c270066f5335a81214 ...

  9. Eclipse优化集合,Eclipse优化速度,解决Ctrl+C、Ctrl+V卡

    Eclipse优化集合,Eclipse优化速度,解决Ctrl+C.Ctrl+V卡 >>>>>>>>>>>>>>> ...

随机推荐

  1. SQL Server Database 维护计划创建一个完整的备份策略

     SQL Server维护计划Maintenance Plan这是一个非常有用的维护工具,能够完成大部分的数据库维护任务,通过这些功能包.您可以省略大量的编码时间. 介绍的不是非常多,特此补上一篇 ...

  2. 从零開始制作H5应用(4)——V4.0,增加文字并给文字加特效

    之前,我们分三次完毕了我们第一个H5应用的三个迭代版本号: V1.0--简单页面滑动切换 V2.0--多页切换,透明过渡及交互指示 V3.0--加入loading,music及自己主动切换 这已经是一 ...

  3. PHPExcel融入ZF2

    下载PHPExcel至vendor下一个 在public\index.php加拿大 require './vendor/Classes/PHPExcel.php'; 之后就能够在不论什么地方按例如以下 ...

  4. 从SAE又回到BAE,感觉好轻松

    [前言] 我这个人总喜欢对同一类东西比較过来比較过去,用过来用过去. 比如曾经选择浏览器,从開始ie,到遨游,世界之窗.qq等等,用了有10款左右的浏览器,每款都用了不短时间, 终于固定在火狐+chr ...

  5. 推荐一套.NET文档处理组件Spire.Office

    原文:推荐一套.NET文档处理组件Spire.Office 以前的项目中用到一点Word简单处理的功能(文字替换和转PDF格式),当时使用的是一套COM组件,必须在服务器上安装office环境.最近考 ...

  6. 分布式Unique ID的生成方法

    分布式Unique ID的生成方法 分布式的Unique ID的用途如此广泛,从业务对象Id到日志的TraceId,本文总结了林林总总的各种生成算法. 1. 发号器 我接触的最早的Unique ID, ...

  7. Jquery 对话框确认

    $("#aa").click(function(){ if(confirm("是否继续")){ $(#aa).fadeOut(500); } })

  8. windows phone 7 通过Post提交URL到服务器,从服务器获取数据(比如登陆时候使用)

    原文:windows phone 7 通过Post提交URL到服务器,从服务器获取数据(比如登陆时候使用) HttpWebRequest myRequest = (HttpWebRequest)Web ...

  9. POJ 3630 Phone List Trie题解

    Trie的应用题目. 本题有两个难点了: 1 动态建立Trie会超时,须要静态建立数组,然后构造树 2 推断的时候注意两种情况: 1) Tire树有133,然后插入13333556的时候.2)插入顺序 ...

  10. svn代码统计工具的金额

    StatSVN介绍 StatSVN是Java写开源统计程序,从statCVS从移植.从能Subversion版本号来获取信息库,该项目开发的叙述性说明,然后生成各种表格和图表.例:时间线.针对每一个开 ...