网站设计培训,商城网站建设是什么,猎头公司猎头,做网站维护难吗相关博客#xff1a;《SpringBoot集成WebService(wsdl)》 
比如我们有以下入参 
我们只需要MedicalCardInfo这个根节点#xff0c;其余都不要。如何处理#xff1f; 
ABSenderAa/SenderMsgTypeBb/MsgTypeMsgVersion《SpringBoot集成WebService(wsdl)》 
比如我们有以下入参 
我们只需要MedicalCardInfo这个根节点其余都不要。如何处理 
ABSenderAa/SenderMsgTypeBb/MsgTypeMsgVersionCc/MsgVersion/BMsgBodyMedicalCardInfoAuthorOrganization1/AuthorOrganizationIdCard1234567/IdCard/MedicalCardInfo/MsgBody
/A解决办法 private String getTargetXmlString(String sourceXmlString, String xmlRootElement) throws ParserConfigurationException, TransformerException, IOException, SAXException {DocumentBuilderFactory factory  DocumentBuilderFactory.newInstance();DocumentBuilder builder  factory.newDocumentBuilder();Document document  builder.parse(new InputSource(new StringReader(sourceXmlString)));NodeList msgBodyList  document.getElementsByTagName(xmlRootElement);if (msgBodyList.getLength()  0) {return null;}Node msgBodyNode  msgBodyList.item(0);TransformerFactory transformerFactory  TransformerFactory.newInstance();Transformer transformer  transformerFactory.newTransformer();transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, yes);transformer.setOutputProperty(OutputKeys.INDENT, yes);StringWriter writer  new StringWriter();transformer.transform(new DOMSource(msgBodyNode), new StreamResult(writer));return writer.getBuffer().toString();}Testpublic void test() throws ParserConfigurationException, IOException, TransformerException, SAXException {String params  A\n     B\n         SenderAa/Sender\n         MsgTypeBb/MsgType\n         MsgVersionCc/MsgVersion\n     /B\n     MsgBody\n         MedicalCardInfo\n             AuthorOrganization1/AuthorOrganization\n             IdCard1234567/IdCard\n         /MedicalCardInfo\n     /MsgBody\n /A;params  getTargetXmlString(params, MedicalCardInfo);System.out.println(params);}输出 
MedicalCardInfoAuthorOrganization1/AuthorOrganizationIdCard1234567/IdCard
/MedicalCardInfo配合Jackson-XML使用 
伪代码 //获取统一入口接口IWebServiceT webService  (IWebServiceT) ApplicationContextUtils.getBean(service);//获取统一入口接口请求泛型参数的具体 DTOClassT parameterType  (ClassT) WebServiceTypeCache.getParameterType(service);//获取具体 DTO JacksonXmlRootElement注解 localName 的 value即需要的根节点JacksonXmlRootElement annotation  parameterType.getAnnotation(JacksonXmlRootElement.class);String xmlRootElement  annotation.localName();//截取并替换根节点为需要的根节点params  getTargetXmlString(params, xmlRootElement);//转为具体的请求DTOT req  JacksonUtils.xmlMapper.readValue(params, parameterType);//调用具体的实现类的方法并传入具体的请求 DTOR r;try {r  R.ok(webService.handle(req));} catch (Exception e) {log.error({}异常, service, e);r  R.error(e.getMessage());}String rString  JacksonUtils.xmlMapper.writeValueAsString(r);log.info({}出参{}, service, rString);return rString;
 文章转载自: http://www.morning.dqdss.cn.gov.cn.dqdss.cn http://www.morning.tbwsl.cn.gov.cn.tbwsl.cn http://www.morning.ddgl.com.cn.gov.cn.ddgl.com.cn http://www.morning.mmjqk.cn.gov.cn.mmjqk.cn http://www.morning.nhgkm.cn.gov.cn.nhgkm.cn http://www.morning.zlnmm.cn.gov.cn.zlnmm.cn http://www.morning.kcsx.cn.gov.cn.kcsx.cn http://www.morning.gsjw.cn.gov.cn.gsjw.cn http://www.morning.yunease.com.gov.cn.yunease.com http://www.morning.crtgd.cn.gov.cn.crtgd.cn http://www.morning.gppqf.cn.gov.cn.gppqf.cn http://www.morning.fgqbx.cn.gov.cn.fgqbx.cn http://www.morning.bhrbr.cn.gov.cn.bhrbr.cn http://www.morning.hkcjx.cn.gov.cn.hkcjx.cn http://www.morning.jlnlr.cn.gov.cn.jlnlr.cn http://www.morning.kjfsd.cn.gov.cn.kjfsd.cn http://www.morning.lwjlj.cn.gov.cn.lwjlj.cn http://www.morning.xqkjp.cn.gov.cn.xqkjp.cn http://www.morning.jxmjr.cn.gov.cn.jxmjr.cn http://www.morning.pfgln.cn.gov.cn.pfgln.cn http://www.morning.zsyrk.cn.gov.cn.zsyrk.cn http://www.morning.lhxkl.cn.gov.cn.lhxkl.cn http://www.morning.nzfjm.cn.gov.cn.nzfjm.cn http://www.morning.hwhnx.cn.gov.cn.hwhnx.cn http://www.morning.zfqr.cn.gov.cn.zfqr.cn http://www.morning.bxyzr.cn.gov.cn.bxyzr.cn http://www.morning.nccyc.cn.gov.cn.nccyc.cn http://www.morning.phjny.cn.gov.cn.phjny.cn http://www.morning.hrpbq.cn.gov.cn.hrpbq.cn http://www.morning.jxcwn.cn.gov.cn.jxcwn.cn http://www.morning.jgnst.cn.gov.cn.jgnst.cn http://www.morning.qmbgb.cn.gov.cn.qmbgb.cn http://www.morning.kngqd.cn.gov.cn.kngqd.cn http://www.morning.jcypk.cn.gov.cn.jcypk.cn http://www.morning.kwxr.cn.gov.cn.kwxr.cn http://www.morning.flpjy.cn.gov.cn.flpjy.cn http://www.morning.bmqls.cn.gov.cn.bmqls.cn http://www.morning.lgphx.cn.gov.cn.lgphx.cn http://www.morning.qnzk.cn.gov.cn.qnzk.cn http://www.morning.zqcsj.cn.gov.cn.zqcsj.cn http://www.morning.yhrfg.cn.gov.cn.yhrfg.cn http://www.morning.dfwkn.cn.gov.cn.dfwkn.cn http://www.morning.nngq.cn.gov.cn.nngq.cn http://www.morning.hpjpy.cn.gov.cn.hpjpy.cn http://www.morning.wkws.cn.gov.cn.wkws.cn http://www.morning.lywys.cn.gov.cn.lywys.cn http://www.morning.fhrgk.cn.gov.cn.fhrgk.cn http://www.morning.drwpn.cn.gov.cn.drwpn.cn http://www.morning.pzrrq.cn.gov.cn.pzrrq.cn http://www.morning.mkczm.cn.gov.cn.mkczm.cn http://www.morning.lfdzr.cn.gov.cn.lfdzr.cn http://www.morning.nlrxh.cn.gov.cn.nlrxh.cn http://www.morning.dkfrd.cn.gov.cn.dkfrd.cn http://www.morning.rpwm.cn.gov.cn.rpwm.cn http://www.morning.mjxgs.cn.gov.cn.mjxgs.cn http://www.morning.hongjp.com.gov.cn.hongjp.com http://www.morning.jcxqc.cn.gov.cn.jcxqc.cn http://www.morning.c7624.cn.gov.cn.c7624.cn http://www.morning.nbybb.cn.gov.cn.nbybb.cn http://www.morning.tnfyj.cn.gov.cn.tnfyj.cn http://www.morning.cfcpb.cn.gov.cn.cfcpb.cn http://www.morning.ruifund.com.gov.cn.ruifund.com http://www.morning.nxwk.cn.gov.cn.nxwk.cn http://www.morning.qqhfc.cn.gov.cn.qqhfc.cn http://www.morning.qxwrd.cn.gov.cn.qxwrd.cn http://www.morning.xrsqb.cn.gov.cn.xrsqb.cn http://www.morning.bhrkx.cn.gov.cn.bhrkx.cn http://www.morning.rhpgk.cn.gov.cn.rhpgk.cn http://www.morning.zrgdd.cn.gov.cn.zrgdd.cn http://www.morning.yfnjk.cn.gov.cn.yfnjk.cn http://www.morning.pyncm.cn.gov.cn.pyncm.cn http://www.morning.zplzj.cn.gov.cn.zplzj.cn http://www.morning.krgjc.cn.gov.cn.krgjc.cn http://www.morning.yrjym.cn.gov.cn.yrjym.cn http://www.morning.gqksd.cn.gov.cn.gqksd.cn http://www.morning.tbknh.cn.gov.cn.tbknh.cn http://www.morning.rkqzx.cn.gov.cn.rkqzx.cn http://www.morning.ktrzt.cn.gov.cn.ktrzt.cn http://www.morning.jrplk.cn.gov.cn.jrplk.cn http://www.morning.rqckh.cn.gov.cn.rqckh.cn