EDIT: I should make it clear that PHP is the main language to be used, there will be no ASP.
Instead of starting a new thread I thought I should continue here.
I got sidetracked off the technical part of this project with a lot of paperwork for a few months, but I have recently been looking into this again.
What was first said in this thread about hibernate and REST makes some sense now.
I have my webserver (linux) setup, along with Tomcat, Apache HTTP server, mod_proxy, PHP, Java, openEJB (EJB for tomcat) and MySQL.
I have been implementing this system for a while, and trying to get my head around all the technical parts.
For testing, I have setup a JNDI connection (using MySQL connector / J) to a MySQL database using JSP - which works fine. My problem now comes in trying to connect PHP to the MySQL DB via JNDI. This is where the PHP-Java Bridge originally came into things - it would allow PHP to access JNDI. However, like "willcodeforbeer" said, it may be better to use a different approach.
What I have been looking at is similar to the method which mentioned hibernate and REST. What I have learnt (I think) is that PHP can access EJBs within Tomcat using SOAP (via WSDL). So if I could create an EJB that contained the config for the connection to my database (JNDI), I could then call that using PHP and SOAP and use MySQL within PHP to carry out the queries.
I have been having trouble getting this to work though.
I have been talking to the technical guys who created openEJB, and we agreed that it would be best to try and access a simple EJB web service using PHP, and then move onto the database stuff later. They said that openEJB uses Apache CXF and so I dont need Apache SOAP installed - just the PHP SOAP extension or NuSOAP. They have given me a simple Calculator web service which is deployed into Tomcat as an EJB:
Code:
package org.superbiz.ws; import javax.ejb.Stateless; import javax.jws.WebService; @Stateless @WebService(portName = "CalculatorPort", serviceName = "CalculatorWebService", targetNamespace = "http://superbiz.org/wsdl") public class Calculator { public int sum(int add1, int add2) { return add1 + add2; } public int multiply(int mul1, int mul2) { return mul1 * mul2; } }
This is compiled into the Calculator.class and can be accessed from
www.mysite.com:8080/Calculator.
The WSDL file can be accessed through:
www.mysite.com:8080/Calculator?wsdl
Now my question is: can I access this web service using php and WSDL? I have been reading up and I've seen that PHP can do apparently do this. So far, I have this code:
PHP Code:
<?php
$client = new SoapClient("http://www.mysite.com/Calculator?wsdl");
var_dump($client->__getTypes());
?>
The code gives this output:
array(4) { [0]=> string(41) "struct multiply { int arg0; int arg1; }" [1]=> string(40) "struct multiplyResponse { int return; }" [2]=> string(36) "struct sum { int arg0; int arg1; }" [3]=> string(35) "struct sumResponse { int return; }" }
I guess that this shows that I can call the web service as WSDL from PHP - doesn't it? So in theory I should be able to call a DB connection set up as a web service in Java?
Is this the most appropriate way to work towards getting a connection to the DB established? Or would people recommend the method mentioned which uses hibernate and REST, or anything else?
Any help would be fantastic.
regards
Jp