【发布时间】:2013-01-23 10:46:05
【问题描述】:
我正在为一个项目学习 SOAP,现在我了解了它的基础知识。不敢相信我以前从未尝试过使用它。这很棒。但无论如何,我的问题。
我已成功将我的请求响应打印到网络浏览器,但我似乎无法将此响应转换为 STD 对象。
我一直在学习一个教程并将其调整为不同的 WDSL 文件,以完全理解我在做什么。
这是我的 PHP 文件。
<?
//////////////////////////////////////
//
// ABOUT: This file will send a request to the WSDL file and return a result in the browser window
// AUTHOR: Brad Bird
// DATE: 07/02/2013
//
//////////////////////////////////////
// Setup the SOAP Client options
$wsdl = "http://www.mobilefish.com/services/web_service/countries.php?wsdl";
$options = array(
"trace" => 1,
"exception" => 0
);
// Creates new instance of the SOAP Client
$client = new SoapClient($wsdl, $options);
// Return a set of information using one function
$countryCode = "af";
$values = $client->countryInfoByIana($countryCode);
// Prints the details of the request and response to the browser
print "<h2>SOAP Details</h2>";
print "<pre>";
print "<h3>Request</h3> " . htmlspecialchars($client->__getLastRequest()) . "<br />";
print "<h3>Response</h3> " . htmlspecialchars($client->__getLastResponse());
print "</pre>";
// Prints the request in XML format
$xml = $values->countryInfoByIanaResponse;
print "<h2>stdClass Object</h2>";
print "<pre>";
print_r($xml);
print "</pre>";
我试图从中获取请求的这个 WSDL 文件就在这里。 http://www.mobilefish.com/services/web_service/countries.php?wsdl
由于某种原因,STD 对象部分没有显示任何内容。有什么想法吗?
【问题讨论】:
-
print_r($values);会发生什么? -
我现在在手机上。但我确实尝试过,但它没有产生 std 对象。
-
+1 用于复制/粘贴准备好的代码。下次可能会缩短一点-提出问题的人可能是作者。
-
如果
print_r($values);什么也没产生,那么$client->countryInfoByIana($countryCode);什么也不返回。 -
@ExternalUse 很抱歉,我本可以在将其发布到此处之前将其缩短一点!我现在已经选择了我选择的答案:)。