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);
相关推荐
张人玉1 分钟前
高德API精讲系——vue+高德API搭建前端环境页面
前端·javascript·vue.js·高德api
weixin_307779133 分钟前
Jenkins SSH Build Agents 插件详解:远程构建的利器
运维·开发语言·架构·ssh·jenkins
靈龍靈6 分钟前
ELBK部署
运维·ci/cd·jenkins
为什么要内卷,摆烂不香吗6 分钟前
sed 流编辑器练习自用
linux·运维·编辑器
智象科技6 分钟前
从资源到业务:运维监控体系的差异
大数据·运维·一体化运维·智能运维·多云管理
杜子不疼.8 分钟前
【Linux】多机管理终极方案:禁用 root 密码,用面板实现批量部署 + 操作追溯
linux·运维·服务器
艾莉丝努力练剑10 分钟前
【Python基础:语法第五课】Python字典高效使用指南:避开KeyError,掌握遍历与增删改查精髓
大数据·运维·人工智能·python·安全·pycharm
后端小张11 分钟前
【JAVA进阶】Docker 2025完全指南:从容器入门到企业级实践
java·运维·开发语言·spring·docker·容器·springboot
西西偷西瓜12 分钟前
Trae IDE 读取并解析接口文档:trae-swagger-mcp 插件开发分享
前端·ide·自动化·yapi·ai编程
DeepFlow 零侵扰全栈可观测12 分钟前
金山办公基于 DeepFlow docker 模式的可观测性实践
运维·docker·容器