81,122
社区成员




public class WSClientFactoryDX {
private static final WSClientFactoryDX instance = new WSClientFactoryDX();
private static JaxWsProxyFactoryBean dxCicFactoryBean;
static {
WsClientAuthHandler wsClientAuthHandler;
try {
dxCicFactoryBean = new JaxWsProxyFactoryBean();
dxCicFactoryBean.setServiceClass(ICICService.class);
dxCicFactoryBean
.setAddress("https://cic.dealextreme.com/v2.0/Services/CICService.svc");
if (true) {
dxCicFactoryBean.getOutInterceptors().add(
new LoggingOutInterceptor());
dxCicFactoryBean.getInInterceptors().add(
new LoggingInInterceptor());
}
Map<String, Object> cicMap = new HashMap<String, Object>();
cicMap.put(WSHandlerConstants.ACTION,
WSHandlerConstants.USERNAME_TOKEN);
cicMap.put(WSHandlerConstants.USER, "Username");
cicMap.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
wsClientAuthHandler = new WsClientAuthHandler();
wsClientAuthHandler.setUsername("");
wsClientAuthHandler.setPassword("");
cicMap.put(WSHandlerConstants.PW_CALLBACK_REF, wsClientAuthHandler);
WSS4JOutInterceptor cicWSSOut = new WSS4JOutInterceptor(cicMap);
dxCicFactoryBean.getOutInterceptors().add(cicWSSOut);
} catch (Exception ex) {
System.out.print("===method : WSClientFactoryDX Static ERROR==="
+ ex.getMessage());
}
}
public static WSClientFactoryDX getInstance() {
return instance;
}
private WSClientFactoryDX() {
}
public ICICService getDXCICProxyFacgtoryBean() {
return (ICICService) dxCicFactoryBean.create();
}
public static void main(String[] args) {
int mb = 1024*1024;
//Getting the runtime reference from system
Runtime runtime = Runtime.getRuntime();
System.out.println("Max Memory:" + runtime.maxMemory() / mb+"M");
while(true) {
ICICService icicService = WSClientFactoryDX.getInstance().getDXCICProxyFacgtoryBean();
try {
vRes = icicService.verifyCustomer(vReq);
} catch (Exception ex) {
} finally {
}
System.out.println("Total Memory:" + runtime.totalMemory() / mb+"M");
}
}
}
dxCicFactoryBean.create()
这个只需要创建一次,你循环创建了JaxWsProxyFactoryBean。