76 lines
2.6 KiB
PHP
76 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace app\index\library;
|
|
use fast\Http;
|
|
class Wsdl
|
|
{
|
|
public static function webservice($data, $method) {
|
|
$param = '';
|
|
for($i=0;$i<count($data);$i++){
|
|
$param .= '<arg'.$i.'>'.$data[$i].'</arg'.$i.'>';
|
|
}
|
|
$body = '<?xml version="1.0" encoding="utf-8"?>
|
|
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
|
<soap:Body>
|
|
<n0:'.$method.' xmlns:n0="http://ws.service.shop.com/">
|
|
'.$param.'
|
|
</n0:'.$method.'>
|
|
</soap:Body>
|
|
</soap:Envelope>';
|
|
$url = "http://ye4s.com/webservice/ws?wsdl".$method;
|
|
$options = [
|
|
];
|
|
$req = Http::sendRequest($url, $body, 'POST', $options);
|
|
$res = $req['ret'] ? $req['msg'] : '';
|
|
preg_match_all("/<return>([^<]+)<\/return>/i",$res,$ress);
|
|
if(isset($ress[1][0])){
|
|
$arr = htmlspecialchars_decode($ress[1][0]);
|
|
}
|
|
else{
|
|
$arr = [];
|
|
}
|
|
return $arr;
|
|
}
|
|
public static function webserviceTest($data,$method){
|
|
$param = '';
|
|
for($i=0;$i<count($data);$i++){
|
|
$param .= '<arg'.$i.'>'.$data[$i].'</arg'.$i.'>';
|
|
}
|
|
$body = '<?xml version="1.0" encoding="utf-8"?>
|
|
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
|
<soap:Body>
|
|
<n0:'.$method.' xmlns:n0="http://ws.service.shop.com/">
|
|
'.$param.'
|
|
</n0:'.$method.'>
|
|
</soap:Body>
|
|
</soap:Envelope>';
|
|
return $body;
|
|
}
|
|
public static function webservicepda($data, $method) {
|
|
$param = '';
|
|
for($i=0;$i<count($data);$i++){
|
|
$param .= '<arg'.$i.'>'.$data[$i].'</arg'.$i.'>';
|
|
}
|
|
$body = '<?xml version="1.0" encoding="utf-8"?>
|
|
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
|
<soap:Body>
|
|
<n0:'.$method.' xmlns:n0="http://ws.service.shop.com/">
|
|
'.$param.'
|
|
</n0:'.$method.'>
|
|
</soap:Body>
|
|
</soap:Envelope>';
|
|
$url = "http://ye4s.com/webservice/pda?wsdl".$method;
|
|
$options = [
|
|
];
|
|
$req = Http::sendRequest($url, $body, 'POST', $options);
|
|
$res = $req['ret'] ? $req['msg'] : '';
|
|
preg_match_all("/<return>([^<]+)<\/return>/i",$res,$ress);
|
|
if(isset($ress[1][0])){
|
|
$arr = htmlspecialchars_decode($ress[1][0]);
|
|
}
|
|
else{
|
|
$arr = [];
|
|
}
|
|
return $arr;
|
|
}
|
|
} |