soap-ws 获取wsdl中所有方法 (三)
2016-07-01 11:43
495 查看
3. 两种方法比较
测试方法@Test public void test2() { String wsdlUrl = "http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?wsdl"; long s1=System.currentTimeMillis(); System.out.println(getBindingOperations(wsdlUrl)); long e1=System.currentTimeMillis(); System.out.println("getBindingOperations "+(e1-s1));//1707ms long s2=System.currentTimeMillis(); System.out.println(getOperationByUrl(wsdlUrl)); long e2=System.currentTimeMillis(); System.out.println("getOperationByUrl "+(e2-s2));//199ms System.out.println(Arrays.equals(getBindingOperations(wsdlUrl).toArray(),getOperationByUrl(wsdlUrl).toArray())); }
测试结果:
[getSupportCity, getSupportProvince, getSupportDataSet, getWeatherbyCityName, getWeatherbyCityNamePro, getSupportCity, getSupportProvince, getSupportDataSet, getWeatherbyCityName, getWeatherbyCityNamePro, getSupportCity, getSupportProvince, getSupportDataSet, getWeatherbyCityName, getWeatherbyCityNamePro, getSupportCity, getSupportProvince, getSupportDataSet, getWeatherbyCityName, getWeatherbyCityNamePro] getBindingOperations **1123** [getSupportCity, getSupportProvince, getSupportDataSet, getWeatherbyCityName, getWeatherbyCityNamePro, getSupportCity, getSupportProvince, getSupportDataSet, getWeatherbyCityName, getWeatherbyCityNamePro, getSupportCity, getSupportProvince, getSupportDataSet, getWeatherbyCityName, getWeatherbyCityNamePro] getOperationByUrl **35** false
执行时间上差距很大,原因是第一种方法每次都是新建一个对象。
static SoapOperationBuilder create(SoapBuilder builder, Binding binding, BindingOperation operation, String soapAction) { String bindingInputName = operation.getBindingInput() != null ? operation.getBindingInput().getName() : null; String bindingOutputName = operation.getBindingOutput() != null ? operation.getBindingOutput().getName() : null; return new SoapOperationImpl(builder, binding.getQName(), operation.getName(), bindingInputName, bindingOutputName, SoapUtils.normalizeSoapAction(soapAction)); }
第二中方法获取到的Binding节点和获取portType节点比较。
@Test public void test03(){ String wsdlUrl = "http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?wsdl"; long s1=System.currentTimeMillis(); System.out.println(getAllBindingOperation(wsdlUrl)); long e1=System.currentTimeMillis(); System.out.println("getAllBindingOperation "+(e1-s1));//480ms long s2=System.currentTimeMillis(); System.out.println(getOperationByUrl(wsdlUrl)); long e2=System.currentTimeMillis(); System.out.println("getOperationByUrl "+(e2-s2));//281ms System.out.println(Arrays.equals(getAllBindingOperation(wsdlUrl).toArray(),getOperationByUrl(wsdlUrl).toArray())); }
测试结果
[getSupportCity, getSupportProvince, getSupportDataSet, getWeatherbyCityName, getWeatherbyCityNamePro, getSupportCity, getSupportProvince, getSupportDataSet, getWeatherbyCityName, getWeatherbyCityNamePro, getSupportCity, getSupportProvince, getSupportDataSet, getWeatherbyCityName, getWeatherbyCityNamePro, getSupportCity, getSupportProvince, getSupportDataSet, getWeatherbyCityName, getWeatherbyCityNamePro] getAllBindingOperation 265 [getSupportCity, getSupportProvince, getSupportDataSet, getWeatherbyCityName, getWeatherbyCityNamePro, getSupportCity, getSupportProvince, getSupportDataSet, getWeatherbyCityName, getWeatherbyCityNamePro, getSupportCity, getSupportProvince, getSupportDataSet, getWeatherbyCityName, getWeatherbyCityNamePro] getOperationByUrl 39 false
综上,获取portType节点的operation时间最快。生产环境推荐获取binding节点的信息。
相关文章推荐
- WPF中数据绑定
- php的webservice的wsdl的XML无法显示问题的解决方法
- 在PHP中利用wsdl创建标准webservice的实现代码
- Android Support v4、v7、v13的区别和应用场景
- Aixs2开发Web service操作数据库demo
- DBus glib 各数据类型接收与发送详解—C语言(1)
- DBus glib 各数据类型接收与发送详解—C语言(2)
- DBus glib 各数据类型接收与发送详解—C语言(3)
- gSoap使用实例 - 发送WSDL文件
- 服务注册和服务仓库在SOA中的角色
- WSDL 1.1 中文规范
- eclipse根据wsdl文件生成webservice客户端
- 【异常】OS X-EI-目录权限
- WPF Binding ItemsSource to Enum
- Effective C# Rule number 1
- myeclipse快捷键
- PagedCollectionView
- ComboBox 的绑定
- 用Apache AXIS 开发 Web Services Step By Step
- 手机归属地免费查询接口,api,wsdl,webservice