CxfConfig.java 2.79 KB
package com.huaheng.framework.config;

import com.huaheng.api.erp.server.*;
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 javax.xml.ws.Endpoint;


/**
 * @ClassName CxfConfig
 * @Description TODO
 * @Author Administrator
 * @Date 2020/10/1214:11
 */

@Configuration
public class CxfConfig {


    private static final int LOG_LIMIT = 1;


    //本地wsdld服务端地址
    public static String wsdlUrl = "http://localhost:8888/wms/webService/shipment?wsdl";

    public static String taskwsdlUrl = "http://localhost:8888/wms/webService/assignTask?wsdl";
    //对方wsdl地址
    //public static String wsdlUrl = "http://";
    //ESB
    //public static String wsdlUrl = "http://";



    @Bean
    public ServletRegistrationBean webServlet(){
        return new ServletRegistrationBean(new CXFServlet(),"/webService/*");//发布服务名称
    }


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

    @Bean
    public ShipmentItemReceive shipmentItemReceive()
    {
        return  new ShipmentItemReceiveImpl();
    }

    @Bean
    public TaskReceive taskReceive()
    {
        return  new TaskReceiveImpl();
    }

    @Bean
    public BackDomainServiceImpl backDomainService()
    {
        return  new BackDomainServiceImpl();
    }

    @Bean
    public Endpoint endpoint() {
        EndpointImpl endpoint=new EndpointImpl(springBus(), shipmentItemReceive());
        endpoint.publish("/shipment");
        return endpoint;
    }

    @Bean
    public Endpoint endpoint2() {
        EndpointImpl endpoint=new EndpointImpl(springBus(), taskReceive());
        endpoint.publish("/assignTask");
        return endpoint;
    }


    @Bean
    public Endpoint endpoints() {
        EndpointImpl endpoint=new EndpointImpl(springBus(), backDomainService());
        endpoint.publish("/lackMat");
        return endpoint;
    }

    /**
     * @description 启用日志记录
     * @author fg
     * @date 2019年1月11日
     */
//    @Bean(name = Bus.DEFAULT_BUS_ID)
//    public SpringBus springBus() {
//        SpringBus springBus = new SpringBus();
//        LoggingInInterceptor ipt = new LoggingInInterceptor();
//        LoggingOutInterceptor opt = new LoggingOutInterceptor();
//        ipt.setPrettyLogging(true);
//        ipt.setLimit(LOG_LIMIT);
//        opt.setPrettyLogging(true);
//        opt.setLimit(LOG_LIMIT);
//        springBus.getInInterceptors().add(ipt);
//        springBus.getOutInterceptors().add(opt);
//        return springBus;
//    }




}