nusoap整合yii的问题 [ 新手入门 ]
server:
public function actionServer() {
$this->layout = false;
include "nusoap.php";//创建一个新的soap_server对象,并注册允许远程调用的方法
$s=new soap_server();//配置名称
//$s->configureWSDL("php_wsdl");//注册暴露的方法
$s->configureWSDL("php_wsdl-1", "");
$s->wsdl->schemaTargetNamespace="urn:php_wsdl-1";
$s->methodURI = 'http://192.168.50.107/web/webservices-test/index.php?r=webservice/server';
$s->register('test',
array("inputString"=>"xsd:string" ,),//输入参数
array( "return"=>"xsd:string", ),//输出参数
"urn:php_wsdl-1",//名字空间
"urn:php_wsdl-1#test",//名字空间#要操作的函数名
"rpc",//style
"encoded",//use
"This is test."//说明
);
/*$s->register('acceptMessage',
array("inputString"=>"xsd:string",), //输入参数
array( "return"=>"xsd:string", ),//输出参数
"urn:php_wsdl",//名字空间
"urn:php_wsdl#acceptMessage",//名字空间#要操作的函数名
"rpc",//style
"encoded",//use
"This is acceptMessage."//说明
);*/
function test($inputString) {//类性检查
if(is_string($inputString)) {
return "php Server已收到".$inputString;
} else {
return new soap_fault('client', '', '调用出错!');
}
}
/*function acceptMessage($inputString) {
return "php Server已收到:".$inputString;
}*/
//最后一步是把所有的收到的post数据都传递给SOAP server的service方法。它将处理请求,并调用相应的函数。
//$s->service( file_get_contents("php://input"));
// Use the request to (try to) invoke the service
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$s->service($HTTP_RAW_POST_DATA);exit;
}
client:
public function actionClient() {
include_once 'nusoap.php';// 创建一个soapclient对象,参数是server的WSDL
$client = new soapclient('http://192.168.50.107/web/webservices-test/index.php?r=webservice/server&wsdl', true);
//$client = new soapclient('http://192.168.50.107/web/webservices-test/server.php?wsdl', true);
$client->soap_defencoding = 'UTF-8';
$client->decode_utf8 = false;
$client->xml_encoding = 'UTF-8';
$client->request = 'http://192.168.50.107/web/webservices-test/index.php?r=webservice/server&wsdl';
$err = $client->getError();
if ($err) {
echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
}
//设置参数数组
$param=array(
"inputString"=>"你好",
);
//呼叫/使用 那个函数,注意名字空间的区分
$return=$client->call('test',$param);
if ($client->fault) {
echo '<h2>Fault</h2><pre>'; print_r($return); echo '</pre>';
} else {
$err = $client->getError();
if ($err) {
echo '<h2>Error</h2><pre>' . $err . '</pre>';
} else {
echo '<h2>Result</h2><pre>' . htmlspecialchars($return, ENT_QUOTES) . '</pre>';
}
}
//print_r($return);
// $return=$client->call('acceptMessage',$param);
// print_r($return);
echo '<h2>Request</h2><pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>';
echo '<h2>Response</h2><pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>';
echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '</pre>';
}
}
报错:
Error
Response not of type text/xml: text/html
Request
POST /web/webservices-test/index.php HTTP/1.0
Host: 192.168.50.107
User-Agent: NuSOAP/0.7.3 (1.114)
Content-Type: text/xml; charset=UTF-8
SOAPAction: "urn:php_wsdl-1#test"
Content-Length: 534
<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns4599="urn:php_wsdl-1"><SOAP-ENV:Body><ns4599:test xmlns:ns4599="urn:php_wsdl-1"><inputString xsi:type="xsd:string">浣犲ソ</inputString></ns4599:test></SOAP-ENV:Body></SOAP-ENV:Envelope>
Response
HTTP/1.1 200 OK
Date: Fri, 23 Mar 2012 01:31:01 GMT
Server: Apache/2.2.11 (Win32) DAV/2 mod_ssl/2.2.11 OpenSSL/0.9.8i PHP/5.2.9
X-Powered-By: PHP/5.2.9
Content-Length: 4834
Connection: close
Content-Type: text/html
什么原因?高手帮我分析下。。。
共 0 条回复
没有找到数据。
yhl27ml@163.com
注册时间:2011-04-09
最后登录:1970-01-01
在线时长:0小时0分
最后登录:1970-01-01
在线时长:0小时0分
- 粉丝0
- 金钱400
- 威望0
- 积分400