springboot 发布webservice接口

1. pom 文件加包

        <dependency><groupId>org.apache.cxf</groupId><artifactId>cxf-rt-frontend-jaxws</artifactId><version>3.2.4</version></dependency><dependency><groupId>org.apache.cxf</groupId><artifactId>cxf-rt-transports-http</artifactId><version>3.2.4</version></dependency><dependency><groupId>jaxen</groupId><artifactId>jaxen</artifactId><version>1.1-beta-11</version><exclusions><exclusion><groupId>xerces</groupId><artifactId>xercesImpl</artifactId></exclusion></exclusions></dependency>

2.增加配置文件

@Configuration
public class CxfConfig {@Autowiredprivate PersonnelsyncService personnelsyncService;@Beanpublic ServletRegistrationBean servicesServlet() {ServletRegistrationBean bean = new ServletRegistrationBean(new CXFServlet(), "/services/*");bean.addInitParameter("hide-service-list-page", "true");return bean;}@Bean(name = Bus.DEFAULT_BUS_ID)public SpringBus springBus() {SpringBus springBus = new SpringBus();springBus.getProperties().put("org.apache.cxf.stax.maxTextLength", Integer.MAX_VALUE);return springBus;}@Beanpublic Endpoint organizationInfoService() {EndpointImpl endpoint = new EndpointImpl(springBus(), personnelsyncService);endpoint.publish("/OutHrmService");return endpoint;}
}

表示发布

3.

@WebService(name ="OutHrmService",targetNamespace="http://cornWeb.hbportal.wiseda.com")
@BindingType(value = SOAPBinding.SOAP12HTTP_BINDING)
public interface PersonnelsyncService {@WebMethod(operationName = "updateHrmResourceInfo")ReturnMes updateHrmResourceInfo(@WebParam(name="interfaceCode")String interfaceCode, @WebParam(name="recordXml")String recordXml) throws Exception;
}

4.实现类

