<?php $ws_url = "http://10.10.10.10/ws"; $wsdl = "{$ws_url}/webservice.asmx?wsdl"; // test $account = 'account'; $password = 'password'; try { $client = new SoapClient($wsdl); } catch (Exception $e) { echo $e->getMessage(); } // 透過 __getFunctions 可以取得此 WSDL 所提供的 WebServices $functions = $client->__getFunctions(); $client->IIsLoginOK( $account, $password ); $soap_params = array( 'parameters' => array( 'account' => $account, 'password' => $password ) ); $info = $client->__soapCall("login", $soap_params ); print_r($info);
最難搞的地方在於 $soap_params
因為一般的呼叫方式都只要傳遞參數即可,但是在這邊卻要透過 array 傳遞,而且外面還要再用一層 parameters 包起來才行~!!!!
查好久才找到問題!!