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;
}
}