springboot+shiro集成webService

接口代码如下:

@WebService
public interface SysCustomerAttachmentService {
    @WebMethod
    ESBResponseEntity insertCousterAttachment(@WebParam(name="header") ESBHeaderEntity header,@WebParam(name="list") List<CustomAttachmentContentEntity> list);

}

实现类代码:

@WebService(targetNamespace="http://service.jfcus.modules.fawjiefang.com/",endpointInterface = "com.fawjiefang.modules.jfcus.service.SysCustomerAttachmentService")
//@Service("sysCustomerAttachmentService")
public class SysCustomerAttachmentServiceImpl extends ServiceImpl<SysCustomerAttachmentDao, CustomAttachmentContentEntity> implements SysCustomerAttachmentService {

    @Autowired
    SysCustomerAttachmentDao sysCustomerAttachmentDao;
    @Transactional
    @Override
    public ESBResponseEntity insertCousterAttachment(ESBHeaderEntity header,List<CustomAttachmentContentEntity> list) {
        ESBResponseEntity entity = new ESBResponseEntity();
        try {
            if(header == null){
                entity.setResultType("0");
                entity.setResultCode("502");
                entity.setResultMessage("成功接收0条数据,报文中body中arg0信息是空");
                return entity;
            }
            if(list == null  ||  list.size() == 0){
                entity.setResultType("0");
                entity.setResultCode("502");
                entity.setResultMessage("成功接收0条数据,报文中body中arg1信息为空");
                return entity;
            }
            for (int i=0;i<list.size();i++) {
                UUID uuid = UUID.randomUUID();
                list.get(i).setID(uuid.toString());
                list.get(i).setJSTIME(new Date().toString());
                list.get(i).setTRANSID(header.getTransID());
                list.get(i).setMESSAGEID(header.getMessageID());
            }
                sysCustomerAttachmentDao.saveCustomAttachment(list);
                entity.setCount(header.getCount());
                entity.setMessageID(header.getMessageID());
                entity.setTransID(header.getTransID());
                entity.setInterfaceID(header.getInterfaceID());
                entity.setResultType("0");
                entity.setResultCode("502");
                entity.setResultMessage("成功接收"+list.size()+"数据");
                return entity;
        } catch (Exception e) {
            e.printStackTrace();
            entity.setResultCode("402");
            entity.setResultType("-1");
            entity.setResultMessage("服务异常,请联系相关人员");
            return entity;
        }
    }

}

配置类:

@Configuration
public class WebConfig{
    @SuppressWarnings({ "rawtypes", "unchecked" })
    @Bean
    public ServletRegistrationBean getCXFServlet(){

        return new ServletRegistrationBean(new CXFServlet() , "/webService/*");
    }
    @Bean(name = Bus.DEFAULT_BUS_ID)
    public SpringBus springBus()
    {
        return  new SpringBus();
    }

    @Bean
    public SysCustomerAttachmentService sysCustomerAttachmentService()
    {
        return  new SysCustomerAttachmentServiceImpl();
    }

    @Bean
    public Endpoint endpoint() {
        EndpointImpl endpoint=new EndpointImpl(springBus(), sysCustomerAttachmentService());
        endpoint.publish("/sysCustomerAttachmentService");
        return endpoint;
    }
}
如下截图:是项目中shiro的路径权限配置,注意红色部分意思是不是任何路径都可以匿名访问的,所以利用cxf发布接口时要注意发布的路径不可以是/**或者/*,发布其他路径时记得要在shiro权限过滤中设置发布的路径可以匿名访问。如绿色框中的部分。重新启动项目即可访问成功。
springboot+shiro集成webService