zl程序教程

您现在的位置是:首页 >  后端

当前栏目

java-工具-Webservice wsdl解析

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数据,第一时间想到了查库,查了挺久的,好多都是用代码实现,比较懒,这方面内容代码实现的偏多,虽然确实比较简单,但能快点就快点