
最近搞微軟 .Net 的 SOAP 真是搞死人!!~~~ 想不到跟 PHP 介接沒有那麼單純。因為除了透過 WSDL 取得定義之外,呼叫的方式還要有特殊的參數!!!~ 紀錄一下免得忘記
<?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 包起來才行~!!!!
查好久才找到問題!!