Java - PHP communication

Hi,
I'm quite new to EJB3 and going to build web application using (probably) EJB3 and Struts 2. My problem is, that I need to bound some parts of my new business logic with this older PHP website. I just need to call some simple Java methods (e.g. searching in db - pass on one or two parameters and get a result) from this PHP website. I've done some research and it looks like I should use Web services. There is a lot of materials for this topic in the web, but somewhere I've read, that web services are overkill for such the simple scenario. Is here any easier way to call Java business logic from PHP. Thank you very much for your answer.
Edited by: esembaJ on 13.10.2008 22:53

As I understood, your "application" consists of two parts: web site written on php and EJB+Struts.
If so, you can easily make HTTP requests from php to your Struts actions.
Your actions can make response in JSON (JavaScript Object Notation) with the help of json-plugin.
With these approach you beat two things: you can make actions which can be easily used asynchronously (JSON helps to do this) also they can be used by any application that can parse JSON response.
You don't need to dig into WS. Your case is very simple because of powerful java web-framework. WS will make your solution too complicated. Also you'll have troubles with WS on php-side.
Once, I've had to send some data to java-WS from php4. I've tried to realize it in many ways, but finally I've made simple HTTP request with manually formed XML-body (it was SOAP).

Similar Messages

  • Problem download: Java serial communication

    Hi,
    I need to work with Java serial communication api for Windows.
    As mentioned on SUN site, downloaded the following:
    1) comm2.0.3.zip, &
    2) rxtx-2.0-7pre1-i386-pc-mingw32.zip
    Extracting, unable to see win32com.dll & javax.comm.properties
    Can you help me?
    Thanks,
    Priya

    Hi priya
    There is problem in your downloaded s/w
    Download commAPI once again then try
    Read the readme file and follow the instruction

  • Problems uninstalling Forte for java 4 community edition

    I just installed Forte for java 4 community edition at work, and when i tried to uninstalled it with add/remove programs from control panel. And the uninstall wizard start but then a Sun window apper and it is written, uninstalling and the uninstall program seems to be frozen.

    i have the same problem, reading the documentation it seems you got to run the installer again and you ll get prompted with the "file deletion confirmation"
    too bad i have a self-installing package and i don't get the prompt...
    guesses anyone?

  • Java System Communications Express attachment problem

    Hello everyone, please excuse my ignorance on this query as I have very little to do with the Java language and I've really approached this forum as I've run out of ideas for the problem my customer has.
    The customer is connecting to a 'Sun Java System Communications Express' server, from approximately 20 PC's. 2 of the PC's have a problem that is not user based because if they sign in elsewhere their problem disappears and likewise if someone signs into their PC, they experience the same problem.
    If the user receives an email with an attachment and forwards it to a recipient, no problem.
    If the user recieves an emal with an attachment and forwards it to themselves, no problem.
    If however, the user tries to send an email with an attachment (which for all intents and purposes seems to take the correct amount of time to upload, and when you click save appears in the message attached) the attachment disappears, including if you simply save the message in drafts and do not actually send it.
    I have tried uninstalling and reinstalling versions 5 and 6 of Java, resetting the web settings using both IE6 and IE7 (unfortunately the initial secure server refuses any other connections from Firefox / Netscape / Opera / Safari therefore I can only test with IE)
    I have disabled all additional addons, disabled all non-microsoft startup services, disabled all startup programs.
    As you will appreciate, I've done a fair and reasonable amount of testing and simply cannot work out why the attachment fails to stay with the email on these two machines. Help on this problem would be very much greatly appreciated.
    Many Thanks
    Tony

    Unfortunately I do not have access to version information of the server as I am only have access to the client end. All that I can provide you with is the fact that it works on 18 identical systems. The missing attachment(s) occur regardless of whether you save the message to draft or send the message. It should be noted however that if you receive an attachment with a message and save that to drafts, the message retains the attachment so it only seems as though it is affected during the phase of attaching the file to the message from the local PC. The environment that the client is working in uses a verified certificate and is connected through https.

  • Sun Java System Communications Express 6

    Does anyone have information about Sun Java System Communications Express?
    Has it been released? What are your opinions, etc?
    Thanks,
    GB

    i started with schema 2
    so installed directory identity - verified them
    ran instalelr again and instaleld messagign , calendar - tested them
    then installed communicatiosn express and configured as per setup docs - configured them for identity sso not messaging sso
    l8r

  • Java+php+linuxruntime  error

    Dear all i have one java class i amm using php pages to to use this class
    currently i am getting below error
    Fatal error: Uncaught exception 'java_RuntimeException' with message 'Could
    not connect to the context server . Error message: Connection refused (111)
    ' in /usr/local/apache2/htdocs/java/Java.inc:1163 Stack trace: #0
    /usr/local/apache2/htdocs/java/Java.inc(1180):
    java_Protocol->createSimpleHandler('@java-bridge-10...') #1
    /usr/local/apache2/htdocs/java/Java.inc(1187):
    java_Protocol->createHandler() #2
    /usr/local/apache2/htdocs/java/Java.inc(365):
    java_Protocol->java_Protocol(Object(java_Client)) #3
    /usr/local/apache2/htdocs/java/Java.inc(1541): java_Client->java_Client() #4
    /usr/local/apache2/htdocs/java/Java.inc(1650):
    __javaproxy_Client_getClient() #5
    /usr/local/apache2/htdocs/java/Java.inc(1665): java_session_array(Array) #6
    /usr/local/apache2/htdocs/java.php(3): java_session() #7 {main} thrown in
    /usr/local/apache2/htdocs/java/Java.inc on line 1163

    "Connection refused"
    I think it is safe to assume your network settings are wrong and it actually has nothing to do with java. Firewall problem perhaps?

  • Java/php bridge

    Hi All,
    i am working on jdeveloper10.1.3 & OracleApps Server.
    suggests some possible ways to bridge Java/PHP?
    I am facing problem integrating with jsp page and php page . if any one know its great help me.
    What are the software’s required for bridge between java and php.
    Request is so needful.
    thq,
    elisha.

    Judging by your later response, I'd say Gene got it right first time in that it is a memory issue.
    It looks like your application needs more than 512m heap size. I guess there isn't enough on the box where WebLogic is installed, otherwise you would have used the same sizes as TomCat.
    Apologies if I'm stating the obvious

  • What are the pre-requisite for JAVA Proxy communication?

    What are the pre-requisite for JAVA Proxy communication?

    Hi,
    You can install the Java proxy runtime on the SAP J2EE Engine Release 6.40 SP5 or higher.
    The messaging system that the Java proxy runtime uses to send messages to the Integration Server must also be installed on the J2EE server.
    To send messages from a J2EE application, the application must be programmed against beans that encapsulate all details about the Java runtime. The following classes are generated:
    ·        Proxy classes that send or receive messages using the Java proxy runtime.
    ·        Bean classes as an outer shell that conform to the J2EE standard. The beans call the proxy classes for communication.
    The classes must be deployed on the J2EE server together with their J2EE application
    see this link for the example scenario http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/f272165e-0401-0010-b4a1-e7eb8903501d

  • Use of synchronized queue for java socket communications

    Hi all,
    We have a need for a server socket application (stand alone java application) to process just one command per time coming from a java socket client (JSP Web application). There are a lot of users accessing the java socket client, but the server socket can only handle one command per time, so there is a need of a queue type, so users will have to wait for their time.
    We've been told that we can use "synchronized Queue", but we don't know what it is and how to use. A URL, book etc. with sample code would assist us, since we are new to both java socket communication and queue of commands.
    Can anyone assist us
    cheers
    Trajano
    P.S.
    The server socket java application has two threads:
    1st thread handles the java socket communication;
    2nd thread is a RS-232 serial driver that communicates to several micro-controllers connected on a multi-drop.
    JSP web app client socket users can issue various commands at the same time to the java server socket app, however the server can only service one command per time (just one RS-232 COM1 serial port available). The commands have to somehow be added to a queue for processing.

    I do not have the experience to offer advice. But I just happened to be reading today about Collections.synchronizedList.
    import java.util.List;
    import java.util.LinkedList;
    import java.util.Collections;
    public class Queue {
       private List queue;
       public Queue() {
          queue = Collections.synchronizedList(new LinkedList());
       public Object removeItem() throws InterruptedException {
          synchronized (queue) {
             while (queue.isEmpty())
                queue.wait();
             return queue.remove(0);
       public void addItem(Object item) {
          synchronized (queue) {
             queue.add(item);
             queue.notifyAll();
    class Test {
       public static void main(String[] args) {
          final Queue queue = new Queue();
          //start a thread to process items from the queue
          Runnable work = new Runnable() {
             public void run() {
                try {
                   Object item = queue.removeItem();
                   //do something with item
                } catch (InterruptedException e) {
                   //handle this
          Thread worker = new Thread(work);
          worker.start();
    }Reference: Java Thread Programming, Paule Hyde
    Also, here is Doug Lea's library,
    http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html

  • About Java(tm) Communications API

    Hi all,
    I am customizing some project, using Java(tm) Communications API.
    I've find it is not include of J2SE core module, and had some incompatibility issue.
    I am wondering if there are other package I could use in replace of this particular API?
    Thx,
    James

    Hi all,
    I am customizing some project, using Java(tm) Communications API.
    I've find it is not include of J2SE core module, and had some incompatibility issue.
    I am wondering if there are other package I could use in replace of this particular API?
    Thx,
    James

  • Java - php / passing parameters

    hi,
    i am trying to set up a communication between my java app and a php skrip. i've done the following:
    try {
    URL url =
    new URL("http://test.net/" +
    "login.php");
    URLConnection connection =
    url.openConnection();
    connection.setDoOutput(true);
    PrintStream out =
    new PrintStream(connection.getOutputStream());
    out.println("username=" + URLEncoder.encode("test"));
    out.println("password=" + URLEncoder.encode("9e07480f0e4952926e115f15bc50ec47"));
    out.close();
    DataInputStream in =
    new DataInputStream(connection.getInputStream());
    result = in.readLine();
    System.out.println("result:" + result.toString());
    in.close();
    } catch(MalformedURLException mue) {
    System.out.println("Illegal URL: " + mue);
    } catch(IOException ioe) {
    System.out.println("IOException: " + ioe);
    } catch(Exception e) {
    System.out.println("Error: " + e);
    the php gets my request but it doesn't realize the parameters username/passord.
    is there a way to set the parameters through the api or do is the only way to do it by adding them to the url like ?username=bla&password=bla. i really would like to do it on a higher level but maybe there is no api support available. thanx for any advice, mischka.

    Golden rule of testing: test one thing at a time.
    Try it with this (working code) to test that you know that you CAN write a simple *.txt message file from a TextField first before extending it to verification /password whatever conditions.import java.net.*;
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    public class write extends java.applet.Applet implements ActionListener {  
        TextArea info = new TextArea(10,60);
         Button Bsend = new Button("SEND");
         String str = "", text="";
         public void init() {
              add(info);
              Bsend.addActionListener(this);
              add(Bsend); 
         public void paint (Graphics g) {
              g.drawString(str, 30, 270);
         public void actionPerformed(ActionEvent evt) {
                if (evt.getSource().equals(Bsend) ) {
                try{
                    writePage();
                   catch(Exception x){ System.out.print(x); }
              repaint();
        public void writePage() throws Exception {  
            text = info.getText();     
             URL url = new URL("http://"+getCodeBase().getHost()+"login.php");
                URLConnection conn = url.openConnection();
                conn.setDoOutput(true);
                OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
                wr.write(text);
                wr.flush();
            wr.close();
            str = "Information sent to " + getCodeBase().getHost().toString();
    }

  • Java JDBC Communication Link Failure

    Hi,
    I have a Java application which utilizes the JDBC mysql connector 5.1.6. It works great, and I am able to connect to my MySQL database just fine and execute queries perfectly.
    However, it seems that if my server idles for certain periods of time without issuing a command to the MySQL server (and this idle period seems to be variant; sometimes if it sites just 5 minutes I get this error, other times it has to idle for close to 25 minutes before it gives me this error):
    com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
    Last packet sent to the server was 1493610 ms ago.Obviously the "... ms ago" part varies based on how long the server was idling.
    This is a particular problem for me because the purpose of my application is to be one part in more of an enterprise information system. So this connection to the database is intended to make an update every 25 minutes to update a user's session data in my database. Unfortunately, when idling for this long it will just error out.
    My temporary solution has been to catch this exception, reconnect, and re-issue the query which is working, but that's like putting a band-aid on a wound that needs stitches. The real problem is I have so many areas in my code where I execute commands that it would make it difficult to maintain if I had to use this Try-Catch method of reconnecting in each spot.
    Is there some timeout setting I need to set in MySQL or in the JDBC to stopt his error from happening? I have read the MySQL documentation and its timeout is already set to an hour so that shouldn't be the problem...
    Thanks!

    I searched for this on google:
    com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications
    and here is a link that might help:
    http://forums.mysql.com/read.php?39,199085,204628#msg-204628
    I think the key to your problem is the last line in that link. In connection pooling, you should get a connection, use it, then close it as quickly as possible (ideally, all in the same function within try/catch/finally block) for each time you need to use a connection (hundreds of times within your application). I suspect you open a connection and keep it open with the anticipation that there is a performance penalty in alternatively opening and closing it hundreds of times. There is none. The act of getting and closing a connection from a connection pool is a lightweight operation (in terms of performance). I suggest going back and refactoring your code with the above in mind. That way, your connections will never time out (they are only open for a few milliseconds at a time).

  • I need some advices on Java-Delphi communication

    Hi all!
    I am a student of Electronic Engineering at University of Brescia.
    I am developing a dissertation on OPC Servers (who use DCOM for communicating).
    I have to develop an OPC Server that must manage some sensors. To communicate with this sensors I have already Java code written from others. Thus I thought to write my OPC server in Java, but it appears not so simply... right?!? So I think to develop my OPC server in Delphi (I found some sources to help me) and then build an interface to the sensors in Java. But now I don't know how the program in Delphi and that one in Java can communicate.
    Unfortunately I'm not an expert programmer of Delphi and Java, (but I'm improving...) so I don't know if this thing is possible/impossible (I think possible) and hard/simple (I hope simple!!).
    Do you have any suggestion?
    As usual, I would be very grateful if you could provide me with these information or if you could suggest where I can find them.
    You can also reply me at [email protected]
    Regards
    Stefano Arrighini

    Stefano,
    the following is a URL to a tutorial on accessing COM via Java. It may be a useful starting place for you.
    http://www.developer.com/java/article.php/770221
    Have you thought about using TCP/IP sockets for communication between the client and server? Java makes this very easy.
    Ian

  • Issue with Java - PHP interoperability

    Hi,
    There are some converts written in PHP that can take raw wikipedia data and output a good HTML. I wanted to make use of these in my Java code.
    So in my Java Web App, I wanted to run the PHP parser, get hold of the InputStream and push it to my ServletOutputStream.
    Code Snippet:
       String command="php testparser.php Anarchism.wikimarkup";
       proc = Runtime.getRuntime().exec(command);
       InputStream in = proc.getInputStream();
       InputStreamReader isr = new InputStreamReader(in);
       BufferedReader br = new BufferedReader(isr);
       String line = null;
       while ((line = br.readLine()) != null) {
         System.out.println(line);
       }But the problem here is that the PHP Process never stops and hence the Buffer never ends. THe program is waiting in infinite loop in readLine().
    Please let me know if anyone has tried this and whats a better way to handle interoperability between PHP and Java.
    Thanks,
    Phani

    Phanikumar_Bhamidipati wrote:
    Yeah, I had a look at the document. But as per my understanding, the way the PHP engine runs is different from normal execs. I don't see how it can 'run different' and in my experience it doesn't. PHP sends output to stdout and stderr and reads from stdin. When PHP terminates it will close stdout and stderr and, if you have followed the recommendations in the reference, your readLine() will return 'null'.
    Because the same code ran fine when I automated unzipping a set of files using "bunzip2" command.If you read the article it explains a possible reason for this BUT until you implement the recommendations you will not know what is wrong.
    >
    I tried using Process.waitFor() method as well, but the result is same (Infinite Loop).This almost certainly is nothing to do with Process.waitFor() and probably everything to do with buffers filling (probably stderr).
    Until you post the code with the recommendations implemented that exhibits the same blocking problem it is a waste of time anyone responding further.

  • Out of memory error in java- flex communication using RTMP

    We are using flex and java in our application. due to RTMP call to fetch data every 5 seconds. it is hiting database and establishing connection and keeps it open hence this is causing for Out of memory issue. Can come one help on this issue.

    You probably want to ask here: http://forums.adobe.com/community/flex

Maybe you are looking for

  • ATP Tree Structure is not getting created automatically after Sales Order is saved

    In one one of our scenario, when we add material to Sales Order and save with Requirement Type(under Procurrement Tab of Sales Order) , in APO there is no planned order or only planned order which is dynamically pegged created because the ATP Tree in

  • Error 10698 Virtual machine could not be live migrated to virtual machine host

    Hi all, I am running a fail over cluster of Host: 2 x WS2008 R2 Data Centre managed by VMM: VMM 2008 R2 Virtual Host: 1x windows 2003 64bit guest host/virtual machine I have attempted a live migration through VMM 2008 R2 and im presented withe the fo

  • Audio Sync

    Is it possible to hear audio playing through speakers hooked up to built-in audio that is in synch with video playing through firewire on a NTSC monitor? The only way I seem to be able to get audio to sync with the monitor is to use the monitors spea

  • AUR won't accept PKGBUILD with numbers in the Package Name

    Trying to submit a PKGBUILD called: gstreamer0.10-pitfdll-cvs I am getting an error "Invalid name: only lowercase letters are allowed." Does this mean that numbers are not allowed in the package names in AUR? The error goes away once I remove the num

  • DW template problems

    I'm seriously not sure what to do here. Murray/Ace if you see this, I am starting this thread fresh, as I have encountered new problems. I have a template that works seemingly fine in all respects, uploaded it to temporary site: http://www.newton-des