2015-04-01 63 views
0

我得到了轉換WSDL到PHP腳本,但有什麼不工作很我試圖連接http://www.regcheck.org.uk/api/reg.asmx?wsdl,但得到這個錯誤WSDL到PHP實現

Array ([RegCheckServiceCheck::Check] => SoapFault Object ([message:protected] => System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.NullReferenceException: Object reference not set to an instance of an object. at webtropy.CarReg.Check(String RegistrationNumber, String username) in c:\inetpub\wwwroot\regcheck.org.uk\api\reg.asmx:line 26 --- End of inner exception stack trace --- [string:Exception:private] => [code:protected] => 0 [file:protected] => C:\xampp\htdocs\Check\RegCheckServiceCheck.php [line:protected] => 32 [trace:Exception:private] => Array ([0] => Array ([file] => C:\xampp\htdocs\Check\RegCheckServiceCheck.php [line] => 32 [function] => __call [class] => SoapClient [type] => -> [args] => Array ([0] => Check [1] => Array ([0] => RegCheckStructCheck Object ([RegistrationNumber] => [username] => [result:RegCheckWsdlClass:private] => [lastError:RegCheckWsdlClass:private] => Array () [internArrayToIterate:RegCheckWsdlClass:private] => [internArrayToIterateIsArray:RegCheckWsdlClass:private] => [internArrayToIterateOffset:RegCheckWsdlClass:private] =>)))) [1] => Array ([file] => C:\xampp\htdocs\Check\RegCheckServiceCheck.php [line] => 32 [function] => Check [class] => SoapClient [type] => -> [args] => Array ([0] => RegCheckStructCheck Object ([RegistrationNumber] => [username] => [result:RegCheckWsdlClass:private] => [lastError:RegCheckWsdlClass:private] => Array () [internArrayToIterate:RegCheckWsdlClass:private] => [internArrayToIterateIsArray:RegCheckWsdlClass:private] => [internArrayToIterateOffset:RegCheckWsdlClass:private] =>))) [2] => Array ([file] => C:\xampp\htdocs\sample-regcheck.php [line] => 46 [function] => Check [class] => RegCheckServiceCheck [type] => -> [args] => Array ([0] => RegCheckStructCheck Object ([RegistrationNumber] => [username] => [result:RegCheckWsdlClass:private] => [lastError:RegCheckWsdlClass:private] => Array () [internArrayToIterate:RegCheckWsdlClass:private] => [internArrayToIterateIsArray:RegCheckWsdlClass:private] => [internArrayToIterateOffset:RegCheckWsdlClass:private] =>)))) [previous:Exception:private] => [faultstring] => System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.NullReferenceException: Object reference not set to an instance of an object. at webtropy.CarReg.Check(String RegistrationNumber, String username) in c:\inetpub\wwwroot\regcheck.org.uk\api\reg.asmx:line 26 --- End of inner exception stack trace --- [faultcode] => soap:Server [detail] =>))

我肯定缺少的東西在配置文件中,mybe有人有想法?

+0

請發表您的完整代碼。 – 2015-04-01 12:04:49

+0

請編輯您的問題並刪除代碼段 – hakre 2015-04-14 21:28:38

回答

1

有可能通過一個HTTP GET請求如下來調用Web服務;

<?php 
$username = 'Your username here'; 
$regNumber = 'SK08KPT'; 
$xmlData = file_get_contents("https://www.regcheck.org.uk/api/reg.asmx/Check?RegistrationNumber=" . $regNumber ."&username=" . $username); 
$xml=simplexml_load_string($xmlData);  
$strJson = $xml->vehicleJson;  
$json = json_decode($strJson);  
print_r($json->Description);  
?> 

不像SOAP調用那麼優雅,但更簡單。