我正在运行TCP / IP套接字,它发送SOAP消息然后获取响应然后读取它。
问题在于这种情况:首先一切都很好,我发送消息,然后使用swingworker得到响应。如果我关闭套接字,并尝试再次连接,我会通过布尔值停止swing工作者。当我再次连接时,我让线程运行,但是当我发送SOAP消息时,我没有从套接字获得任何输出,但是当我在那时进行调试,然后我逐步调试代码时,我得到一个响应和输出!怎么会发生这种情况?
这是我的代码:
protected Object doInBackground() throws Exception {
Integer result = 1;
while (true) {
if (startReading && !this.server.isSocketClosed()) {
// send the SOAP Message based on which message is selected
SendSOAPRequestMessage();
//Thread.sleep(5);
String responseMessage = null;
try {
// get the response from the client/server
responseMessage = Utils.convertStreamToString(this.server);
System.out.println(responseMessage);
// give the message without the header + and check the content length and if the header is corrupted
fullMsg = decoder.DecodeSoapHeader(new String(responseMessage.getBytes("UTF-8")));
} catch (Exception ex) {
Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
}