I tried the same a few weeks ago, and ended up using standard java classes.
More cumbersome, but if wrapped inside its own javascript function, you can
forget about the details...
Here's some javascript code for a POST request to give you an idea:
var connection = null;
try {
//Create connection
url = new java.net.URL( resourceUrl );
connection = url.openConnection();
connection.setRequestMethod( "POST" ); //"GET"
connection.setUseCaches( false );
connection.setDoInput( true );
connection.setDoOutput( true );
//Send request
var wr = new java.io.DataOutputStream( connection.getOutputStream() );
var bytesWritten = wr.writeBytes( resourceUrl );
logString += "" + bytesWritten + " bytes written to " + wr.toString() + "
on connection " + connection.toString();
wr.flush ();
wr.close ();
is = connection.getInputStream();
rd = new java.io.BufferedReader( new java.io.InputStreamReader( is ) );
var line;
var response = new java.lang.StringBuffer();
while( ( line = rd.readLine() ) != null ) {
response.append( line );
response.append( '\r' );
}
rd.close();
logString += " - RESPONSE: " + response.toString();
}
catch( e ) {
return logString + " | " + e.toString();
}
finally {
if ( connection != null ) {
connection.disconnect();
}
}
return logString;
Op woensdag 4 juni 2014 11:46:44 UTC+2 schreef Gaurav Dhiman:
>
> Hi ,
>
> Can we make XHR (call to 3rd party webservices) from OrientDB JS function
> context ?
> I am not using any application server (NodeJS / PHP etc), so need to do
> all required XHR in OrientDB JS functions.
>
> I did try but it failed. Any example code will be helpful.
>
> Thanks,
> Gaurav
>
--
---
You received this message because you are subscribed to the Google Groups
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.