[由于是保存过的内容,原地址找不到了,不好意思]
Soap是简单对象访问协议.在php5中得到了非常非常好的支持.
我在学习和测试soap过程中,第一次发现中文字符要出错.立刻就猜想到这不会成为问题.
下面是我测试成功的演示代码,请注意encoding=gb2312,charset=utf-8.呵呵
client.php:
CODE
<?php
header("content-type:text/html;charset=utf-8");
try {
$opts = array('location' => '
http://127.0.0.1/server.php',
'uri' => '
http://127.0.0.1/test');
$client = new SoapClient(NULL, $opts);
$data = $client->__call('get', array('info'));
print ($data);
} catch (SOAPFault $e) {
print $e;
}
?>
server.php:
CODE
<?
class soap_test
{
private $d = array('info'=>'<font size="4" color="#0000cc">用php5操作soap实在是太方便了!</font><br>注:<font size="2" color="#006600">本测试的平台为apache+win2000+php5.0.4+IE6.0</font>');
public function get($key)
{
return $this->d[$key];
}
}
$sv = new SoapServer(NULL,array('uri'=>'
http://127.0.0.1/test','encoding'=>'gb2312'));
$sv->setClass('soap_test');
$sv->handle();
?>