I want to create a Talend component that based on javajet code, that talend component fetch data from one web based inventory system. But the thing is that the api of that system is available in php so I want to use that php api function in javajet code. is it possible?
The .javajet code generates plain Java, so you cannot embed or call PHP directly in that. But you should be able to call your PHP API by invoking the PHP interpreter as a subprocess in the generated code, e.g. by calling
Runtime.getRuntime().exec("php myapi.php").
You would then need to come up with a mechanism to pass arguments and results to/from the subprocess, preferably via command-line arguments and/or standard input and standard output.
Alternatively, you might want to invoke your PHP API through a web server, which means you would have to issue an HTTPRequest to that webserver and parse the response you get from the server.
Related
I was asked is there anyway to call RESTful API only by java.io. No java.net URL and 3rd party library. I did try to open HTTP by different reader/InputStream under java.io, it seems getting FileNotFoundExceptions, etc.
Any ideas?
According to the Java documentation:
Package java.io
Provides for system input and output through data streams,
serialization and the file system.
In order to make a REST call using such such approach, you may write a REST method call into a JSON format and payload into a File then have a another application read the file that will then do the actual REST API call.
And since this is not a direct REST call, the answer to your question is that it's not possible not to use any networking module of the Java Platform to achieve what you require.
Although I wonder why you are restricted to use only java.io for REST API calls?
I was thinking it can make RESTful call indirectly via OS command, e.g. compose curl script and use Process to execute it, it redirect output to a file and then read the output file to parse output JSON
I have two WEB applications based on two different servers. How I can pass data from the PHP web form, which consists of 5-10 fields, to Java application(Struts2, Spring2) in the most elegant and safe way?
I think cURL should be enough, you can make HTTP(S) requests from one to the othe server.
let the PHP return a JSON object, best would be RESTfull.
let the java code make a REST call
One answer: API. That's what APIs are intended for - communication between applications.
Create endpoint in the JAVA app that acceps the data and does something with it.
In PHP after recieving the data from form make a call to the JAVA app endpoint and send the data there.
For security you may want to use some data encription using oauth (that is if you data requires that kind of security).
You have created an API which will return JSON array.
Call that API from java application and get JSON, decode JSON and use that.
What are the various options to call a "specific" Java method from Javascript and have callback, etc?
E.g. One i know is using DWR..But wanted to know if there are any other libraries that can be used OR if this can be done by AJAX itself..
What is the recommended approach?
Put simply, with the possible exception of a Java applet running in the same page context as the JavaScript, there is no way for JavaScript to directly call a Java method, or vice-versa. DWR isn't calling any Java methods directly from JavaScript, it's sending an AJAX request to the server and using its own intermediate layer to instrument the request and response processing such that it looks as if it is calling Java methods.
But anyways, the typical approach for getting JavaScript code in the client and Java code on the server to talk to one another is to define an API on the server that is exposed to the client. The client can then make requests (using AJAX or whatever other mechanism you prefer) using the exposed API. The client isn't calling any Java methods directly, instead it's sending a request to a given URL on the server, which gets mapped back to some bit of Java code. Most popular JavaScript frameworks provide convenience methods for simplifying AJAX request handling and callbacks.
If for some reason you want functionality equivalent to being able to call an arbitrary method in an arbitrary class and have the result returned to you, then you could define an API method that takes as parameters a class name and a method name and then uses reflection to perform the method invocation. This would probably be very close to what the server-side portion of DWR is doing.
I know you can do this when using Mozilla Rhino, but I'm guessing that you're talking about a browser run-time environment, so maybe this response isn't very helpful.
I have a requirment, of invoking a Java file from Oracle database. In my project, whole of my business logic is in database, but there is a requirement of invoking a third party system (SOAP / RMI call) from my application.
Now for this i need to invoke atleast a Java Code or a batch script file (depending on Windows(.bat) Or Linux(.sh)).
Thanks
Try this page: http://www.cs.umbc.edu/portal/help/oracle8/java.815/a64686/04_call2.htm
You can can Java-Code from your PL/SQL.
Web-service call outs can be done from the Oracle Database. I'm not sure why you need to use Java for this as PL/SQL also allows for outbound calls using UTL_DBWS.
If you do not intend to use JPublisher, or you have a very simple web-service to consume, then you can use UTL_HTTP itself, or the appropriate class in Java - HttpURLConnection. However, I've never seen any case where a JAX-RPC library or any other web-service library was loaded into the database using loadjava, and used to make web-service calls; it ought to be possible do so, as long as the library is very light (in not depending on other libraries that cannot be loaded or used in the database), and requires permissions only to connect out from the database.
Related question
Access Web service from Oracle stored procedure
We have several classic asp web application that instantiates a visual basic 6 component, passes a (possibly huge) xml string, and gets back a (also possibly huge) xml string.
This component is the only way we have to interact with the database.
We are planning to rewrite this component using java. The idea is to left the rest of the asp application untouched.
So we need to execute some java component passing and receiving a string, from classic asp running on an iis...
We are looking for something with the less overhead possible (obviously, I'm trying to avoid having a web service call for each db operation)
which would be the best approach to achieve such a thing?
thanks a lot
this is the code we need to migrate:
Private Function ComandoExecute( Xml )
Dim Comando
Set Comando = Server.CreateObject("TramitesConsultaComando.clsComando")
ComandoExecute = Comando.execute(Xml)
Set Comando = Nothing
End Function
The component is a dll that runs thru com+
There are other options for serialization you could look at:
Plain old HTTP - just encode information in the headers and body. You'll need to use a HTTPClient from ASP for this though.
JSON - look at http://www.webdevbros.net/2007/04/26/generate-json-from-asp-datatypes/ for generating JSON from ASP datatypes
On the Java side just use a Servlet, you can embed this in something like Jetty or Tomcat. There's a very simple example here:
http://docs.codehaus.org/display/JETTY/Embedding+Jetty
you can write socket server on Java which will receive data from aSP.NET pages, ASP.NET will open socket and sent information this is in case you want to avoid HTTP, but I agree with Jon, sending JSON by HTTP using POST command and de-serialize this JSON using Google GSON library is much simpler approach.