问题
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¶meters=[]
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¶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 ?
回答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