1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| /** * @param $url 请求wsdl地址 * @param $method 请求方法 * @param $content 请求参数 * @return array */ function request($url, $method, $content) { $params = array('location' => $url);//为了目标网址为 https 也能通 try { $soap = new SoapClient($url, $params);//实例化 } catch (\SoapFault $e) { return [ 'status' => 1, 'msg' => $e->getMessage(), 'data' => [], ]; }
try { $res = $soap->__soapCall($method, $content);//请求 } catch (\SoapFault $e) { return [ 'status' => 1, 'msg' => $e->getMessage(), 'data' => '', ]; }
return json_decode($res, true); }
|