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);