3

Which is the overall best option for calling Java from PHP?

or something else entirely? By "best" I mean easy to use, reliable, transparent (for debugging purposes) - the whole enchilada.

To put it the other way, does either solution have any major shortcomings?

Edit: the reason for this is a PHP site which needs to use a 3rd party SOAP service. The type hierarchy defined in the WSDL appears to be too complex for any pure PHP client.

Rob Agar
  • 12,337
  • 5
  • 48
  • 63

2 Answers2

3

The PHP/Java bridge is functional, but we found that it tended to leave around zombie JVM processes as Apache children that have to be kill -9'd to get rid of. We ended up running a cron job daily to take care of the problem. We only used it for one specific class (an interface class to someone's horrid SOAP endpoint), and it was a tad bit finicky when it came to type juggling, but it did work for us. (The zombie process problem may have been due to the prehistoric PHP version we were using at the time, so it may have been fixed by now.)

I don't have any experience with Gearman and Java, but plenty of it with PHP. It's been a pleasure to work with, for the most part. The most annoying issue is that processing async updates from the caller requires some pretty verbose code to handle all of the possible states. For fire-and-forget and fire-and-get-back-immediate-results RPC, though, it's really hard to beat.

Charles
  • 50,943
  • 13
  • 104
  • 142
  • cheers - we've got the exact same problem, a troublesome SOAP service – Rob Agar Mar 23 '11 at 05:15
  • I don't think there's a non-troublesome one. The vendor was providing sales tax services and were *very* hesitant to recommend anything but the Java client due to interop issues. – Charles Mar 23 '11 at 05:22
3

Gearman is probably not really the solution you are after (unless you really want a job queue rather than some form of RPC). It can operate in a blocking/synchronous fashion but it brings alot of overhead (code/application/etc wise) to the party for what i'm guessing is a simple task?

Without knowing what you are trying to do i'm going to throw some suggestion out there. XML-RPC (can be slightly less evil than SOAP!) or maybe something like Facebook's Thrift[1], Apache Avro[2], or Google Protocol Buffers[3]?

[1] http://incubator.apache.org/thrift/

[2] http://avro.apache.org/

[3] http://code.google.com/apis/protocolbuffers/

James Butler
  • 3,852
  • 1
  • 26
  • 38
  • thanks - I've edited the question to describe why we need this, but I'll look into those suggestions – Rob Agar Mar 28 '11 at 03:21
  • Ah-ha, i see the problem... I presume you've tried all the SOAP libs for PHP like Zend_Soap [http://framework.zend.com/manual/en/zend.soap.html] and NuSoap [http://sourceforge.net/projects/nusoap/]? Are the calls your making going to be (or need to be) blocking? (Sorry for so many questions) – James Butler Mar 28 '11 at 09:21