//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//package com.wiseda.protal.webservice.impl;import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.wiseda.protal.dao.*;
import com.wiseda.protal.entity.*;
import com.wiseda.protal.eum.PersonSyncTypeEnum;
import com.wiseda.protal.vo.PersonSyncVo;
import com.wiseda.protal.webservice.PersonnelsyncService;
import com.wiseda.protal.webservice.ReturnMes;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;import cn.hutool.core.bean.BeanUtil;
import org.springframework.transaction.annotation.Transactional;import javax.jws.WebService;
import java.util.*;@WebService(serviceName ="OutHrmService",targetNamespace="http://cornWeb.hbportal.wiseda.com")
@Service
@Transactional
public class PersonnelsyncServiceImpl implements PersonnelsyncService {@AutowiredPersonnelSyncMapper personnelSyncMapper;@AutowiredSysEmployeeOrgMMapper sysEmployeeOrgMapper;@AutowiredSysPositionMapper sysPositionMapper;@AutowiredSysOrgUnitMMapper sysOrgUnitMapper;@AutowiredSysPersonnelSyncLogMapper sysPersonnelSyncLogMapper;@Overridepublic ReturnMes updateHrmResourceInfo(String interfaceCode,String recordXml) throws Exception {String  comp="";String  BasicCode = "";ReturnMes rm = new ReturnMes();List<Map<String, String>> list = new ArrayList<>();SysPersonnelSyncLog sysPersonnelSyncLog = new SysPersonnelSyncLog();sysPersonnelSyncLog.setCrtTime(new Date());sysPersonnelSyncLog.setBasiCode(BasicCode);sysPersonnelSyncLog.setSendPara(recordXml);try {Document document = DocumentHelper.parseText(recordXml);Element root = document.getRootElement();comp=root.element("Head").element("Comp").getText();BasicCode = root.element("Head").element("BasicCode").getText();List nodes= document.selectNodes("//Msg/Data/*");for (Iterator iter = nodes.iterator(); iter.hasNext(); ) {Map<String, String> param = new HashMap<>();Element element = (Element) iter.next();Element header = element.element("Header");List dataItems = header.elements("DataItem");for (Object it : dataItems) {Element element1 = (Element) it;param.put(element1.attributeValue("FieldName"), element1.attributeValue("FieldValue"));}list.add(param);}if(PersonSyncTypeEnum.PERSONNEL.getMessge().equals(BasicCode)){insertPersonnel(list);}if(PersonSyncTypeEnum.POST.getMessge().equals(BasicCode)){insertPost(list);}if(PersonSyncTypeEnum.DEPARTMENT.getMessge().equals(BasicCode)){insertDepartment(list);}rm.setErrorDescribe("成功");rm.setRecordCode(comp);rm.setSateCode("0");rm.setSysIdKeyList("0");sysPersonnelSyncLog.setReturnPara(rm.toString());}catch (Exception e){e.printStackTrace();rm.setErrorDescribe("服务错误解析失败:"+e);rm.setRecordCode(comp);rm.setSateCode("103");rm.setSysIdKeyList("0");sysPersonnelSyncLog.setReturnPara(e.toString());}sysPersonnelSyncLogMapper.insert(sysPersonnelSyncLog);return rm;}public void insertPersonnel(List<Map<String, String>> list){list.stream().forEach(x->{PersonSyncVo personSyncVo = BeanUtil.mapToBean(x, PersonSyncVo.class, true);String user_cd = personSyncVo.getSys_user_cd().substring(personSyncVo.getSys_user_cd().length() - 8);int size = personnelSyncMapper.selectList(new LambdaQueryWrapper<SysEmployee>().eq(SysEmployee::getId, user_cd)).size();if(size >0){personnelSyncMapper.deleteById(user_cd);sysEmployeeOrgMapper.delete(new LambdaQueryWrapper<SysEmployeeOrg>().eq(SysEmployeeOrg::getEmpId,user_cd));}SysEmployee sysEmployee = new SysEmployee();sysEmployee.setId(user_cd);sysEmployee.setCode(user_cd);sysEmployee.setName(personSyncVo.getSys_cd_nm());if ("36501".equals(personSyncVo.getSex_id())) {sysEmployee.setGender("1");} else {sysEmployee.setGender("2");}sysEmployee.setEmail(personSyncVo.getEmail_addr());sysEmployee.setMobile(personSyncVo.getMobile());sysEmployee.setIsDeleted(0);sysEmployee.setIsUse(1);sysEmployee.setPositionId(personSyncVo.getPost_id());sysEmployee.setCreateTime(new Date());sysEmployee.setSortNum(Integer.parseInt(personSyncVo.getSys_ord_cd()));personnelSyncMapper.insert(sysEmployee);//人员表SysEmployeeOrg sysEmployeeOrg = new SysEmployeeOrg();sysEmployeeOrg.setId(UUID.randomUUID().toString());//根据部门对照表,将数字门户部门Id替换 人资部门IdString orgid = personnelSyncMapper.selectPortalDeptId(personSyncVo.getDept_id());sysEmployeeOrg.setOrgId(orgid);sysEmployeeOrg.setEmpId(user_cd);sysEmployeeOrg.setIsMaster(1);sysEmployeeOrgMapper.insert(sysEmployeeOrg);//人员部门关联表});}public void insertPost(List<Map<String, String>> list){list.stream().forEach(x->{PersonSyncVo personSyncVo = BeanUtil.mapToBean(x, PersonSyncVo.class, true);int size = sysPositionMapper.selectList(new LambdaQueryWrapper<SysPosition>().eq(SysPosition::getId, personSyncVo.getSys_id_key())).size();if(size>0){sysPositionMapper.deleteById(personSyncVo.getSys_id_key());}SysPosition sysPosition = new SysPosition();sysPosition.setId(personSyncVo.getSys_id_key());sysPosition.setName(personSyncVo.getSys_cd_nm());sysPositionMapper.insert(sysPosition);});}public void insertDepartment(List<Map<String, String>> list){list.stream().forEach(x->{PersonSyncVo personSyncVo = BeanUtil.mapToBean(x, PersonSyncVo.class, true);//查询公司主键String companyId = sysOrgUnitMapper.selectPortalComp(personSyncVo.getYy_gsml());//上级部门idString parentId = personnelSyncMapper.selectPortalDeptId(personSyncVo.getParent_id());// 查询数字化门户对应的部门String departId = personnelSyncMapper.selectPortalDeptId(personSyncVo.getSys_id_key());int size = sysOrgUnitMapper.selectList(new LambdaQueryWrapper<SysOrgUnit>().eq(SysOrgUnit::getId, departId)).size();if(size>0){sysOrgUnitMapper.deleteById(departId);}SysOrgUnit sysOrgUnit = new SysOrgUnit();sysOrgUnit.setId(departId);sysOrgUnit.setCode(departId);sysOrgUnit.setName(personSyncVo.getSys_cd_nm());sysOrgUnit.setAliasCode(departId);sysOrgUnit.setAliasName(personSyncVo.getSys_cd_nm());sysOrgUnit.setNodeType("DEPT");if(StringUtils.isNotBlank(parentId)){sysOrgUnit.setParentId(parentId);}else{sysOrgUnit.setParentId(companyId);}sysOrgUnit.setIsInvented(0);sysOrgUnit.setIsUse(1);sysOrgUnit.setPathId(departId);sysOrgUnit.setIsDeleted(0);sysOrgUnit.setCreateTime(new Date());sysOrgUnit.setSortNum(Integer.parseInt(personSyncVo.getSys_ord_cd()));sysOrgUnitMapper.insert(sysOrgUnit);});}
}

5.postman调用

参数 要用 <![CDATA[]]>  包装   xml的话,要顶格写  列如:<![CDATA[<?xml version="1.0" encoding="gb2312"?><?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:test="http://cornWeb.hbportal.wiseda.com"><soapenv:Body><test:updateHrmResourceInfo><interfaceCode><![CDATA[10106]]></interfaceCode>        <recordXml><![CDATA[<?xml version="1.0" encoding="gb2312"?><Msg><Head><Source></Source><BasicCode>10106</BasicCode><Cryp></Cryp><Comp>35893863</Comp><Date>2024/04/11 03:00:24</Date><DataDefine><HeaderDefine QueryName="人员代码(全部)"><FieldItem FieldName="sys_id_key" Caption="系统内码" FieldType="NUMBER(18,0)" FieldLength="" Remark="" isPrimaryKey="True"/><FieldItem FieldName="sys_user_cd" Caption="国家局代码" FieldType="VARCHAR22(30)" FieldLength="" Remark="" isPrimaryKey="False"/><FieldItem FieldName="sys_cd_nm" Caption="职工姓名" FieldType="VARCHAR22(100)" FieldLength="" Remark="" isPrimaryKey="False"/><FieldItem FieldName="sex_id" Caption="性别" FieldType="NUMBER(18,0)" FieldLength="" Remark="" isPrimaryKey="False"/><FieldItem FieldName="dept_id" Caption="所属部门" FieldType="NUMBER(18,0)" FieldLength="" Remark="" isPrimaryKey="False"/><FieldItem FieldName="mobile" Caption="移动电话" FieldType="VARCHAR22(60)" FieldLength="" Remark="" isPrimaryKey="False"/><FieldItem FieldName="sys_ord_cd" Caption="排序码" FieldType="NUMBER(6,0)" FieldLength="" Remark="" isPrimaryKey="False"/><FieldItem FieldName="sys_use_mark" Caption="启用标记" FieldType="NUMBER(1,0)" FieldLength="" Remark="" isPrimaryKey="False"/><FieldItem FieldName="rem" Caption="所属公司" FieldType="VARCHAR22(100)" FieldLength="" Remark="" isPrimaryKey="False"/><FieldItem FieldName="tele_no" Caption="办公电话" FieldType="VARCHAR22(30)" FieldLength="" Remark="" isPrimaryKey="False"/><FieldItem FieldName="post_id" Caption="岗位" FieldType="NUMBER(18,0)" FieldLength="" Remark="" isPrimaryKey="False"/><FieldItem FieldName="email_addr" Caption="E-mail" FieldType="VARCHAR22(60)" FieldLength="" Remark="" isPrimaryKey="False"/><FieldItem FieldName="staff_tp_id" Caption="人员类别" FieldType="NUMBER(18,0)" FieldLength="" Remark="" isPrimaryKey="False"/></HeaderDefine></DataDefine></Head><Data><Row Index="1"><Header Action="update"><DataItem FieldName="sys_id_key" FieldValue="38211"/><DataItem FieldName="sys_user_cd" FieldValue="2013000100008712"/><DataItem FieldName="sys_cd_nm" FieldValue="王运华"/><DataItem FieldName="sex_id" FieldValue="36501"/><DataItem FieldName="dept_id" FieldValue="12823"/><DataItem FieldName="mobile" FieldValue="15933977958"/><DataItem FieldName="sys_ord_cd" FieldValue="99999"/><DataItem FieldName="sys_use_mark" FieldValue="1"/><DataItem FieldName="rem" FieldValue="1004"/><DataItem FieldName="tele_no" FieldValue=""/><DataItem FieldName="post_id" FieldValue=""/><DataItem FieldName="email_addr" FieldValue=""/><DataItem FieldName="staff_tp_id" FieldValue="30709112"/></Header></Row><Row Index="2"><Header Action="update"><DataItem FieldName="sys_id_key" FieldValue="38211"/><DataItem FieldName="sys_user_cd" FieldValue="2013000100008712111"/><DataItem FieldName="sys_cd_nm" FieldValue="王运华111"/><DataItem FieldName="sex_id" FieldValue="36501"/><DataItem FieldName="dept_id" FieldValue="12823"/><DataItem FieldName="mobile" FieldValue="15933977958"/><DataItem FieldName="sys_ord_cd" FieldValue="99999"/><DataItem FieldName="sys_use_mark" FieldValue="1"/><DataItem FieldName="rem" FieldValue="1004"/><DataItem FieldName="tele_no" FieldValue=""/><DataItem FieldName="post_id" FieldValue=""/><DataItem FieldName="email_addr" FieldValue=""/><DataItem FieldName="staff_tp_id" FieldValue="30709112"/></Header></Row><Row Index="3"><Header Action="update"><DataItem FieldName="sys_id_key" FieldValue="38211"/><DataItem FieldName="sys_user_cd" FieldValue="2013000100008712222"/><DataItem FieldName="sys_cd_nm" FieldValue="王运华2222"/><DataItem FieldName="sex_id" FieldValue="36501"/><DataItem FieldName="dept_id" FieldValue="12823"/><DataItem FieldName="mobile" FieldValue="15933977958"/><DataItem FieldName="sys_ord_cd" FieldValue="99999"/><DataItem FieldName="sys_use_mark" FieldValue="1"/><DataItem FieldName="rem" FieldValue="1004"/><DataItem FieldName="tele_no" FieldValue=""/><DataItem FieldName="post_id" FieldValue=""/><DataItem FieldName="email_addr" FieldValue=""/><DataItem FieldName="staff_tp_id" FieldValue="30709112"/></Header></Row></Data>
</Msg>]]></recordXml>
</test:updateHrmResourceInfo></soapenv:Body>
</soapenv:Envelope>

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/623731.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

NVM的安装与配置

目录 一、简介二、下载2.1、windows环境下载地址2.2、安装 三、配置3.1、查看可安装版本3.2、安装版本3.3、使用和切换版本3.4、模块配置 四、其他4.1、全局安装pnpm4.2、常用nvm命令 一、简介 NVM&#xff0c;全称为Node Version Manager&#xff0c;是一个流行的命令行工具&a…

OpenHarmony实战开发-在Native侧实现进度通知功能。

介绍 本示例通过模拟下载场景介绍如何将Native的进度信息实时同步到ArkTS侧。 效果图预览 使用说明 点击“Start Download“按钮后&#xff0c;Native侧启动子线程模拟下载任务Native侧启动子线程模拟下载&#xff0c;并通过Arkts的回调函数将进度信息实时传递到Arkts侧 实…

ubuntu 使用conda 创建虚拟环境总是报HTTP错误,转换多个镜像源之后仍报错

最近在使用Ubuntu conda创建虚拟环境时&#xff0c;总是报Http错误&#xff0c;如下图所示&#xff1a; 开始&#xff0c;我以为是conda 镜像源的问题&#xff0c;但是尝试了好几个镜像源都不行&#xff0c;还是报各种各样的HTTP错误。后来查阅很多&#xff0c;总算解决了。解…

spring高级篇(一)

1、ApplicationContext与BeanFactory BeanFactory是ApplicationContext的父级接口&#xff1a;&#xff08;citlaltu查看类关系图&#xff09; 在springboot的启动类中&#xff0c;我们通过SpringApplication.run方法拿到的是继承了ApplicationContext的ConfigurableApplicatio…

PHP直播电商平台APP开发应该具有的功能和搭建之前应该思考的过程?

直播电商平台是一个充满活力和潜力的领域&#xff0c;可以为用户提供全新的购物体验。以下是一些开发和搭建直播电商平台的想法&#xff1a; 功能丰富的直播模块&#xff1a; 实现主播与观众之间的实时互动&#xff0c;包括文字聊天、语音聊天、送礼物、打赏等功能。 商品展示…

竞技游戏新纪元:如何打造满足现代玩家需求的极致体验?

文章目录 一、现代玩家需求分析二、以玩家体验为核心的游戏设计三、个性化与定制化服务四、强化社交互动与社区建设五、持续更新与优化《游戏力&#xff1a;竞技游戏设计实战教程》亮点编辑推荐内容简介目录获取方式 随着科技的飞速发展和游戏产业的不断壮大&#xff0c;现代玩…

【程序分析】3-4 数据流分析-三种应用

目录 Reach Definition 可达分析 may analysis 算法 为什么会停&#xff1f; 活变量分析 may analysis: 不放过任何 path&#xff0c;v 在这条 path 上这条 path 就都要考虑 算法-后向传播 可用表达式分析 must analysis-不会误报&#xff0c;可能漏报 算法&#xff…

关于万兆以太网IP核仿真相关问题

文章目录 一、sim_speedup_control信号二、 一、sim_speedup_control信号 一般来说我们自己进行仿真时候该信号都直接给1&#xff0c;之前的高速IP核好像并没有出过错误&#xff0c;但是10G PCSPMS IP核进行仿真的时候&#xff0c;该信号必须要先置为0&#xff0c;等待用户复位…

react17 + antd4 如何实现Card组件与左侧内容对齐并撑满高度

在使用antd进行页面布局时&#xff0c;经常会遇到需要将内容区域进行左右分栏&#xff0c;并在右侧区域内放置一个或多个Card组件的情况。然而&#xff0c;有时我们会发现右侧的Card组件并不能与左侧的栏目对齐&#xff0c;尤其是当左侧栏目高度动态变化时。本文将介绍如何使用…

BTI性能开销权衡及优化措施

BTI分支目标识别精讲与实践系列 思考 1、什么是代码重用攻击&#xff1f;什么是ROP攻击&#xff1f;区别与联系&#xff1f; 2、什么是JOP攻击&#xff1f;间接分支跳转指令&#xff1f; 3、JOP攻击的缓解技术&#xff1f;控制流完整性保护&#xff1f; 4、BTI下的JOP如何…

【C++航海王:追寻罗杰的编程之路】异常——错误处理方式之一

目录 引言 1 -> C语言传统的处理错误的方式 2 -> C异常概念 3 -> 异常的使用 3.1 -> 异常的抛出和捕获 3.2 -> 异常的重新抛出 3.3 -> 异常规范 4 -> 自定义异常体系 5 -> C标准库的异常体系 6 -> 异常的优缺点 引言 在C编程中&#xff…

3dmax在线渲染怎么取消?怎么关闭云渲染

在线渲染&#xff0c;无论是通过云渲染服务还是渲染农场&#xff0c;已经成为众多3dmax动画制作者的首选方式来执行渲染任务。然而&#xff0c;如果在渲染过程中需要禁用这一在线渲染功能&#xff0c;该怎么操作呢&#xff1f;接下来&#xff0c;让我们一起探讨如何关闭这一功能…