我是axis2和php的新手。我需要实现客户端.php它将基于端口 8282 上的中间件执行一些操作。我的问题是我的本地主机是 8080,我无法访问中间件。这是代码:
<?php
class ScriptSoapClient extends SoapClient {
public function __doRequest($request,$location,$action,$version,$one_way=0) {
$response=parent::__doRequest($request,$location,$action,$version,$one_way);
$response=preg_replace('#^.*(<?xml.*>)[^>]*$#s','$1',$response);
return $response;
}
}
// | is used as splitting char for arrays
function runService() {
//global $KERNELURL;
$KERNELURL="127.0.0.1:8282/axis2/services/MiddleService?wsdl"; $num=func_num_args();
if ($num < 2) return;
$service=new ScriptSoapClient(null, array("location"=> $KERNELURL,"uri"=>"http://ws.apache.org/axis2","trace"=>true));
$p[0]=new SoapParam((string)func_get_arg(0),"p1");
$p[1]=new SoapParam((string)func_get_arg(1),"p2");
for ($i=2; $i < $num-1;$i++) {
$param=func_get_arg($i);
if (is_array($param)) {
$data="||ARR||".implode("|",$param);
} else {
$data=$param;
}
$p[$i]=new SoapParam((string)$data,"p3");
}
$p[$num-1]=new SoapParam((string)func_get_arg($num-1),"p4");
try {
$result=$service->__soapCall("run",$p);
} catch (SoapFault $e) {
echo $e;
return "error";
}
unset($service);
if (is_array($result)) {
return $result["return"];
} else {
return $result;
}
}
$res2=runService("Service_addCostume","addCostume","costum1");
?>
这是我的错误:
SoapFault exception: [HTTP] Unknown protocol. Only http and https are allowed. in C:xampphtdocsClient_addCostume.php:4 Stack trace:
#0 C:xampphtdocsClient_addCostume.php(4): SoapClient->__doRequest('__doRequest('__soapCall('run', Array)
#3 C:xampphtdocsClient_addCostume.php(41): runService('Service_addCost...', 'addCostume', 'costum1')
#4 {main}
在$KERNELURL之前添加一个 http://