CXF框架发布SOAP Web

复制代码
package com.kpl.webservice.server;


import com.kpl.webservice.domain.InterfaceResult;
import com.kpl.webservice.domain.vo.ERPProdOrderVo;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import java.util.List;


@WebService(
        name = "MesWebService",     //服务名
        targetNamespace = "http://server.webservice.kpl.com"  //命名空间
)
public interface MesWebService {

    /**
     * 订单表 ERP-MES  PROD_ORDER 新增 修改
     */
    @WebMethod
    public InterfaceResult insertProdOrder(@WebParam(name = "ERPProdOrder") List<ERPProdOrderVo> erpProdOrderVoList);

}

WebserviceConfig

复制代码
package com.kpl.webservice.config;


import com.kpl.webservice.server.MesWebService;
import org.apache.cxf.Bus;
import org.apache.cxf.bus.spring.SpringBus;
import org.apache.cxf.jaxws.EndpointImpl;
import org.apache.cxf.transport.servlet.CXFServlet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.xml.ws.Endpoint;


@Configuration
public class WebserviceConfig {


    @Autowired
    private MesWebService mesWebService;


    /**
     * 注入servlet  bean name不能dispatcherServlet 否则会覆盖dispatcherServlet
     *
     * @return
     */

    @Bean(name = "cxfServlet")
    public ServletRegistrationBean cxfServlet() {
        return new ServletRegistrationBean(new CXFServlet(), "/webservice/*");
    }


    @Bean(name = Bus.DEFAULT_BUS_ID)
    public SpringBus springBus() {
        return new SpringBus();
    }


    /**
     * 注册接口到webservice服务
     *
     * @return
     */

    @Bean
    public Endpoint psonEndpoint() {
        EndpointImpl endpoint = new EndpointImpl(springBus(), mesWebService);
        endpoint.publish("/webservice");
        return endpoint;
    }


}

SecurityConfig

复制代码
// 20241016 lgy 修改修复webservice 发布后需要授权访问问题
                .antMatchers("/webservice/**").permitAll()
                // 除上面外的所有请求全部需要鉴权认证
                .anyRequest().authenticated()
                .and()
                .headers().frameOptions().disable();
        httpSecurity.logout().logoutUrl("/logout").logoutSuccessHandler(logoutSuccessHandler);
        // 添加JWT filter
        httpSecurity.addFilterBefore(authenticationTokenFilter, UsernamePasswordAuthenticationFilter.class);
        // 添加CORS filter
        httpSecurity.addFilterBefore(corsFilter, JwtAuthenticationTokenFilter.class);
        httpSecurity.addFilterBefore(corsFilter, LogoutFilter.class);
相关推荐
塔能物联运维4 小时前
物联网运维中的自适应网络拓扑重构技术
运维·物联网·重构
weixin_307779134 小时前
AWS云上Quickwit部署指南与成本分析
服务器·自动化·云计算·运维开发·aws
文心快码BaiduComate4 小时前
文心快码3.5S实测插件开发,Architect模式令人惊艳
前端·后端·架构
Kimser5 小时前
基于 VxeTable 的高级表格选择组件
前端·vue.js
摸着石头过河的石头5 小时前
JavaScript 防抖与节流:提升应用性能的两大利器
前端·javascript
酸菜土狗5 小时前
让 ECharts 图表跟随容器自动放大缩小
前端
路由侠内网穿透5 小时前
本地部署开源数据分析平台 Elastic Stack 并实现外部访问( Windows 版本)
运维·服务器·网络·windows·开源·jenkins
_大学牲5 小时前
FuncAvatar: 你的头像氛围感神器 🤥🤥🤥
前端·javascript·程序员
回忆是昨天里的海5 小时前
k8s安装-kubeadm join,将工作节点加入k8s集群
java·服务器·kubernetes
葡萄城技术团队5 小时前
SpreadJS 性能飙升秘籍:底层优化技术深度拆解
前端