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);
相关推荐
静西子2 小时前
Vue3路由
前端·javascript·vue.js
J总裁的小芒果2 小时前
vue3 全局定义动态样式
前端·javascript·vue.js
whalekv2 小时前
10月25日
前端·javascript·vue.js
华普微HOPERF4 小时前
Matter协议,如何塑造更宜居、流畅的智能家居网络?
服务器·网络·智能家居
万邦科技Lafite4 小时前
京东按图搜索京东商品(拍立淘) API (.jd.item_search_img)快速抓取数据
开发语言·前端·数据库·python·电商开放平台·京东开放平台
初学者_xuan4 小时前
零基础新手小白快速了解掌握服务集群与自动化运维(十五)Redis模块-Redis数据库基础
运维·数据库·自动化
小志biubiu5 小时前
【Linux】Ext系列文件系统
linux·服务器·c语言·经验分享·笔记·ubuntu·操作系统
DooTask官方号5 小时前
DooTask 1.3.38 版本更新:MCP 服务器与 AI 工具深度融合,开启任务管理新体验
运维·服务器·人工智能·开源软件·dootask
一只小透明啊啊啊啊6 小时前
Java Web 开发的核心组件:Servlet, JSP,Filter,Listener
java·前端·servlet
你的人类朋友7 小时前
设计模式有哪几类?
前端·后端·设计模式