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);
相关推荐
真智AI几秒前
利用 Claude Opus 4 自动化 GitHub 工作流:从安装到实战详解
运维·自动化·github
小磊哥er7 分钟前
【前端工程化】前端工作中的业务规范有哪些
前端
ᥬ 小月亮18 分钟前
webpack基础
前端·webpack
YongGit36 分钟前
探索 AI + MCP 渲染前端 UI
前端·后端·node.js
胡斌附体1 小时前
linux测试端口是否可被外部访问
linux·运维·服务器·python·测试·端口测试·临时服务器
愚润求学1 小时前
【Linux】自旋锁和读写锁
linux·运维
大锦终1 小时前
【Linux】常用基本指令
linux·运维·服务器·centos
慧一居士1 小时前
<script setup>中的setup作用以及和不带的区别对比
前端
知北游天1 小时前
Linux:多线程---深入互斥&&浅谈同步
linux·运维·服务器
Gappsong8741 小时前
【Linux学习】Linux安装并配置Redis
java·linux·运维·网络安全