server.php
class HandelInfo{
public function AlcoholDetectionRecord($id = 0, $userId = "", $userTask = 0, $alcoholValue = 0.0, $alcoholResult = 0, $recordTime='',$recordVideoName = "", $answerAccuracy = '',$description = ""){
$record = $id.'-'.$userId.'-'.$userTask.'-'.$alcoholValue.'-'.$alcoholResult.'-'.$recordTime.'-'.$recordVideoName.'-'.$answerAccuracy.'-'.$description;
file_put_contents("record.txt",$record."\r\n",FILE_APPEND);
}
}
$server = new SoapServer(null, array("location" => "http://39.100.106.41/index.php", "uri" => "server.php"));
$server->setClass("HandelInfo");
$server->handle();
//$obj =
echo file_get_contents('record.txt');
client.php
<?php
/**
* SoapClient.php
* webservice 客户端实例
*/
header('Content-Type:text/html;charset=utf-8');
try {
//根据实际情况修改下行内容
// echo phpinfo();
// exit;
// $soap = new SoapClient(null, array('location'=>'http://39.100.106.41/index.php'));
$soap = new SoapClient("http://127.0.0.1/server.php?WSDL");
// var_dump($soap);
echo $soap->AlcoholDetectionRecord($id = 1000, $userId = "张三", $userTask = 1, $alcoholValue = 0.0, $alcoholResult = 0, $recordTime='222',$recordVideoName = "1.avi", $answerAccuracy = 100.0,$description = "车间:1;车组:2;车次:G5;班次:11;地区:北京;设备ID:dev123456");
} catch(SoapFault $e) {
echo $e->getMessage();
} catch(Exception $e) {
echo $e->getMessage();
}