php 通过hessian 和 java通信 序列化的php对象不能被java解析 我用java序列化的对象是可以正常解析。
能告诉我php的序列化的对象和java序列化的对象有什么区别。还有怎么序列化php才能像java序列化的那样被解析。谢谢我在线等<?php
header("Content-Type: text/html; charset=gbk3212");
/*
* v1.0 by jetsum tonydon
* netbeansIDE 7.0
*/
include_once '../hessianPhp/Hessian.php';
include_once '../hessianPhp/HessianClient.php';
Hessian :: mapRemoteType('com.hisupplier.showroom.webservice.QueryParams', 'QueryParams');
Hessian :: mapRemoteType('com.hisupplier.showroom.webservice.ListResult', 'ListResult');
Hessian :: mapRemoteType('com.hisupplier.showroom.entity.Product', 'Product');
Hessian :: mapRemoteType('com.hisupplier.commons.page.Page', 'Page');
#
//include_once '../hessianPhp/HessianClient.php'; $testUrl = "http://192.168.0.51:8080/mam/interface/appInterface";
echo($testUrl."<br/>");
$hessianClient = new HessianClient($testUrl);
//echo("aaaaaaaa");
//$name = empty($_GET['name'])?'name is Null.':$_GET['name'];
$page = serialize(new Page());
print_r($page);
//echo("<br/> PHP Invoked Java Web Service [IBaseService-getGid(String value)]:<br/> ".$hessianClient->searchGame("","",$page));
//print_r($page.pageNo);
//try{
// print_r($hessianClient ->findById("123213"));
print_r($hessianClient ->searchGame("","",$page));
// }catch(Exception $e){
// echo $e->getMessage();
// } class Page {
// 公共变量 /**
*
*/
public static $serialVersionUID = 1;
public static $ASC = "asc";
public static $DESC = "desc";
public static $MIN_PAGESIZE = 1;
public static $MAX_PAGESIZE = 200; // 分页参数
protected $pageNo = 1;
protected $pageSize = 10;
protected $orderBy = null;
protected $order = ASC;
protected $autoCount = true;
protected $totalCount = -1; // 构造函数
function __construct(){
//super();
} // 查询参数函数 /**
* 获得当前页的页号,序号从1开始,默认为1.
*/
function getPageNo() {
return $this->pageNo;
//return pageNo;
} /**
* 设置当前页的页号,序号从1开始,低于1时自动调整为1.
*/
function setPageNo($pageNo) {
$this->pageNo = $pageNo; if ($this->pageNo < 1) {
$this->pageNo = 1;
}
} /**
* 获得每页的记录数量,默认为10.
*/
function getPageSize() {
return $this->getPageSize();
} /**
* 设置每页的记录数量,超出MIN_PAGESIZE与MAX_PAGESIZE范围时会自动调整.
*/
function setPageSize($pageSize) {
$this->pageSize = $pageSize; if ($this->pageSize == -1) {
return;
} if ($this->pageSize < $this->MAX_PAGESIZE) {
$this->pageSize = $this->MIN_PAGESIZE;
} else if ($this->pageSize > $this->MAX_PAGESIZE) {
$this->pageSize = $this->MAX_PAGESIZE;
}
} /**
* 根据pageNo和pageSize计算当前页第一条记录在总结果集中的位置,序号从0开始.
*/
function getFirst() {
return (($this->pageNo - 1) * $this->pageSize);
} /**
* 获得排序字段,无默认值.多个排序字段时用','分隔,仅在Criterion查询时有效.
*/
function getOrderBy() {
return $this->orderBy;
} /**
* 设置排序字段.多个排序字段时用','分隔.仅在Criterion查询时有效.
*/
function setOrderBy($orderBy) {
$this->orderBy = $orderBy;
} /**
* 是否已设置排序字段,仅在Criterion查询时有效.
*/
function isOrderBySetted() {
return StringUtils.isNotBlank($this->orderBy);
} /**
* 获得排序方向,默认为asc,仅在Criterion查询时有效.
*/
function getOrder() {
return $this->order;
}
/**
* 就
* 取得分页参数的组合字符串. 将多个分页参数组合成一个字符串方便在页面上的传递,格式为pageNo|orderBy|order.
*/
function getPageRequest() {
return $this->getPageNo() + "|" + StringUtils.defaultString($this->getOrderBy()) + "|" + $this->getOrder();
} /**
* 设置分页参数的组合字符串. 将多个分页参数组合成一个字符串方便在页面上的传递,格式为pageNo|orderBy|order.
*/
function setPageRequest($pageRequest) { if (StringUtils.isBlank($this->getPageRequest())) {
return;
} $params[] = StringUtils.splitPreserveAllTokens($this->getPageRequest(), '|'); if (StringUtils.isNumeric($params[0])) {
$this->setPageNo(Integer.valueOf($params[0]));
} if (StringUtils.isNotBlank($params[1])) {
$this->setOrderBy($params[1]);
} if (StringUtils.isNotBlank($params[2])) {
$this->setOrder($params[2]);
}
} /**
* 查询对象时是否自动另外执行count查询获取总记录数,默认为false,仅在Criterion查询时有效.
*/
function isAutoCount() {
return $this->autoCount;
} /**
* 查询对象时是否自动另外执行count查询获取总记录数,仅在Criterion查询时有效.
*/
function setAutoCount($autoCount) {
$this->autoCount = $autoCount;
} /**
* 取得总记录数,默认值为-1.
*/
function getTotalCount() {
return $this->totalCount;
} function setTotalCount($totalCount) {
$this->totalCount = $totalCount;
} /**
* 根据pageSize与totalCount计算总页数,默认值为-1.
*/
function getTotalPages() {
if ($this->totalCount < 0) {
return -1;
} $count = $this->totalCount / $this->pageSize;
if ($this->totalCount % $this->pageSize > 0) {
$count++;
}
return $count;
} /**
* 是否还有下一页.
*/
function isHasNext() {
return ($this->pageNo + 1 <= $this->getTotalPages());
} /**
* 取得下页的页号,序号从1开始.
*/
function getNextPage() {
if (isHasNext()) {
return $this->pageNo + 1;
} else {
return $this->pageNo;
}
} /**
* 是否还有上一页.
*/
function isHasPre() {
return ($this->pageNo - 1 >= 1);
} /**
* 取得上页的页号,序号从1开始.
*/
function getPrePage() {
if ($this->isHasPre()) {
return $this->pageNo - 1;
} else {
return $this->pageNo;
}
} /**
* 取得反转的排序方向. 如果有以','分隔的多个排序方向,逐一进行反转.
*/
function getInverseOrder() {
$orders[] = StringUtils.split($this->order, ','); for ($i = 0; i < $this->order.length; $i++) {
if ($this->DESC.equals($orders[i])) {
$orders[i] = $this->ASC;
} else {
$orders[i] = $this->DESC;
}
}
return StringUtils.join($orders);
} function isPageSetted() {
return $this->pageSize != -1;
}
}
?>
能告诉我php的序列化的对象和java序列化的对象有什么区别。还有怎么序列化php才能像java序列化的那样被解析。谢谢我在线等<?php
header("Content-Type: text/html; charset=gbk3212");
/*
* v1.0 by jetsum tonydon
* netbeansIDE 7.0
*/
include_once '../hessianPhp/Hessian.php';
include_once '../hessianPhp/HessianClient.php';
Hessian :: mapRemoteType('com.hisupplier.showroom.webservice.QueryParams', 'QueryParams');
Hessian :: mapRemoteType('com.hisupplier.showroom.webservice.ListResult', 'ListResult');
Hessian :: mapRemoteType('com.hisupplier.showroom.entity.Product', 'Product');
Hessian :: mapRemoteType('com.hisupplier.commons.page.Page', 'Page');
#
//include_once '../hessianPhp/HessianClient.php'; $testUrl = "http://192.168.0.51:8080/mam/interface/appInterface";
echo($testUrl."<br/>");
$hessianClient = new HessianClient($testUrl);
//echo("aaaaaaaa");
//$name = empty($_GET['name'])?'name is Null.':$_GET['name'];
$page = serialize(new Page());
print_r($page);
//echo("<br/> PHP Invoked Java Web Service [IBaseService-getGid(String value)]:<br/> ".$hessianClient->searchGame("","",$page));
//print_r($page.pageNo);
//try{
// print_r($hessianClient ->findById("123213"));
print_r($hessianClient ->searchGame("","",$page));
// }catch(Exception $e){
// echo $e->getMessage();
// } class Page {
// 公共变量 /**
*
*/
public static $serialVersionUID = 1;
public static $ASC = "asc";
public static $DESC = "desc";
public static $MIN_PAGESIZE = 1;
public static $MAX_PAGESIZE = 200; // 分页参数
protected $pageNo = 1;
protected $pageSize = 10;
protected $orderBy = null;
protected $order = ASC;
protected $autoCount = true;
protected $totalCount = -1; // 构造函数
function __construct(){
//super();
} // 查询参数函数 /**
* 获得当前页的页号,序号从1开始,默认为1.
*/
function getPageNo() {
return $this->pageNo;
//return pageNo;
} /**
* 设置当前页的页号,序号从1开始,低于1时自动调整为1.
*/
function setPageNo($pageNo) {
$this->pageNo = $pageNo; if ($this->pageNo < 1) {
$this->pageNo = 1;
}
} /**
* 获得每页的记录数量,默认为10.
*/
function getPageSize() {
return $this->getPageSize();
} /**
* 设置每页的记录数量,超出MIN_PAGESIZE与MAX_PAGESIZE范围时会自动调整.
*/
function setPageSize($pageSize) {
$this->pageSize = $pageSize; if ($this->pageSize == -1) {
return;
} if ($this->pageSize < $this->MAX_PAGESIZE) {
$this->pageSize = $this->MIN_PAGESIZE;
} else if ($this->pageSize > $this->MAX_PAGESIZE) {
$this->pageSize = $this->MAX_PAGESIZE;
}
} /**
* 根据pageNo和pageSize计算当前页第一条记录在总结果集中的位置,序号从0开始.
*/
function getFirst() {
return (($this->pageNo - 1) * $this->pageSize);
} /**
* 获得排序字段,无默认值.多个排序字段时用','分隔,仅在Criterion查询时有效.
*/
function getOrderBy() {
return $this->orderBy;
} /**
* 设置排序字段.多个排序字段时用','分隔.仅在Criterion查询时有效.
*/
function setOrderBy($orderBy) {
$this->orderBy = $orderBy;
} /**
* 是否已设置排序字段,仅在Criterion查询时有效.
*/
function isOrderBySetted() {
return StringUtils.isNotBlank($this->orderBy);
} /**
* 获得排序方向,默认为asc,仅在Criterion查询时有效.
*/
function getOrder() {
return $this->order;
}
/**
* 就
* 取得分页参数的组合字符串. 将多个分页参数组合成一个字符串方便在页面上的传递,格式为pageNo|orderBy|order.
*/
function getPageRequest() {
return $this->getPageNo() + "|" + StringUtils.defaultString($this->getOrderBy()) + "|" + $this->getOrder();
} /**
* 设置分页参数的组合字符串. 将多个分页参数组合成一个字符串方便在页面上的传递,格式为pageNo|orderBy|order.
*/
function setPageRequest($pageRequest) { if (StringUtils.isBlank($this->getPageRequest())) {
return;
} $params[] = StringUtils.splitPreserveAllTokens($this->getPageRequest(), '|'); if (StringUtils.isNumeric($params[0])) {
$this->setPageNo(Integer.valueOf($params[0]));
} if (StringUtils.isNotBlank($params[1])) {
$this->setOrderBy($params[1]);
} if (StringUtils.isNotBlank($params[2])) {
$this->setOrder($params[2]);
}
} /**
* 查询对象时是否自动另外执行count查询获取总记录数,默认为false,仅在Criterion查询时有效.
*/
function isAutoCount() {
return $this->autoCount;
} /**
* 查询对象时是否自动另外执行count查询获取总记录数,仅在Criterion查询时有效.
*/
function setAutoCount($autoCount) {
$this->autoCount = $autoCount;
} /**
* 取得总记录数,默认值为-1.
*/
function getTotalCount() {
return $this->totalCount;
} function setTotalCount($totalCount) {
$this->totalCount = $totalCount;
} /**
* 根据pageSize与totalCount计算总页数,默认值为-1.
*/
function getTotalPages() {
if ($this->totalCount < 0) {
return -1;
} $count = $this->totalCount / $this->pageSize;
if ($this->totalCount % $this->pageSize > 0) {
$count++;
}
return $count;
} /**
* 是否还有下一页.
*/
function isHasNext() {
return ($this->pageNo + 1 <= $this->getTotalPages());
} /**
* 取得下页的页号,序号从1开始.
*/
function getNextPage() {
if (isHasNext()) {
return $this->pageNo + 1;
} else {
return $this->pageNo;
}
} /**
* 是否还有上一页.
*/
function isHasPre() {
return ($this->pageNo - 1 >= 1);
} /**
* 取得上页的页号,序号从1开始.
*/
function getPrePage() {
if ($this->isHasPre()) {
return $this->pageNo - 1;
} else {
return $this->pageNo;
}
} /**
* 取得反转的排序方向. 如果有以','分隔的多个排序方向,逐一进行反转.
*/
function getInverseOrder() {
$orders[] = StringUtils.split($this->order, ','); for ($i = 0; i < $this->order.length; $i++) {
if ($this->DESC.equals($orders[i])) {
$orders[i] = $this->ASC;
} else {
$orders[i] = $this->DESC;
}
}
return StringUtils.join($orders);
} function isPageSetted() {
return $this->pageSize != -1;
}
}
?>
INFO : com.app.pub.web.SecurityFilter - Request URI:/mam/interface/appInterface
2011-8-29 10:16:01 com.caucho.hessian.io.SerializerFactory getDeserializer
警告: Hessian/Burlap: 'Page' is an unknown class in WebappClassLoader
context: /mam
delegate: false
repositories:
/WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@3b8b49
:
java.lang.ClassNotFoundException: Page
2011-8-29 10:16:01 com.caucho.hessian.server.HessianSkeleton invoke
警告: java.lang.IllegalArgumentException: argument type mismatch
java.lang.IllegalArgumentException: argument type mismatch
Page Object ( ) Hessian fault: argument type mismatch
Fatal error: Uncaught exception 'HessianError' with message 'Hessian fault: argument type mismatch' in C:\AppServ\www\ireadygo_boss\HessianPHP\Protocol.php:90 Stack trace: #0 C:\AppServ\www\ireadygo_boss\HessianPHP\Protocol.php(216): HessianParser->makeFault('Hessian fault: ...', Array) #1 C:\AppServ\www\ireadygo_boss\HessianPHP\Protocol.php(158): HessianParser->parseFault() #2 C:\AppServ\www\ireadygo_boss\HessianPHP\Protocol.php(195): HessianParser->parseObject('f') #3 C:\AppServ\www\ireadygo_boss\HessianPHP\Hessian.php(194): HessianParser->parseReply() #4 C:\AppServ\www\ireadygo_boss\HessianPHP\HessianClient.php(104): HessianProxy->call('searchGame', Array) #5 [internal function]: HessianClient->__call('searchGame', Array) #6 C:\AppServ\www\ireadygo_boss\cgibin\demo_hessian.php(34): HessianClient->searchGame('', '', Object(Page)) #7 {main} thrown in C:\AppServ\www\ireadygo_boss\HessianPHP\Protocol.php on line 90