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);
相关推荐
xiguolangzi2 分钟前
vue3+element-plus el-table列的显隐、列宽 持久化
前端·javascript·vue.js
用户6823806032254 分钟前
前端会用到的数据结构--堆(HEAP)
前端
莫空00004 分钟前
深入理解JavaScript的Reflect API:从原理到实践
前端·面试
卡布叻_星星4 分钟前
后端 Maven打包 JAR 文件、前端打包dist文件、通过后端服务访问前端页面、Nginx安装与部署
前端·maven·jar
前端(从入门到入土)20 分钟前
前端请求后端服务403(Invalid CORS request)
前端
超龄超能程序猿26 分钟前
Bitvisse SSH Client 安装配置文档
运维·ssh·github
奈斯ing43 分钟前
【Redis篇】数据库架构演进中Redis缓存的技术必然性—高并发场景下穿透、击穿、雪崩的体系化解决方案
运维·redis·缓存·数据库架构
蓝天白云下遛狗1 小时前
goole chrome变更默认搜索引擎为百度
前端·chrome
鳄鱼皮坡1 小时前
仿muduo库One Thread One Loop式主从Reactor模型实现高并发服务器
运维·服务器
come112341 小时前
Vue 响应式数据传递:ref、reactive 与 Provide/Inject 完全指南
前端·javascript·vue.js