package com.foreverwin.mesnac.integration.config;


import com.foreverwin.mesnac.integration.service.CAPPAPIWebService;
import com.foreverwin.mesnac.integration.service.ERPAPIWebService;
import org.apache.cxf.Bus;
import org.apache.cxf.jaxws.EndpointImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.xml.ws.Endpoint;

/**
 * 访问地址样例：
 * 本地测试：http://localhost:50000/webservice/EAPIWebService?wsdl
 * 发布服务器：http://localhost:50000/manufacturing-app/webservice/EAPIWebService?wsdl
 */
@Configuration
public class IntegrationConfiguration {

    @Autowired
    private Bus bus;
    @Autowired
    private ERPAPIWebService ERPAPIWebService;
    @Autowired
    private CAPPAPIWebService CAPPAPIWebService;

    @Bean
    public Endpoint erpWebService() {
        EndpointImpl endpoint = new EndpointImpl(bus, ERPAPIWebService);
        //显示要发布的名称
        endpoint.publish("/ERPAPIWebService");
        return endpoint;
    }


    @Bean
    public Endpoint cappWebService() {
        EndpointImpl endpoint = new EndpointImpl(bus, CAPPAPIWebService);
        //显示要发布的名称
        endpoint.publish("/CAPPAPIWebService");
        return endpoint;
    }
}
