package com.ann.demo.utils;

import com.ann.demo.controller.JAXDynamicClientFactory;
import org.apache.cxf.endpoint.Client;

/**
 * @Author: LeiJiaXin
 * @Date: 2019/10/10 11:07
 */
public class WebServiceUtils {

    private static Client client = null;
    public static Object[] connect(String path) throws Exception {
        String wsdlUrl = "http://10.6.0.224/cdms/cdmsservice.asmx?wsdl";
        String wsdlMethod = "GetImageStream";
        /*String wsdlUrl = "http://localhost:8099/services/api?wsdl";
        String wsdlMethod = "emrService";*/
        if(client == null) {
            JAXDynamicClientFactory dcf = JAXDynamicClientFactory.newInstance();
            client = dcf.createClient(wsdlUrl);
        }
        try {
            // invoke("方法名",参数1,参数2,参数3....);
            return client.invoke(wsdlMethod, path);
        } catch (Exception e) {
            return null;
        }
/*
        JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
        Client client = dcf.createClient("http://10.6.0.224/cdms/cdmsservice.asmx?wsdl");
        Object[] objects = new Object[0];
        try {
            // invoke("方法名",参数1,参数2,参数3....);
            return objects = client.invoke("GetImageStream", path);
        } catch (Exception e) {
            return null;
        }
*/
    }

    public static void main(String[] args) {
        String path = "D:/test";
        try {
            Object[] objects = connect(path);
            String s = objects[0].toString();
            System.out.println(s);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
