美文网首页
Xfire调用 webservice封装

Xfire调用 webservice封装

作者: wuyuan0127 | 来源:发表于2017-08-31 10:50 被阅读0次

    import java.net.MalformedURLException;

    import java.net.URL;

    import org.codehaus.xfire.client.Client;

    import org.slf4j.Logger;

    import org.slf4j.LoggerFactory;

    /**

    * @ClassName CallWSDLUtil

    * @Description 使用Xfire调用WSDL接口

    * @param object 用来存储方法的参数

    * @date 2016年4月11日

    *

    */

    public class CallWSDLUtil {

    private static final Logger LOG = LoggerFactory.getLogger(CallWSDLUtil.class);

    public static String invokeRemoteFuc(String endpoint,String operationName,Object... values) {

    String result = "";

    try {

    Client c = new Client(new URL(endpoint));

    Object[] object = null;

    if (values != null) {

    object = new Object[values.length];

    for (int i = 0; i < values.length; i++) {

    object[i] = values[i];

    }

    } else {

    object = new Object[0];

    }

    Object[] results = c.invoke(operationName, object);

    if (results != null) {

    result = results[0].toString();

    }

    } catch (MalformedURLException e) {

    LOG.error(e.getMessage(), e);

    } catch (Exception e) {

    LOG.error(e.getMessage(), e);

    }

    return result;

    }

    }

    相关文章

      网友评论

          本文标题:Xfire调用 webservice封装

          本文链接:https://www.haomeiwen.com/subject/ootqjxtx.html