我有一个程序,其中包含与在SQL Server上运行的PLM应用程序的HTTP连接。该计划计划每天运行。它从几个来源收集数据,然后向PLM发出查询以存储数据,最后读取PLM的回复以验证数据是否被正确存储。
应用程序运行正常,直到我们升级了DB(进入SQL Server 2012)和PLM。
此后升级,当程序建立连接时,它接收OK状态;但是,数据设置查询不会影响数据库,也没有收到答复。没有错误消息 - 只是故障。
我的主要问题是 - 如何调试它。我知道我发送的东西和收到的东西。如何获得有关两者之间发生情况的更多数据?
我附上代码供审核。我没有在这里添加的是查询本身,它是类似WML的字符串。无论收到的查询是什么,PLM都应该触发答案,即使它是错误消息。但是,我只得到NULL。
public Boolean amlArasCommunication (String data , int targetDbType, String passWord)
{
final String url = "http://plm-srv/InnovatorServer/Server/InnovatorServer2012.aspx";
final String schemeUrl = "'http://schemas.xmlsoap.org/soap/envelope/'";
String answer =””;
String dataBase = data base name;
Writer wout;
HttpURLConnection amlConnection = null;
try
{
// instantiate the HttpURLConnection with the URL object - A new connection is
// opened every time by calling the openConnection method of the protocol
// handler for this URL. This is the point where the connection is opened.
amlConnection = (HttpURLConnection) new URL(url).openConnection();
amlConnection.setDoOutput(true);
amlConnection.setDoInput(true);
amlConnection.setRequestMethod("POST");
amlConnection.setRequestProperty("SOAPAction", "ApplyAML");
amlConnection.setConnectTimeout(10000);
amlConnection.setReadTimeout(10000);
amlConnection.setRequestProperty("AUTHUSER", "Admin");
amlConnection.setRequestProperty("AUTHPASSWORD", calcMD5(passWord));
amlConnection.setRequestProperty("DATABASE", dataBase);
String query = "<?xml version='1.0'?>\r\n" +
"<SOAP-ENV:Envelope xmlns:SOAP-ENV=" + schemeUrl + ">\r\n" +
" <SOAP-ENV:Body>\r\n" +
data +
" </SOAP-ENV:Body>\r\n" +
"</SOAP-ENV:Envelope>\r\n";
// instantiate OutputStreamWriter using the output stream, returned from getOutputStream, that writes
// to this connection. If an I/O error occurs while creating the output stream, IOException will be fired.
wout = new OutputStreamWriter(amlConnection.getOutputStream());
wout.write (query);
wout.close();
// At this point, we've sent all the data. The outputStream was closed, while the connection is still open
int result;
if ((result = amlConnection.getResponseCode()) == HttpURLConnection.HTTP_OK)
{
// Get the communication results from the PLM
InputStream ac = amlConnection.getInputStream();
InputStreamReader isr = new InputStreamReader (ac);
BufferedReader in = new BufferedReader(isr);
String readResult = in.readLine ();
int count = 0;
while (readResult != null)
{
answer += readResult + "\n";
readResult = in.readLine ();
count++;
}
in.close();
if (answer.contains("fault"))
System.out.println ("Error message: " + answer + "\nQuery: " + query);
else
log.message ("Lines count=" + count + "; com status=" + result + "; reply: " + answer, false);
}
else
// Error code is returned, or no status code is returned, do stuff in the else block
System.out.println("Connection failed with the following code: " + result);
}
catch (IOException e) { ; }
if (amlConnection != null)
amlConnection.disconnect ();
return true;
}
答案 0 :(得分:0)
我认为您必须查看PLM应用程序的日志文件,以找出没有获得HTTP响应的原因。升级后应用程序不再工作的原因可能有很多。
我想仅根据客户端代码调试问题很困难。由于服务器似乎接受了您的HTTP,我希望这个事件和错误会被写入某个日志文件。您可能还想尝试一些像SOAP UI这样的图形工具来测试SOAP服务。