java-工具-Webservice wsdl解析
2023-09-27 14:26:36 时间
原文链接:http://www.cnblogs.com/coshaho/p/5689738.html
wsdl解析
首先必然是理解第三方webservice的接口描述,也就是解析wsdl文件。wsdl文件是webservice服务接口描述文档,一个wsdl文件可以包含多个接口,一个接口可以包含多个方法。
public class WsdlInfo private String wsdlName; private List InterfaceInfo interfaces; * coshaho * @param path wsdl地址 * @throws Exception public WsdlInfo(String path) throws Exception WProject project = new WProject(); WsdlInterface[] wsdlInterfaces = WsdlImporter.importWsdl( project, path ); this.wsdlName = path; if(null != wsdlInterfaces) List InterfaceInfo interfaces = new ArrayList InterfaceInfo for(WsdlInterface wsdlInterface : wsdlInterfaces) InterfaceInfo interfaceInfo = new InterfaceInfo(wsdlInterface); interfaces.add(interfaceInfo); this.interfaces = interfaces; public String getWsdlName() { return wsdlName; public void setWsdlName(String wsdlName) { this.wsdlName = wsdlName; public List InterfaceInfo getInterfaces() { return interfaces; public void setInterfaces(List InterfaceInfo interfaces) { this.interfaces = interfaces; }
int operationNum = wsdlInterface.getOperationCount(); List OperationInfo operations = new ArrayList OperationInfo for(int i = 0; i operationNum; i++) WsdlOperation operation = ( WsdlOperation )wsdlInterface.getOperationAt( i ); OperationInfo operationInfo = new OperationInfo(operation); operations.add(operationInfo); this.operations = operations; public String getInterfaceName() { return interfaceName; public void setInterfaceName(String interfaceName) { this.interfaceName = interfaceName; public List OperationInfo getOperations() { return operations; public void setOperations(List OperationInfo operations) { this.operations = operations; public String[] getAdrress() { return adrress; public void setAdrress(String[] adrress) { this.adrress = adrress; }
requestXml = operation.createRequest( true ); responseXml = operation.createResponse(true); public String getOperationName() { return operationName; public void setOperationName(String operationName) { this.operationName = operationName; public String getRequestXml() { return requestXml; public void setRequestXml(String requestXml) { this.requestXml = requestXml; public String getResponseXml() { return responseXml; public void setResponseXml(String responseXml) { this.responseXml = responseXml; }
String url = "http://webservice.webxml.com.cn/WebServices/ChinaOpenFundWS.asmx?wsdl"; WsdlInfo wsdlInfo = new WsdlInfo(url); System.out.println("WSDL URL is " + wsdlInfo.getWsdlName()); for(InterfaceInfo interfaceInfo : wsdlInfo.getInterfaces()) System.out.println("Interface name is " + interfaceInfo.getInterfaceName()); for(String ads : interfaceInfo.getAdrress()) System.out.println("Interface address is " + ads); for(OperationInfo operation : interfaceInfo.getOperations()) System.out.println("operation name is " + operation.getOperationName()); System.out.println("operation request is "); System.out.println("operation request is " + operation.getRequestXml()); System.out.println("operation response is "); System.out.println(operation.getResponseXml()); }
WSDL URL is http://webservice.webxml.com.cn/WebServices/ChinaOpenFundWS.asmx?wsdl Interface name is ChinaOpenFundWSSoap12 Interface address is http://webservice.webxml.com.cn/WebServices/ChinaOpenFundWS.asmx operation name is getFundCodeNameDataSet operation request is operation request is soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:web="http://WebXml.com.cn/" soap:Header/ soap:Body web:getFundCodeNameDataSet/ /soap:Body /soap:Envelope operation response is soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:web="http://WebXml.com.cn/" xmlns:xs="http://www.w3.org/2001/XMLSchema" soap:Header/ soap:Body web:getFundCodeNameDataSetResponse !--Optional:-- web:getFundCodeNameDataSetResult xs:schema !--Ignoring type [{http://www.w3.org/2001/XMLSchema}schema]-- /xs:schema !--You may enter ANY elements at this point-- /web:getFundCodeNameDataSetResult /web:getFundCodeNameDataSetResponse /soap:Body /soap:Envelope operation name is getFundCodeNameString operation request is operation request is soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:web="http://WebXml.com.cn/" soap:Header/ soap:Body web:getFundCodeNameString/ /soap:Body /soap:Envelope operation response is soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:web="http://WebXml.com.cn/" soap:Header/ soap:Body web:getFundCodeNameStringResponse !--Optional:-- web:getFundCodeNameStringResult !--Zero or more repetitions:-- web:string ? /web:string /web:getFundCodeNameStringResult /web:getFundCodeNameStringResponse /soap:Body /soap:Envelope operation name is getOpenFundDataSet operation request is operation request is soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:web="http://WebXml.com.cn/" soap:Header/ soap:Body web:getOpenFundDataSet !--Optional:-- web:userID ? /web:userID /web:getOpenFundDataSet /soap:Body /soap:Envelope operation response is soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:web="http://WebXml.com.cn/" xmlns:xs="http://www.w3.org/2001/XMLSchema" soap:Header/ soap:Body web:getOpenFundDataSetResponse !--Optional:-- web:getOpenFundDataSetResult xs:schema !--Ignoring type [{http://www.w3.org/2001/XMLSchema}schema]-- /xs:schema !--You may enter ANY elements at this point-- /web:getOpenFundDataSetResult /web:getOpenFundDataSetResponse /soap:Body /soap:Envelope
国人开源了一款小而全的 Java 工具类库,Github标星14K 最近看到了一款小而全的 Java 工具类库:Hutool,Github 已经接近 14K Star 了,想必一定很优秀,现在推荐给大家,很多轮子不要再造了!
【Java技术指南】「Unirest编程专题」一起认识一下一个“灰常”优秀的Http工具,让Http开发变得如此简单 Unirest-Java是一个轻量级的HTTP客户端库,它提供了简单易用的API,可以帮助Java开发人员快速地发送HTTP请求和处理响应。在本文中,我们将深入探讨Unirest-Java的技术细节和使用方法。
java中好用的list转json的工具hutool 最近做服务器接口开发的时候遇到的小问题,数据库查询之后的数据怎样快捷的转化为json数据,第一时间想到了查库,查了挺久的,好多都是用代码实现,比较懒,这方面内容代码实现的偏多,虽然确实比较简单,但能快点就快点
相关文章
- Java中httpClient中的设置超时时间
- Java NIO系列教程(十) Java NIO DatagramChannel
- Java SE 8 在并发工具方面的加强
- Java NIO系列教程(二) Channel
- 阿里 P7 给你系统梳理面试 6 大专题,Java 面试速成笔记太香了
- Java 中的语法糖,真甜。
- Java中Queue类实现
- 基于Java的WebService服务端
- java jjwt-api使用,java jwt使用,java jwt 工具类
- Java中如何判断两个对象是否相等(Java equals and ==)
- Java日志框架slf4j剖析
- 无插件及工具纯java生成验证码
- 你应当知道的7个Java工具
- java学习-加载.properties工具类
- java获取视频第一帧工具类
- 华为OD机试 - 密室逃生游戏(Java) | 机试题+算法思路+考点+代码解析 【2023】
- 【Harmony OS】【JAVA UI】webView动画加载资源加载动画交互
- Java高手速成 | 新增类Record的工作实例
- java虚拟机性能监控工具介绍
- java 效率编程 的一些小知识点
- Java学习笔记_3 @面向对象
- Java小白入门200例26之数组的定义
- Java //EX2.17 设page是Graphics类的一个对象,编写一条语句画一个以(50, 50)为圆心,20像素为半径的圆