CXFConfig.java 1.72 KB
package com.bsth;

import com.bsth.ws_server.park_station.CompanyServiceSoap;
import com.bsth.ws_server.waybill.LD_ServiceSoap;
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.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;

import javax.xml.ws.Endpoint;

/**
 * Created by panzhao on 2017/3/9.
 */
@Configuration
public class CXFConfig {

    @Bean(name = Bus.DEFAULT_BUS_ID)
    public SpringBus springBus() {
        return new SpringBus();
    }

    public CompanyServiceSoap companyService(){
        return new CompanyServiceSoap();
    }

    public LD_ServiceSoap ldServiceSoap(){
        return new LD_ServiceSoap();
    }

    @Bean
    public Endpoint companyEndpoint() {
        EndpointImpl endpoint = new EndpointImpl(springBus(), companyService());
        endpoint.publish("/CompanyService");
        //endpoint.getInInterceptors().add(new AuthInterceptor());
        return endpoint;
    }

   @Bean
    public Endpoint ldServiceEndpoint() {
        EndpointImpl endpoint = new EndpointImpl(springBus(), ldServiceSoap());
        endpoint.publish("/LD_Service");
        //endpoint.getInInterceptors().add(new AuthInterceptor());
        return endpoint;
    }

    @Bean
    public ServletRegistrationBean servletRegistrationBean() {
        ServletRegistrationBean bean = new ServletRegistrationBean(new CXFServlet(), "/webservice/*");
        bean.setLoadOnStartup(0);
        bean.setOrder(Ordered.HIGHEST_PRECEDENCE);
        return bean;
    }
}