1、
//org.dom4j.io.SAXReader.SAXReader // 获取wsdl dom对象 // 解析wsdl detail.append("\u25c6\u89e3\u6790wsdl"); Document doc = null; try { doc = new SAXReader().read(uri); // 【成功】 detail.append(" \u3010\u6210\u529f\u3011").append("\n"); } catch (DocumentException e) { e.printStackTrace(); // 【失败】 detail.append(" \u3010\u5931\u8d25\u3011").append("\n"); detail.append(ExceptionUtils.getStackTrace(e)); log.setStatus(Constants.FAILURE); log.setDetail(detail.toString()); return log; } // 根节点 Element root = doc.getRootElement(); // 客户端工厂类 String clazz = getClassName(root, uri); // 获取客户端工厂方法名 String portName = getPortName(root, uri); // 获取服务接口名称 String face = getFaceName(root, uri); // 目标命名空间 String targetNamespace = getTargetNamespace(root); //目标服务名称 String targetSeriviceName = getTargetServiceName(root,uri);
/** * * 获取客户端工厂类名(处理不规则的Class名称) * * @param wsdlUri * * @return 类名 * */ protected String getClassName(Element root, String wsdlUri) { String clazz = null; // 增加非空验证以及钻取引入的wsdl文件 if (root != null) { // 结果 Element r = getSubElementByName(root, "service", wsdlUri); if (r == null) return clazz; clazz = r.attributeValue("name"); clazz = clazz.replaceAll("^\\p{Lower}", clazz.substring(0, 1) .toUpperCase()); int index = clazz.indexOf("_"); while (index != -1) { clazz = clazz.replaceFirst("_.", clazz.substring(index + 1, index + 2).toUpperCase()); index = clazz.indexOf("_"); } } return clazz; } /** * * 获取客户端工厂方法名 * * @param wsdlUri * */ protected String getPortName(Element root, String wsdlUri) { String portName = null; if (root != null) { Element r = getSubElementByName(root, "service", wsdlUri); if (r == null) return portName; Element p = r.element("port"); if (p == null) return portName; portName = p.attributeValue("name"); portName = portName.replaceFirst("^\\p{Lower}", portName.substring(0, 1).toUpperCase()); int index = portName.indexOf("_"); while (index != -1) { portName = portName.replaceFirst("_.", portName.substring(index + 1, index + 2).toUpperCase()); index = portName.indexOf("_"); } } return portName; } /** * * 获取服务接口名称 * * @param wsdlUri * */ protected String getFaceName(Element root, String wsdlUri) { String face = null; if (root != null) { Element r = getSubElementByName(root, "service", wsdlUri); if (r == null) return face; Element port = r.element("port"); if (port == null) return face; String binding = port.attributeValue("binding"); if (binding.indexOf(":") != -1) { binding = binding.substring(binding.indexOf(":") + 1); } List<Element> ls = getSubElementsByName(root, "binding", wsdlUri); if (ls.size() == 0) return face; for (Element e : ls) { if (binding.equals(e.attributeValue("name"))) { String client = e.attributeValue("type"); if (client.indexOf(":") != -1) { client = client.substring(client.indexOf(":") + 1); } face = client.replaceFirst("^\\p{Lower}", client.substring(0, 1).toUpperCase()); } } } return face.replaceAll("_", ""); } /** * 获取原始wsdl中targetNamespace * * @param root * @return */ protected String getTargetNamespace(Element root) { return root.attributeValue("targetNamespace"); } /** * 获取服务名称 * @param root * @param wsdlUri * @return */ protected String getTargetServiceName(Element root, String wsdlUri){ String serviceName = null; if (root != null) { Element r = getSubElementByName(root, "service", wsdlUri); if (r == null) return serviceName; Element port = r.element("port"); serviceName = r.attributeValue("name"); } return serviceName; }
/** * * 返回入参eleName对应的子元素 BFS遍历获取的一个立即返回 * * @param root 根元素 * @param eleName 子元素名称 * @param wsdlUri * * @return 如果为空,说明未找到 * */ protected Element getSubElementByName(Element root, String eleName, String wsdlUri) { Element r = null; // BFS // 初始化循环条件 Map<String, Element> curLvl = new HashMap<String, Element>(); Map<String, Element> nextLvl = new HashMap<String, Element>(); nextLvl.put(wsdlUri, root); // 循环变量 String location = null; Element e = null; // 循环直到没有叶子节点 outer: while (nextLvl.size() > 0) { curLvl = nextLvl; nextLvl = new HashMap<String, Element>(); // 遍历当层的元素,同时将下层元素存取至集合 for (String uri : curLvl.keySet()) { e = curLvl.get(uri); r = e.element(eleName); if (r != null) { break outer; } @SuppressWarnings("unchecked") List<Element> ls = e.elements("import"); for (Element i : ls) { try { location = i.attributeValue("location"); location = joinLocation(uri, location); nextLvl.put(location, new SAXReader().read(location) .getDocument().getRootElement()); } catch (DocumentException e1) { e1.printStackTrace(); } } } } return r; }
原始WSDL:
http://localhost:8888/UnicomWebservices/services/ESB_ERP_FA_ImportOtherAddAssetsInfoSrvPort?wsdl
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://ws.project.com/ESB_ERP_FA_ImportOtherAddAssetsInfoSrv" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" name="ESB_ERP_FA_ImportOtherAddAssetsInfoSrv" targetNamespace="http://ws.project.com/ESB_ERP_FA_ImportOtherAddAssetsInfoSrv"> <wsdl:types> <schema xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://ws.project.com/ESB_ERP_FA_ImportOtherAddAssetsInfoSrv" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns="http://www.w3.org/2001/XMLSchema"> <import namespace="http://ws.project.com/ESB_ERP_FA_ImportOtherAddAssetsInfoSrv" schemaLocation="http://localhost:8888/UnicomWebservices/services/ESB_ERP_FA_ImportOtherAddAssetsInfoSrvPort?xsd=ESB_ERP_FA_ImportOtherAddAssetsInfoSrv.xsd"/> </schema> </wsdl:types> <wsdl:message name="ESB_ERP_FA_ImportOtherAddAssetsInfoSrvRequestMessage"> <wsdl:part element="tns:ESB_ERP_FA_ImportOtherAddAssetsInfoSrvRequest" name="payload"> </wsdl:part> </wsdl:message> <wsdl:message name="ESB_ERP_FA_ImportOtherAddAssetsInfoSrvResponseMessage"> <wsdl:part element="tns:ESB_ERP_FA_ImportOtherAddAssetsInfoSrvResponse" name="payload"> </wsdl:part> </wsdl:message> <wsdl:portType name="ESB_ERP_FA_ImportOtherAddAssetsInfoSrv"> <wsdl:operation name="process"> <wsdl:input message="tns:ESB_ERP_FA_ImportOtherAddAssetsInfoSrvRequestMessage"> </wsdl:input> <wsdl:output message="tns:ESB_ERP_FA_ImportOtherAddAssetsInfoSrvResponseMessage"> </wsdl:output> </wsdl:operation> </wsdl:portType> <wsdl:binding name="ESB_ERP_FA_ImportOtherAddAssetsInfoSrvBinding" type="tns:ESB_ERP_FA_ImportOtherAddAssetsInfoSrv"> <soap:binding transport="http://schemas.xmlsoap.org/soap/http"/> <wsdl:operation name="process"> <soap:operation soapAction="process" style="document"/> <wsdl:input> <soap:body use="literal"/> </wsdl:input> <wsdl:output> <soap:body use="literal"/> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="ESB_ERP_FA_ImportOtherAddAssetsInfoSrv"> <wsdl:port binding="tns:ESB_ERP_FA_ImportOtherAddAssetsInfoSrvBinding" name="ESB_ERP_FA_ImportOtherAddAssetsInfoSrvPort"> <soap:address location="http://localhost:8888/UnicomWebservices/services/ESB_ERP_FA_ImportOtherAddAssetsInfoSrvPort"/> </wsdl:port> </wsdl:service> </wsdl:definitions>
原始WSDL import标签的location xsd:
http://10.204.104.69:8888/UnicomWebservices/services/ESB_ERP_FA_ImportOtherAddAssetsInfoSrvPort?xsd=ESB_ERP_FA_ImportOtherAddAssetsInfoSrv.xsd
<schema xmlns:tns="http://ws.project.com/ESB_ERP_FA_ImportOtherAddAssetsInfoSrv" xmlns:msg="http://ws.project.com/MsgHeader" xmlns="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://ws.project.com/ESB_ERP_FA_ImportOtherAddAssetsInfoSrv"> <import namespace="http://ws.project.com/MsgHeader" schemaLocation="http://localhost:8888/UnicomWebservices/services/ESB_ERP_FA_ImportOtherAddAssetsInfoSrvPort?xsd=MsgHeader.xsd"/> <element name="ESB_ERP_FA_ImportOtherAddAssetsInfoSrvRequest" type="tns:ESB_ERP_FA_ImportOtherAddAssetsInfoSrvRequest"/> <element name="ESB_ERP_FA_ImportOtherAddAssetsInfoSrvResponse" type="tns:ESB_ERP_FA_ImportOtherAddAssetsInfoSrvResponse"/> <complexType name="ESB_ERP_FA_ImportOtherAddAssetsInfoSrvRequest"> <sequence> <element name="MsgHeader" type="msg:MsgHeader"/> <element name="ESB_ERP_FA_ImportOtherAddAssetsInfoSrvInputCollection" type="tns:ESB_ERP_FA_ImportOtherAddAssetsInfoSrvInputCollection"/> </sequence> </complexType> <complexType name="ESB_ERP_FA_ImportOtherAddAssetsInfoSrvResponse"> <sequence> <element name="SERVICE_FLAG" nillable="true" type="string"/> <element name="INSTANCE_ID" nillable="true" type="string"/> <element name="SERVICE_MESSAGE" nillable="true" type="string"/> <element name="ErrorCollection" type="tns:ErrorCollection"/> <element name="ResponseCollection" type="tns:ResponseCollection"/> </sequence> </complexType> <complexType name="ESB_ERP_FA_ImportOtherAddAssetsInfoSrvInputCollection"> <sequence> <element maxOccurs="unbounded" minOccurs="0" name="ESB_ERP_FA_ImportOtherAddAssetsInfoSrvInputItem" type="tns:ESB_ERP_FA_ImportOtherAddAssetsInfoSrvInputItem"/> </sequence> </complexType> <complexType name="ESB_ERP_FA_ImportOtherAddAssetsInfoSrvInputItem"> <sequence> <element name="PRI_KEY" type="string"/> <element name="BATCH_NUM" type="string"/> <element name="CREATED_BY" type="string"/> <element name="PROVINCE_CODE" type="string"/> <element name="BOOK_TYPE_CODE" type="string"/> <element name="ASSET_ID" type="decimal"/> <element name="TAG_NUMBER" nillable="true" type="string"/> <element name="ASSET_DESCRIPTION" type="string"/> <element name="MANUFACTURER_NAME" nillable="true" type="string"/> <element name="MODEL_NUMBER" nillable="true" type="string"/> <element name="SERIAL_NUMBER" nillable="true" type="string"/> <element name="APPLICANT_AREA" type="string"/> <element name="ASSET_CATALOG" type="string"/> <element name="ASSET_PROFESSIONAL" type="string"/> <element name="ASSET_KEYWORD" type="string"/> <element name="ASSET_UNIT" type="decimal"/> <element name="ASSET_UOM" nillable="true" type="string"/> <element name="SPARE_UNITS" nillable="true" type="decimal"/> <element name="SPARE_UOM" nillable="true" type="string"/> <element name="ASSET_SOURCE" type="string"/> <element name="ASSET_BELONG" type="string"/> <element name="SP_CODE" nillable="true" type="string"/> <element name="DATE_IN_SERVICE" type="dateTime"/> <element name="LIFE_IN_MONTHS" nillable="true" type="decimal"/> <element name="DEPRN_RESERVE" nillable="true" type="decimal"/> <element name="YTD_DEPRN" nillable="true" type="decimal"/> <element name="ORIGINAL_COST" type="decimal"/> <element name="SALVAGE_VALUE" nillable="true" type="decimal"/> <element name="ACCUMU_IMPAIRMENT" nillable="true" type="decimal"/> <element name="IS_AMORTIZATION" type="string"/> <element name="EMPLOYEE_NUMBER" type="string"/> <element name="COST_CENTER" type="string"/> <element name="ASSET_AREA" type="string"/> <element name="ASSET_ADDRESS" type="string"/> <element name="ASSET_STATUS" type="string"/> <element name="BEGINNING_ASSET_NUM" nillable="true" type="string"/> <element name="PROPERTY_RIGHT_NUM" nillable="true" type="string"/> <element name="EVA_NET_VALUE" nillable="true" type="decimal"/> <element name="EVA_MONTHS_AVA" nillable="true" type="decimal"/> <element name="BEGINNING_PROJECT" nillable="true" type="string"/> <element name="MANAGEMENT_DEPT" nillable="true" type="string"/> <element name="EXTRA_MESSAGE1" nillable="true" type="string"/> <element name="EXTRA_MESSAGE2" nillable="true" type="string"/> <element name="EXTRA_MESSAGE3" nillable="true" type="string"/> <element name="RESERVED_1" nillable="true" type="string"/> <element name="RESERVED_2" nillable="true" type="string"/> <element name="RESERVED_3" nillable="true" type="string"/> <element name="RESERVED_4" nillable="true" type="string"/> <element name="RESERVED_5" nillable="true" type="string"/> <element name="RESERVED_6" nillable="true" type="string"/> <element name="RESERVED_7" nillable="true" type="string"/> <element name="RESERVED_8" nillable="true" type="string"/> <element name="RESERVED_9" nillable="true" type="string"/> <element name="RESERVED_10" nillable="true" type="string"/> <element name="RESERVED_11" nillable="true" type="string"/> <element name="RESERVED_12" nillable="true" type="string"/> <element name="RESERVED_13" nillable="true" type="string"/> <element name="RESERVED_14" nillable="true" type="string"/> <element name="RESERVED_15" nillable="true" type="string"/> </sequence> </complexType> <complexType name="ErrorCollection"> <sequence> <element maxOccurs="unbounded" minOccurs="0" name="ErrorItem" type="tns:ErrorItem"/> </sequence> </complexType> <complexType name="ErrorItem"> <sequence> <element name="ENTITY_NAME" nillable="true" type="string"/> <element name="PRI_KEY" nillable="true" type="string"/> <element name="ERROR_MESSAGE" nillable="true" type="string"/> <element name="BACH_NUM" nillable="true" type="string"/> <element name="RECORD_NUMBER" nillable="true" type="string"/> <element name="RESERVED_1" nillable="true" type="string"/> <element name="RESERVED_2" nillable="true" type="string"/> <element name="RESERVED_3" nillable="true" type="string"/> <element name="RESERVED_4" nillable="true" type="string"/> <element name="RESERVED_5" nillable="true" type="string"/> </sequence> </complexType> <complexType name="ResponseCollection"> <sequence> <element maxOccurs="unbounded" minOccurs="0" name="ResponseItem" type="tns:ResponseItem"/> </sequence> </complexType> <complexType name="ResponseItem"> <sequence> <element name="REQUEST_ID" nillable="true" type="string"/> <element name="PRI_KEY" nillable="true" type="string"/> <element name="BACH_NUM" nillable="true" type="string"/> <element name="RECORD_NUMBER" nillable="true" type="string"/> <element name="RESERVED_1" nillable="true" type="string"/> <element name="RESERVED_2" nillable="true" type="string"/> <element name="RESERVED_3" nillable="true" type="string"/> <element name="RESERVED_4" nillable="true" type="string"/> <element name="RESERVED_5" nillable="true" type="string"/> </sequence> </complexType> </schema>
location xsd 里的MsgHeader.xsd:
http://10.204.104.69:8888/UnicomWebservices/services/ESB_ERP_FA_ImportOtherAddAssetsInfoSrvPort?xsd=MsgHeader.xsd
<schema xmlns:tns="http://ws.project.com/MsgHeader" xmlns="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://ws.project.com/MsgHeader"> <complexType name="MsgHeader"> <sequence> <element name="SOURCE_APP_ID" type="string"/> <element name="SOURCE_APP_NAME" nillable="true" type="string"/> <element name="SOURCE_MOD_ID" type="string"/> <element name="SOURCE_MOD_NAME" nillable="true" type="string"/> <element name="TARGET_MOD_ID" nillable="true" type="string"/> <element name="TARGET_MOD_NAME" nillable="true" type="string"/> <element name="TOKEN" nillable="true" type="string"/> <element name="USERID" nillable="true" type="decimal"/> <element name="USERNAME" nillable="true" type="string"/> <element name="SUBMITDATE" nillable="true" type="dateTime"/> <element name="PAGE_SIZE" nillable="true" type="decimal"/> <element name="CURRENT_PAGE" nillable="true" type="decimal"/> <element name="TOTAL_RECORD" nillable="true" type="decimal"/> <element name="PROVINCE_CODE" type="string"/> <element name="ENVIRONMENT_NAME" nillable="true" type="string"/> </sequence> </complexType> </schema>
封装后WSDL:
http://localhost:8080/ESB_ERP_FA_ImportOtherAddAssetsInfoSrv/ESB_ERP_FA_ImportOtherAddAssetsInfoSrv?wsdl
<definitions name='ESB_ERP_FA_ImportOtherAddAssetsInfoSrv' targetNamespace='http://ws.project.com/ESB_ERP_FA_ImportOtherAddAssetsInfoSrv' xmlns='http://schemas.xmlsoap.org/wsdl/' xmlns:ns1='http://ws.project.com/MsgHeader' xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/' xmlns:tns='http://ws.project.com/ESB_ERP_FA_ImportOtherAddAssetsInfoSrv' xmlns:xsd='http://www.w3.org/2001/XMLSchema'> <types> <xs:schema elementFormDefault='qualified' targetNamespace='http://ws.project.com/ESB_ERP_FA_ImportOtherAddAssetsInfoSrv' version='1.0' xmlns:ns1='http://ws.project.com/MsgHeader' xmlns:tns='http://ws.project.com/ESB_ERP_FA_ImportOtherAddAssetsInfoSrv' xmlns:xs='http://www.w3.org/2001/XMLSchema'> <xs:import namespace='http://ws.project.com/MsgHeader'/> <xs:element name='ESB_ERP_FA_ImportOtherAddAssetsInfoSrvRequest' type='tns:ESB_ERP_FA_ImportOtherAddAssetsInfoSrvRequest'/> <xs:element name='ESB_ERP_FA_ImportOtherAddAssetsInfoSrvResponse' type='tns:ESB_ERP_FA_ImportOtherAddAssetsInfoSrvResponse'/> <xs:complexType name='ESB_ERP_FA_ImportOtherAddAssetsInfoSrvRequest'> <xs:sequence> <xs:element name='MsgHeader' type='ns1:MsgHeader'/> <xs:element name='ESB_ERP_FA_ImportOtherAddAssetsInfoSrvInputCollection' type='tns:ESB_ERP_FA_ImportOtherAddAssetsInfoSrvInputCollection'/> </xs:sequence> </xs:complexType> <xs:complexType name='ESB_ERP_FA_ImportOtherAddAssetsInfoSrvInputCollection'> <xs:sequence> <xs:element maxOccurs='unbounded' minOccurs='0' name='ESB_ERP_FA_ImportOtherAddAssetsInfoSrvInputItem' type='tns:ESB_ERP_FA_ImportOtherAddAssetsInfoSrvInputItem'/> </xs:sequence> </xs:complexType> <xs:complexType name='ESB_ERP_FA_ImportOtherAddAssetsInfoSrvInputItem'> <xs:sequence> <xs:element name='PRI_KEY' type='xs:string'/> <xs:element name='BATCH_NUM' type='xs:string'/> <xs:element name='CREATED_BY' type='xs:string'/> <xs:element name='PROVINCE_CODE' type='xs:string'/> <xs:element name='BOOK_TYPE_CODE' type='xs:string'/> <xs:element name='ASSET_ID' type='xs:decimal'/> <xs:element name='TAG_NUMBER' nillable='true' type='xs:string'/> <xs:element name='ASSET_DESCRIPTION' type='xs:string'/> <xs:element name='MANUFACTURER_NAME' nillable='true' type='xs:string'/> <xs:element name='MODEL_NUMBER' nillable='true' type='xs:string'/> <xs:element name='SERIAL_NUMBER' nillable='true' type='xs:string'/> <xs:element name='APPLICANT_AREA' type='xs:string'/> <xs:element name='ASSET_CATALOG' type='xs:string'/> <xs:element name='ASSET_PROFESSIONAL' type='xs:string'/> <xs:element name='ASSET_KEYWORD' type='xs:string'/> <xs:element name='ASSET_UNIT' type='xs:decimal'/> <xs:element name='ASSET_UOM' nillable='true' type='xs:string'/> <xs:element name='SPARE_UNITS' nillable='true' type='xs:decimal'/> <xs:element name='SPARE_UOM' nillable='true' type='xs:string'/> <xs:element name='ASSET_SOURCE' type='xs:string'/> <xs:element name='ASSET_BELONG' type='xs:string'/> <xs:element name='SP_CODE' nillable='true' type='xs:string'/> <xs:element name='DATE_IN_SERVICE' type='xs:dateTime'/> <xs:element name='LIFE_IN_MONTHS' nillable='true' type='xs:decimal'/> <xs:element name='DEPRN_RESERVE' nillable='true' type='xs:decimal'/> <xs:element name='YTD_DEPRN' nillable='true' type='xs:decimal'/> <xs:element name='ORIGINAL_COST' type='xs:decimal'/> <xs:element name='SALVAGE_VALUE' nillable='true' type='xs:decimal'/> <xs:element name='ACCUMU_IMPAIRMENT' nillable='true' type='xs:decimal'/> <xs:element name='IS_AMORTIZATION' type='xs:string'/> <xs:element name='EMPLOYEE_NUMBER' type='xs:string'/> <xs:element name='COST_CENTER' type='xs:string'/> <xs:element name='ASSET_AREA' type='xs:string'/> <xs:element name='ASSET_ADDRESS' type='xs:string'/> <xs:element name='ASSET_STATUS' type='xs:string'/> <xs:element name='BEGINNING_ASSET_NUM' nillable='true' type='xs:string'/> <xs:element name='PROPERTY_RIGHT_NUM' nillable='true' type='xs:string'/> <xs:element name='EVA_NET_VALUE' nillable='true' type='xs:decimal'/> <xs:element name='EVA_MONTHS_AVA' nillable='true' type='xs:decimal'/> <xs:element name='BEGINNING_PROJECT' nillable='true' type='xs:string'/> <xs:element name='MANAGEMENT_DEPT' nillable='true' type='xs:string'/> <xs:element name='EXTRA_MESSAGE1' nillable='true' type='xs:string'/> <xs:element name='EXTRA_MESSAGE2' nillable='true' type='xs:string'/> <xs:element name='EXTRA_MESSAGE3' nillable='true' type='xs:string'/> <xs:element name='RESERVED_1' nillable='true' type='xs:string'/> <xs:element name='RESERVED_2' nillable='true' type='xs:string'/> <xs:element name='RESERVED_3' nillable='true' type='xs:string'/> <xs:element name='RESERVED_4' nillable='true' type='xs:string'/> <xs:element name='RESERVED_5' nillable='true' type='xs:string'/> <xs:element name='RESERVED_6' nillable='true' type='xs:string'/> <xs:element name='RESERVED_7' nillable='true' type='xs:string'/> <xs:element name='RESERVED_8' nillable='true' type='xs:string'/> <xs:element name='RESERVED_9' nillable='true' type='xs:string'/> <xs:element name='RESERVED_10' nillable='true' type='xs:string'/> <xs:element name='RESERVED_11' nillable='true' type='xs:string'/> <xs:element name='RESERVED_12' nillable='true' type='xs:string'/> <xs:element name='RESERVED_13' nillable='true' type='xs:string'/> <xs:element name='RESERVED_14' nillable='true' type='xs:string'/> <xs:element name='RESERVED_15' nillable='true' type='xs:string'/> </xs:sequence> </xs:complexType> <xs:complexType name='ESB_ERP_FA_ImportOtherAddAssetsInfoSrvResponse'> <xs:sequence> <xs:element name='SERVICE_FLAG' nillable='true' type='xs:string'/> <xs:element name='INSTANCE_ID' nillable='true' type='xs:string'/> <xs:element name='SERVICE_MESSAGE' nillable='true' type='xs:string'/> <xs:element name='ErrorCollection' type='tns:ErrorCollection'/> <xs:element name='ResponseCollection' type='tns:ResponseCollection'/> </xs:sequence> </xs:complexType> <xs:complexType name='ErrorCollection'> <xs:sequence> <xs:element maxOccurs='unbounded' minOccurs='0' name='ErrorItem' type='tns:ErrorItem'/> </xs:sequence> </xs:complexType> <xs:complexType name='ErrorItem'> <xs:sequence> <xs:element name='ENTITY_NAME' nillable='true' type='xs:string'/> <xs:element name='PRI_KEY' nillable='true' type='xs:string'/> <xs:element name='ERROR_MESSAGE' nillable='true' type='xs:string'/> <xs:element name='BACH_NUM' nillable='true' type='xs:string'/> <xs:element name='RECORD_NUMBER' nillable='true' type='xs:string'/> <xs:element name='RESERVED_1' nillable='true' type='xs:string'/> <xs:element name='RESERVED_2' nillable='true' type='xs:string'/> <xs:element name='RESERVED_3' nillable='true' type='xs:string'/> <xs:element name='RESERVED_4' nillable='true' type='xs:string'/> <xs:element name='RESERVED_5' nillable='true' type='xs:string'/> </xs:sequence> </xs:complexType> <xs:complexType name='ResponseCollection'> <xs:sequence> <xs:element maxOccurs='unbounded' minOccurs='0' name='ResponseItem' type='tns:ResponseItem'/> </xs:sequence> </xs:complexType> <xs:complexType name='ResponseItem'> <xs:sequence> <xs:element name='REQUEST_ID' nillable='true' type='xs:string'/> <xs:element name='PRI_KEY' nillable='true' type='xs:string'/> <xs:element name='BACH_NUM' nillable='true' type='xs:string'/> <xs:element name='RECORD_NUMBER' nillable='true' type='xs:string'/> <xs:element name='RESERVED_1' nillable='true' type='xs:string'/> <xs:element name='RESERVED_2' nillable='true' type='xs:string'/> <xs:element name='RESERVED_3' nillable='true' type='xs:string'/> <xs:element name='RESERVED_4' nillable='true' type='xs:string'/> <xs:element name='RESERVED_5' nillable='true' type='xs:string'/> </xs:sequence> </xs:complexType> </xs:schema> <xs:schema targetNamespace='http://ws.project.com/MsgHeader' version='1.0' xmlns:xs='http://www.w3.org/2001/XMLSchema'> <xs:complexType name='MsgHeader'> <xs:sequence> <xs:element form='qualified' name='SOURCE_APP_ID' type='xs:string'/> <xs:element form='qualified' name='SOURCE_APP_NAME' nillable='true' type='xs:string'/> <xs:element form='qualified' name='SOURCE_MOD_ID' type='xs:string'/> <xs:element form='qualified' name='SOURCE_MOD_NAME' nillable='true' type='xs:string'/> <xs:element form='qualified' name='TARGET_MOD_ID' nillable='true' type='xs:string'/> <xs:element form='qualified' name='TARGET_MOD_NAME' nillable='true' type='xs:string'/> <xs:element form='qualified' name='TOKEN' nillable='true' type='xs:string'/> <xs:element form='qualified' name='USERID' nillable='true' type='xs:decimal'/> <xs:element form='qualified' name='USERNAME' nillable='true' type='xs:string'/> <xs:element form='qualified' name='SUBMITDATE' nillable='true' type='xs:dateTime'/> <xs:element form='qualified' name='PAGE_SIZE' nillable='true' type='xs:decimal'/> <xs:element form='qualified' name='CURRENT_PAGE' nillable='true' type='xs:decimal'/> <xs:element form='qualified' name='TOTAL_RECORD' nillable='true' type='xs:decimal'/> <xs:element form='qualified' name='PROVINCE_CODE' type='xs:string'/> <xs:element form='qualified' name='ENVIRONMENT_NAME' nillable='true' type='xs:string'/> </xs:sequence> </xs:complexType> </xs:schema> </types> <message name='ESB_ERP_FA_ImportOtherAddAssetsInfoSrv_processResponse'> <part element='tns:ESB_ERP_FA_ImportOtherAddAssetsInfoSrvResponse' name='payload'></part> </message> <message name='ESB_ERP_FA_ImportOtherAddAssetsInfoSrv_process'> <part element='tns:ESB_ERP_FA_ImportOtherAddAssetsInfoSrvRequest' name='payload'></part> </message> <portType name='ESB_ERP_FA_ImportOtherAddAssetsInfoSrv'> <operation name='process' parameterOrder='payload'> <input message='tns:ESB_ERP_FA_ImportOtherAddAssetsInfoSrv_process'></input> <output message='tns:ESB_ERP_FA_ImportOtherAddAssetsInfoSrv_processResponse'></output> </operation> </portType> <binding name='ESB_ERP_FA_ImportOtherAddAssetsInfoSrvBinding' type='tns:ESB_ERP_FA_ImportOtherAddAssetsInfoSrv'> <soap:binding style='document' transport='http://schemas.xmlsoap.org/soap/http'/> <operation name='process'> <soap:operation soapAction='process'/> <input> <soap:body use='literal'/> </input> <output> <soap:body use='literal'/> </output> </operation> </binding> <service name='ESB_ERP_FA_ImportOtherAddAssetsInfoSrv'> <port binding='tns:ESB_ERP_FA_ImportOtherAddAssetsInfoSrvBinding' name='ESB_ERP_FA_ImportOtherAddAssetsInfoSrvPort'> <soap:address location='http://localhost:8080/ESB_ERP_FA_ImportOtherAddAssetsInfoSrv/ESB_ERP_FA_ImportOtherAddAssetsInfoSrv'/> </port> </service> </definitions>
..
相关推荐
一个用wsdl4j.jar,ws-commons-java5-1.0.1.jar,XmlSchema-1.3.2.jar完全解析wsdl的例子, 本例子原本是xcalia studio中的一个模块,拿来和初次接触的人参考,因为我走了很多弯路,希望别人能少走。
如果在调用Web服务时遇到问题,检查HTTP通信错误、WSDL解析错误或者服务端返回的错误信息是解决问题的关键。 总的来说,Axis2 1.6.2提供了一种简洁的方式,帮助开发者快速地从WSDL生成客户端代码,从而简化Web服务...
总结,Java解析WSDL文档获取具体的方法与参数涉及的主要知识点包括:XML解析(DOM)、JAX-WS框架、`javax.xml.ws.Service`类的使用,以及如何基于WSDL生成服务客户端代码。理解这些概念,将有助于开发和消费Web服务...
WSDL是XML格式的,可以被工具解析并生成相应的客户端和服务端代码。通过这个过程,开发者可以快速地实现对WebService的调用和实现。 Java中,通常使用Apache CXF、 Axis2 或 JAX-WS等库来处理WSDL文件,生成对应的...
wsdl2java -uri your_wsdl_file.wsdl ``` 这将生成一系列的Java类,包括服务代理、消息处理器和服务实现类,它们可以直接在Java项目中使用。 3. **理解生成的Java代码** - **服务代理**:这是客户端与服务...
在这里,你需要将`http://your-wsdl-url`替换为你的WSDL服务的实际URL,`urn:YourSOAPAction`应替换为你的SOAP操作的命名空间URI。 接下来,调用服务操作类的方法,传入必要的参数: ```objc OperationClass *...
10. **调试与日志分析**:当以上方法都无法解决问题时,可以尝试使用WSDL解析器或XML解析器来定位错误,或者启用服务的日志记录功能,通过查看服务日志来获取更详细的错误信息。 解决WSDL文件出错的问题需要耐心和...
"Java 调用 WSDL" Java 调用 WSDL 是一种常见的技术,它允许 Java 应用程序调用远程... Java 调用 WSDL 文件是通过解析 WSDL 文件来获取服务的接口和操作信息,然后使用 AXIS 库或 SOAP 库等来调用远程的 Web 服务。
它可能包括如何解析 WSDL,如何调用服务,以及如何处理异常等方面的详细说明。 7. **最佳实践**:在实际应用中,应确保 WSDL 文件的正确性和服务端的稳定性,以避免客户端调用失败。同时,对于安全性要求高的场景,...
#### 三、WSDL技术解析 WSDL(Web Services Description Language)是一种基于XML的语言,用于描述网络服务的接口。它定义了服务的操作、消息格式、绑定信息和地址信息等,使得不同平台和服务之间能够互相发现并...
- `wsdl4j-*.jar`:WSDL解析库,用于处理WSDL文件。 4. **使用Axis2生成客户端代码的命令行工具** - Axis2提供了命令行工具`wsdl2java`,可以通过以下命令生成客户端代码: ``` java org.apache.axis2.wsdl....
本文将重点介绍如何利用Axis2工具集中的`java2wsdl`与`wsdl2java`命令来创建WebService接口定义文件和服务端代码,并进一步探讨如何通过Maven插件实现客户端代码的自动化生成。 #### 二、`java2wsdl`命令详解 `...
在IT行业中,Web服务是一种广泛使用的...这个过程涉及到WSDL的编写和解析、Java代码的生成、服务的部署以及客户端的调用,是理解Web服务工作原理和Axis工具的关键。在实际开发中,熟悉这些步骤能够极大地提高工作效率。
Axis插件则简化了这一过程,特别是对于生成客户端代码,使得开发者无需手动编写复杂的SOAP请求和解析响应。 三、生成客户端的步骤 1. 创建Web服务:首先,你需要有一个运行的Web服务。这通常涉及到编写一个Java类,...
Java 6提供了一个名为`wsimport.exe`的工具,用于解析WSDL文件并自动生成客户端代码。使用以下命令行参数调用`wsimport`: ```shell wsimport -d [class 文件存放目录] -s [源码存放目录] -p [包名] -keep [wsdl 的...
- 优化服务性能,例如通过缓存WSDL解析结果、减少不必要的网络请求等。 通过上述内容,我们可以看到Axis在Web服务开发中的重要作用。它简化了Web服务的创建、调用过程,同时提供了强大的源码级扩展性,使得开发者...
开发者可以通过WSDL文档了解服务提供的操作、输入和输出参数,进而实现客户端代码的自动生成。 4. JAX-WS(Java API for XML Web Services): JAX-WS是Java平台上的Web服务开发框架,它提供了创建、部署和消费...
- 其中 `-uri` 后跟 WSDL 文件路径,`-p` 后跟生成代码的包名。 #### 二、项目搭建与配置 1. **创建 Java 项目:** - 在 Eclipse 中创建一个新的 Java 项目。 2. **导入生成的代码:** - 将上一步生成的代码...
Axis作为客户端,可以解析WSDL文档,生成Java客户端 stubs,使得开发者能够轻松地调用Web Service。 **步骤一:获取WSDL文档** Web Service的提供者通常会公开WSDL文件,这是描述服务接口和操作的XML文档。例如,...