📄 webserviceproxyfactory.java
字号:
package com.dmwsinvoke;
import java.lang.reflect.Method;
import net.sf.cglib.proxy.Enhancer;
import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;
public abstract class WebServiceProxyFactory
{
private static Enhancer enhancer = new Enhancer();
private static String wsdld;
private static void initial(String wsdl, Class clazz)
{
enhancer.setSuperclass(clazz);
enhancer.setCallback(new MethodInterceptorImpl());
wsdld = wsdl;
}
public static Object getInstance(String wsdl, Class clazz)
{
initial(wsdl, clazz);
return enhancer.create();
}
private static class MethodInterceptorImpl implements MethodInterceptor
{
public Object intercept(Object obj, Method method, Object[] args,
MethodProxy proxy) throws Throwable
{
if(wsdld == null)
{
throw new Exception("WSDL为空");
}
String methodName = method.getName();
Class exceptReturnType = method.getReturnType();
Object o = DynamicWebServiceInvoker.invokeService(wsdld, methodName,
args, exceptReturnType);
return o;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -