示例#1
0
 public function makeRequest($service, $requestBody)
 {
     $url = 'http://www.webservicex.net/' . $service . '.asmx';
     $request = '<?xml version="1.0" encoding="utf-8"?>
     <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
         <soap12:Body>' . $requestBody . '</soap12:Body>
     </soap12:Envelope>';
     $options = [CURLOPT_SSL_VERIFYHOST => 1, CURLOPT_SSL_VERIFYPEER => 1, CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => 1, CURLOPT_CONNECTTIMEOUT => 60, CURLOPT_POST => 1, CURLOPT_POSTFIELDS => $request, CURLOPT_HTTPHEADER => ['Content-Type: text/xml; charset=utf-8', 'Content-Length: ' . strlen($request)], CURLOPT_FOLLOWLOCATION => true];
     $this->response = CurlHelper::makeRequest($url, $options);
     return $this;
 }