Mantis - Hessian
Viewing Issue Advanced Details
3341 major always 02-13-09 11:45 03-01-09 13:47
everflux  
 
normal  
new 3.2.1  
open  
none    
none  
0003341: hessian 3.2.1 does not work with phphessian while hessian 3.1.6 does
Using phphessian to create a hessian service in php and calling from java (groovy) it does not work using hessian-3.2.1.jar
If using hessian-3.1.6.jar the very same application works.
using phphessian this is the sample service
<?php

include_once 'HessianPHP/dist/HessianService.php';
$wrapper = &new HessianService();
//enable method browsing with http get
$wrapper->setDisplayInfo(true);
$wrapper->registerObject(new Demo());
$wrapper->service();


class Demo
{
  function run($n1,$n2) {
      $result = "";
      $result .= "hello $n1 $n2";
      return $result;
  }

  function arrayResult($n1, $n2)
  {
      $result = array();
      $result[0] = $n1;
      $result[1] = strlen($n1);
      $result[2] = $n2;
      $result[3] = strlen($n1);

      return $result;
  }

  function objectResult($n1, $n2)
  {
      $result;
      $result->nameOne = $n1;
      $result->nameTwo = $n2;

      return $result;
  }

}

?>

this is the call in groovy
import com.caucho.hessian.client.HessianProxyFactory;

def n1='tkruse'
def n2='muenster'

url ="http://localhost/~tkruse/hessianRules/server.php" [^]

HessianProxyFactory factory = new HessianProxyFactory();
//factory.setDebug(true);
factory.setChunkedPost(false);
service = factory.create(DemoInterface.class, url);


println (service.run(n1, n2))

service.arrayResult(n1, n2).each{println "entry: " + it}


When having the debug mode on, it looks like there is something swallowing the first byte containing "r", so hessian does not recognize the response correctly:

Exception in thread "main" com.caucho.hessian.client.HessianRuntimeException: com.caucho.hessian.io.HessianProtocolException: expected hessian reply at 0x1 ()
at com.caucho.hessian.client.HessianProxy.invoke(HessianProxy.java:258)
        at $Proxy0.run(Unknown Source)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

Having a look on a tcpdump everything looks correctly. Since changeing just the hessian jar solves this issue there seems something changed between them.

Notes
(0003852)
Peter Dettman   
02-27-09 03:56   
I believe the problem here is that the client is (implicitly) asking for a Hessian 2.0 reply, and the 2.0 implementation is still 'evolving' (still a draft spec?).

Try calling factory.setHessian2Reply(false).
(0003854)
everflux   
03-01-09 13:47   
I think your hint got me into the right direction, but I still believe it's not the PHP server, but the java client implementation.
I tried hessian 3.2.0, that works too.
Looking through the sources is confusing, the hessian proxy factory can return a hessianInput, hessian1Input and hessian2Input - but in fact getHessianInput and getHessian2Input both return a Hessian2Input. (The getHessian1Input method seems to be never called, too)
I believe starting a reply with "H" signals to use Hessian 2 protocol, while "r" should indicate a standard Hessian (1) reply.
I could not figure out what happens exactly, I think it is about reading a byte too much (or too less) from the input stream.
If I change the HessianProxy line 239 to read
in = _factory.getHessian1Input(is);
I get a different error, too:
Caused by: com.caucho.hessian.io.HessianProtocolException: expected string at 0x0
instead of the
Caused by: com.caucho.hessian.io.HessianProtocolException: expected hessian reply at 0x1