从独立的Java程序调用worklight适配器 [英] Invoking a worklight adaptor from a stand alone java program
本文介绍了从独立的Java程序调用worklight适配器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以使用以下网址在我的机器中调用worklight适配器程序。
I can invoke the worklight adaptor procedure in my machine by using the below URL.
现在,我想从java程序中调用它。
Now, i want to invoke this from a java program.
代码是这样的,
try {
URL myURL = new URL("http://192.168.1.101:10080/AdaptorUI /dev/invoke?adapter=MySQLAdaptor&procedure=procedure1¶meters=[]");
URLConnection myURLConnection = myURL.openConnection();
myURLConnection.connect();
}
catch (MalformedURLException e) {
// new URL() failed
// ...
System.out.println("Inside the MalformedURLException");
}
catch (IOException e) {
// openConnection() failed
// ...
System.out.println("IOException");
}
不知何故上述程序无效。你能帮忙吗?
Somehow the above program is not working. Can you pls help ?
推荐答案
首先,你应该从URL中删除/ dev; / dev应仅在开发环境中使用。
First, you should probably remove the /dev from the URL; /dev should be used only in a development environment.
其次,我建议查看为此问题提供的解决方案: Java URL似乎没有连接,但没有抛出异常
Second, I suggest looking at the solution provided to this question: Java URL doesn't seem to connect, but no exception thrown
来自评论:缺少代码行:
From the comments: Missing line of code:
BufferedReader in = new BufferedReader(new InputStreamReader(myURLConnection.getInputStream()));
这篇关于从独立的Java程序调用worklight适配器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文