按我的要求,我根据响应headerfields的代码“213”。要连接到许多Web服务了一倍。如果头字段的值不是213,我们可以递归调用...如果值为“ E414“......然后我不应该连接到webservice来获取下一个数据。
Webservice的第一个URl请求将具有二进制格式并且正在读取转换后的二进制格式...循环并将其附加到stringbuilder中,因为当一切都完成时我必须将其写入.csv文件。我有堆栈溢出错误: 可能是什么原因导致堆栈跟踪
java.lang.StackOverflowError
at java.lang.Character.toUpperCase(Character.java:4278)
at java.lang.String.regionMatches(String.java:1383)
at java.lang.String.equalsIgnoreCase(String.java:1119)
at sun.net.spi.DefaultProxySelector$3.run(DefaultProxySelector.java:212)
at java.security.AccessController.doPrivileged(Native Method)
at sun.net.spi.DefaultProxySelector.select(DefaultProxySelector.java:201)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:358)
at java.net.Socket.connect(Socket.java:529)
at java.net.Socket.connect(Socket.java:478)
at sun.net.NetworkClient.doConnect(NetworkClient.java:163)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:394)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:529)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:233)
at sun.net.www.http.HttpClient.New(HttpClient.java:306)
at sun.net.www.http.HttpClient.New(HttpClient.java:323)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:970)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:911)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:836)
at com.cdsMonit.utils.GPBUtility.openWsConnection(GPBUtility.java:71)
at com.cdsMonit.utils.GPBUtility.readGPBStrucReadParamsSamplesSampling(GPBUtility.java:132)
at com.cdsMonit.utils.GPBUtility.readGPBStrucReadParamsSamplesSampling(GPBUtility.java:135)
Webservice的第一个URl请求将具有二进制格式并且正在读取转换后的二进制格式...循环并将其附加到stringbuilder中,因为当一切都完成时我必须将其写入.csv文件。 所以Webservice的第二个URl请求将是
public String getParamsNextStr() {
try {
paramsNextBuilder.append(ReadConfigProperies.getInstance().getConfKey("webserviceIp")).append(ApplicationConstants.WSREQ_READPARAMSSAMPLESNEXT).append("&key=").append(WebServiceCookiesEntity.getInstance().getKey().trim());
} catch (IOException ioe) {
GPBUTILI_LOGGER.error(ioe + " Error Occured under openWsConnection() in " + this.getClass());
}
return paramsNextBuilder.toString();
}
主要通话从以下代码开始:
if (webserviceMethod.getMode().equals(ApplicationConstants.MODE_GMT)) {
readGPBStrucReadParamsSamplesSampling(conn, ApplicationConstants.MODE_GMT, webserviceMethod);
}
public void readGPBStrucReadParamsSamplesSampling(HttpURLConnection conn, String readParamsSamplesSamplingMode, WebServiceToolData webserviceMethod) {
try {
if (readParamsSamplesSamplingMode.equals(ApplicationConstants.MODE_GMT)) {
ParamSamples.MULTI_PARAM_SAMPLES_PERGMT multi_param_samples_pergmt = null;
{
multi_param_samples_pergmt = ParamSamples.MULTI_PARAM_SAMPLES_PERGMT.newBuilder().mergeFrom(conn.getInputStream()).buildPartial();
iterateParamAllSamplesListPerGMT(multi_param_samples_pergmt, webserviceMethod);
conn.disconnect();
conn = openWsConnection(getParamsNextStr());
if (!"E414".equals(conn.getHeaderField("X_ISX_STATUS_CODE"))) {
readGPBStrucReadParamsSamplesSampling(conn, ApplicationConstants.MODE_GMT, webserviceMethod);
}
}
}
} catch (IOException ioExp) {
GPBUTILI_LOGGER.error(ioExp + " Error Occured under getMULTI_PARAM_SAMPLES_PERGMT() in " + this.getClass());
} catch (StackOverflowError overflowError) {
// GPBUTILI_LOGGER.error(overflowError + " Error Occured under getMULTI_PARAM_SAMPLES_PERGMT() in " + this.getClass());
overflowError.printStackTrace();
} catch (NullPointerException npe) {
GPBUTILI_LOGGER.error(npe + " Error Occured under getMULTI_PARAM_SAMPLES_PERGMT() in " + this.getClass());
}
}
如您所见,openWsConnection函数为每个URL获取连接对象和新连接输入流....
public HttpURLConnection openWsConnection(String address) {
try {
if (!isURl) {
page = new URL(address.toString());
}
conn = (HttpURLConnection) page.openConnection();
conn = (HttpURLConnection) WebServiceUtilities.getInstance().writeCookies(conn, false);
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
conn.connect();
// } else {
// conn = null;
// }
paramsNextBuilder.delete(0, paramsNextBuilder.length());
} catch (MalformedURLException malFormedExp) {
GPBUTILI_LOGGER.error(malFormedExp + " Error Occured under openWsConnection() in " + this.getClass());
} catch (ProtocolException protocaolExp) {
GPBUTILI_LOGGER.error(protocaolExp + " Error Occured under openWsConnection() in " + this.getClass());
} catch (IOException ioExp) {
GPBUTILI_LOGGER.error(ioExp + " Error Occured under openWsConnection() in " + this.getClass());
}
return conn;
}