}
}
public ExecuteAnonymousResultExt executeAnonymous(String code, LogInfo[] logInfo, Connection connection,
int readTimeout) {
ConnectorConfig connectorConfig = connection.getConnectorConfig();
boolean orig_traceMsg = connectorConfig.isTraceMessage();
boolean orig_prettyPrintXml = connectorConfig.isPrettyPrintXml();
String orig_sessionId = connectorConfig.getSessionId();
String orig_serviceEndpoint = connectorConfig.getServiceEndpoint();
int orig_readTimeout = connectorConfig.getReadTimeout();
connectorConfig.setTraceMessage(true);
connectorConfig.setPrettyPrintXml(true);
connectorConfig.setSessionId(connection.getSessionId());
connectorConfig.setServiceEndpoint(connection.getApexServiceEndpoint(connection.getServiceEndpoint()));
connectorConfig.setReadTimeout(readTimeout);
SoapConnection apex = null;
try {
apex = Connector.newConnection(connectorConfig);
apex.setDebuggingHeader(logInfo, LogType.None);
return new ExecuteAnonymousResultExt(apex.executeAnonymous(code), apex.getDebuggingInfo());
} catch (ConnectionException e) {
ExecuteAnonymousResult er = errorExecuteAnonymousResult(connectorConfig, e);
ExecuteAnonymousResultExt erx = new ExecuteAnonymousResultExt(er, apex.getDebuggingInfo());
DebuggingInfo_element dbi = new DebuggingInfo_element();
dbi.setDebugLog(e.getMessage());
erx.setDebugInfo(dbi);
return erx;
} finally {
connectorConfig.setTraceMessage(orig_traceMsg);
connectorConfig.setPrettyPrintXml(orig_prettyPrintXml);
connectorConfig.setSessionId(orig_sessionId);
connectorConfig.setServiceEndpoint(orig_serviceEndpoint);
connectorConfig.setReadTimeout(orig_readTimeout);
}
}