我正在爲客戶端開發api。我收到以下信息:在非WSDL模式下使用PHP SOAP客戶端
我需要在非WSDL模式下配置相同的PHP SOAP客戶端。我寫了以下,但它似乎並沒有工作:
$wsdl = null;
$options = array(
'uri' => 'http://xyz-crm.example/WebAPI/Custom/project_name/XML/',
'location' => 'http://xyz-crm.exmaple.com/WebAPI/Custom/project_name/XML/',
'login' => 'foobar',
'password' => 'spameggs'
);
$client = new SoapCLient($wsdl, $options);
我只是想先做一個成功的ping到api。看看事情是否正常。我在這裏做錯了什麼?
更新1
我做了以下修改:
$wsdl = null;
$options = array(
'uri' => "http://xyz-crm.example/WebAPI/Custom/project_name/XML/",
'location' => "http://xyz-crm.example/",
'Username' => "foobar",
'Password' => "spameggs",
'soap_version' => '1.2'
);
$client = new SoapClient($wsdl, $options);
$client = $client->getListings();
我得到的錯誤:looks like we got no XML document
[Edit by me, hakre: This update was done as feedback to answer #1 . It changes the location option using a shortened URL (reason not given by OP) and it adds the soap_version option (as suggested in answer #1, but not as constant but as string (containing an invalid value), so there should be no wonder this creates an error, a correct option value is given in answer #1 (the
SOAP_1_1
constant) and by intention, the correct value would be theSOAP_1_2
constant for this example). Error message as commented by OP was "SOAP Fault: Wrong version."]
更新2
我嘗試以下,但它仍然失敗:
$listing = $client->getListings();
$request = $client->__getLastRequest();
停止執行在第一線本身而沒有去第二個。
[Edit by me, hakre: As review has shown wrong configuration options in Update 1 already which are not addressed in Update 2 it would be a miracle if it still wouldn't fail. The execution stops because an Exception is thrown and no error/exception handling is done]
您是否收到任何錯誤消息(是否打開了錯誤報告?)? – DanFromGermany
SOAP錯誤:版本錯誤。這是我得到的錯誤。我也對api uri感到困惑。在網上我看到.asmx作爲URI或位置的格式的例子。這是我第一次使用SOAP。 –