//package com.sap.www.config.webservice;
//
//import com.sap.www.sapmaster.service.MyWebService;
//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 {
//    @Bean
//    public ServletRegistrationBean disServlet(){
//        return new ServletRegistrationBean(new CXFServlet(),"/service/*");//发布服务名称
//    }
//
//    @Bean(name = Bus.DEFAULT_BUS_ID)
//    public SpringBus springBus()
//    {
//        return  new SpringBus();
//    }
//    //    @Autowired
////    private Bus bus;
//    @Autowired
//    public MyWebService myWebService;
//
//    @Bean
//    public Endpoint endpoint() {
//        EndpointImpl endpoint=new EndpointImpl(springBus(), myWebService);//绑定要发布的服务
//        endpoint.publish("/ZHXX_MES_SAP_WebService"); //显示要发布的名称
//        //endpoint.getInInterceptors().add(new AuthInterceptor());
//        return endpoint;
//    }
//}
package com.sw.mes.config.webservice;

import javax.xml.ws.Endpoint;

import org.apache.cxf.Bus;
import org.apache.cxf.bus.spring.SpringBus;
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 com.sw.mes.webservice.service.impl.MyWebServiceImpl;

@Configuration
public class WebServiceConfig {
	
	@Autowired
    private MyWebServiceImpl myWebServiceImpl;
	
	
    @Bean
    public ServletRegistrationBean webServiceServlet() {
        return new ServletRegistrationBean(new CXFServlet(),"/service/*");
    }

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


    @Bean
    public Endpoint userServiceEndpoint(MyWebServiceImpl myWebService) {
        Endpoint endpoint = Endpoint.create(myWebServiceImpl);
        endpoint.publish("/ZHXX_MES_SAP_WebService");//发布地址
        return endpoint;
    }

}
