WSDL 模式

首先,建立一個新的 SoapClient 物件,將 URL 傳遞給 WSDL 檔案,也可以選擇一組選項。

// Create a new client object using a WSDL URL
$soap = new SoapClient('https://example.com/soap.wsdl', [
    # This array and its values are optional
    'soap_version' => SOAP_1_2,
    'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP,
    'cache_wsdl' => WSDL_CACHE_BOTH,
    # Helps with debugging
    'trace' => TRUE,
    'exceptions' => TRUE
]);

然後使用 $soap 物件來呼叫 SOAP 方法。

$result = $soap->requestData(['a', 'b', 'c']);