0
votes

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
Remove the /dev from the URL. Also, you did not mention what is the error that you're getting...Idan Adar
Idan, Forgot to mention, i am not invoking the procedure from the server/java folder, but from a java program on a remote machine. Is it possible ? Somewhere i read its possible, so tried it. The above code is not giving any error, its simply not calling the adaptor procedure.Pradeep John
Did you remove the /dev from the URL?Idan Adar
Also read the following. I do not think this is related to Worklight but to the Java. stackoverflow.com/questions/23704721/…Idan Adar
remvoing /dev doesn't help, Let me try the solution from the other link you posted.Pradeep John

1 Answers

0
votes

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