package org.jeecg.modules.system.util;

import org.apache.cxf.endpoint.Client;
import org.apache.cxf.endpoint.Endpoint;
import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
import org.apache.cxf.service.model.BindingInfo;
import org.apache.cxf.service.model.BindingOperationInfo;

import com.alibaba.fastjson.JSONObject;

import java.util.HashMap;

import javax.xml.namespace.QName;
 
 
public class TestCase {
    public static void main(String[] args) {
        //wsdl地址
        String url = "http://gxb.v1.idcfengye.com/openmeetings/services/ApiRoomService?wsdl";
        //命名空间
        String namespace = "http://gxb.v1.idcfengye.com";
        //方法名
        String methodName = "getRoomUrl";
 
        JaxWsDynamicClientFactory factory = JaxWsDynamicClientFactory.newInstance();
        Client client = factory.createClient(url);
        Endpoint endpoint = client.getEndpoint();
        QName opName = new QName(namespace, methodName);
        BindingInfo bindingInfo = endpoint.getEndpointInfo().getBinding();
        if (bindingInfo.getOperation(opName) == null) {
            for (BindingOperationInfo operationInfo : bindingInfo.getOperations()) {
                if (methodName.equals(operationInfo.getName().getLocalPart())) {
                    opName = operationInfo.getName();
                    break;
                }
            }
        }
        try {
            Object[] objects = client.invoke(opName,  "admin",11L);
            Object object = objects[0];
            String resultMsg = JSONObject.toJSONString(object) ;
            System.out.println("获取返回结果 ：" + resultMsg);
        } catch (java.lang.Exception e) {
            e.printStackTrace();
            System.out.println("异常信息 ：" + e.getMessage());
        }
    }
 
 
}
 
