Thinkphp调用webservice

<!DOCTYPE html>
<html>
<head>
<meta charset=”UTF-8″>
<title>Insert title here</title>
<script type=”text/javascript” src=”../Public/jquery-1.8.0.min.js”></script>
<script type=”text/javascript”>
$(function() {
var OCXobj = document.getElementById(“PlayViewOCX”);
OCXobj.SetOcxMode(0);
$.ajax({
//要用post方式
type : “Post”,
//方法所在页面和方法名
url : “../Home/User/GetPreViewXml”,
success : function(data) {
//返回的数据用data.d获取内容
if (data) {
OCXobj.StartTask_Preview_InWnd(data, 0);
}
},
error : function(err) {
alert(“调用webservice过程中发生了错误!”);
}
});
});
</script>
</head>
<body>

<input id=’previewXml’ value='{$previewXml}’ type=’hidden’ />
<div>
&nbsp;&nbsp;&nbsp;&nbsp;<input type=”button” value=”开始预览”
id=”StartPlayView” /> <br />
<div style=”width: 750px; float: left; overflow: hidden”>
&nbsp;&nbsp;&nbsp;<br /> &nbsp;&nbsp;&nbsp;&nbsp;
<!– 添加预览控件(需要先在windows下注册) –>
<object classid=”clsid:D5E14042-7BF6-4E24-8B01-2F453E8154D7″
id=”PlayViewOCX” width=”750″ height=”450″ name=”ocx”> </object>
</div>
</div>
</body>
</html>

function GetPreViewXml()
{
$client = new \SoapClient(“http://192.168.1.113/services/CmsService?wsdl”);
$funs = array(
$client->__getFunctions()
);

$userLogin = new \stdClass();
$userLogin->userName = ‘admin’;
$userLogin->pwd = ‘5B9BD37AE194BCE2D53666BCB9D99B01’;
$userLogin->clientIp = ‘192.168.1.105’;
$userLogin->clientPort = ’80’;
$userLogin->cmsUrl = ‘http://192.168.1.113’;

$loginResponse = $client->__call(“userLogin”, array(
$userLogin
));

$getCameraInfoByDeviceInfo = new \stdClass();
$getCameraInfoByDeviceInfo->indexCode = 2;
$getCameraInfoByDeviceInfo->sessionId = $loginResponse->return->sessionId;
$getCameraInfoByDeviceInfoResponse = $client->__call(“getCameraInfoByDeviceInfo”, array(
$getCameraInfoByDeviceInfo
));

$getPreviewParam = new \stdClass();
$getPreviewParam->sessionId = $loginResponse->return->sessionId;
$cameraArray = $getCameraInfoByDeviceInfoResponse->return->cameraArray;
$cameraIndexCode = ”;
if (is_array($cameraArray)) {
$cameraIndexCode = $cameraArray[0]->indexCode;
} else {
$cameraIndexCode = $cameraArray->indexCode;
}
$getPreviewParam->cameraIndexCode = $cameraIndexCode;

$getPreviewParamResponse = $client->__call(“getPreviewParam”, array(
$getPreviewParam
));

$this->ajaxReturn($getPreviewParamResponse->return->previewXml);
}

 

发表评论

电子邮件地址不会被公开。 必填项已用*标注