Invoking a worklight adaptor from a stand alone java program

让人想犯罪 __ 提交于 2019-12-11 17:58:39

问题


I can invoke the worklight adaptor procedure in my machine by using the below URL.

http://192.168.1.101:10080/AdaptorUI/dev/invoke?adapter=MySQLAdaptor&procedure=procedure1&parameters=[]

Now, i want to invoke this from a java program.

Code goes like this,

    try {

   URL myURL = new URL("http://192.168.1.101:10080/AdaptorUI  /dev/invoke?adapter=MySQLAdaptor&procedure=procedure1&parameters=[]");
    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 ?


回答1:


First, you should probably remove the /dev from the URL; /dev should be used only in a development environment.

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())); 


来源:https://stackoverflow.com/questions/28384675/invoking-a-worklight-adaptor-from-a-stand-alone-java-program

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!