2016-01-08 131 views
-1

从当我得到与SOAP调用的var_dump导致如下:呼叫与POST方法

WSDL地图

stdClass的对象 ( [网站] =>数组 ( [0] => stdClass的对象 ( [ID] => 102728 [网站ID] => 0 )

我想实现呼叫站点阵列来显示数据:

Post方法调用的SOAP数据

<?php 


$opts = array(
      'ssl' => array('ciphers'=>'RC4-SHA', 'verify_peer'=>false, 'verify_peer_name'=>false) 
     );`enter code here` 

// SOAP 1.2 client 
$params = array (
    'encoding' => 'UTF-8', 
    'verifypeer' => false, 
    'verifyhost' => false, 
    'soap_version' => SOAP_1_2, 
    'trace' => 1, 'exceptions' => 1, 
    "connection_timeout" => 180, 
    'stream_context' => stream_context_create($opts)); 

//disable wsdl cache 
ini_set("soap.wsdl_cache_enabled", "0"); 


$client = new SoapClient("http://www.example.com?WSDL",$params); 

$result1=$client->getSiteInfo(); 

$zone = $result1->Sites; 
if(isset($_POST['rayat'])){ 
    echo $zone; 
} 
else { 


?> 

<form action="index.php" method="post"> 

<input id="rayat" name="rayat" size="10" type="text" value="" /> 
<input id="submit" name="submit" type="submit" value="submit" /> 

</form> 


          
  
<?php 
 

 
    //$param = array('isbn'=>'0385503954'); 
 
    // define path to server application 
 
    $opts = array(
 
       'ssl' => array('ciphers'=>'RC4-SHA', 'verify_peer'=>false, 'verify_peer_name'=>false) 
 
      ); 
 

 
    // SOAP 1.2 client 
 
    $params = array (
 
     'encoding' => 'UTF-8', 
 
     'verifypeer' => false, 
 
     'verifyhost' => false, 
 
     'soap_version' => SOAP_1_2, 
 
     'trace' => 1, 'exceptions' => 1, 
 
     "connection_timeout" => 180, 
 
     'stream_context' => stream_context_create($opts)); 
 

 
    //disable wsdl cache 
 
    ini_set("soap.wsdl_cache_enabled", "0"); 
 

 
    $server = ''; 
 

 
     
 
    $client = new SoapClient("http://www.example.com?WSDL",$params); 
 

 
    $result1=$client->getSiteInfo(); 
 
     
 
    $zone = $result1->Sites; 
 
    if(isset($_POST['rayat'])){ 
 
     echo $zone; 
 
    } 
 
    else { 
 
     
 

 
    ?> 
 

 

 
    <form action="champ.php" method="post"> 
 

 
    <input id="rayat" name="rayat" size="10" type="text" value="" /> 
 
    <input id="submit" name="submit" type="submit" value="submit" /> 
 

 
    </form> 
 

 
    <?php 
 
    } 
 
    ?> 
 
<?php } ?> Above code give me result is 'Array'

回答

-1

肥皂结果对象作为你的var_dump阵列()告诉你。如果你是说,你的SOAP调用将始终只返回一个结果,你可以做这样的事情骗一点:

$zone = $result1->Sites; 
    if(isset($_POST['rayat'])){ 
     echo 'ID: ' . $zone[0]->id . '<br>SiteID: ' . $zone[0]->siteid; 
    } else { 
    ... 
+0

感谢您的及时回复,您已解决。 – mike1225

-1

$区变量是一个数组,你不能回应一个数组,所以你要么必须循环通过数组并回显每个单独的值或直接访问值,如其他答案中所示。

0

试图让搜索价值,它让没有价值!请coorect我!

WSDL

stdClass的对象 ( [opsTrackerSites] =>数组 ( [0] => stdClass的对象 ( [managerName] => DECOMM-MGR,GC [techName] => dectech )

<?php 
    $opts = array(
        'ssl' => array('ciphers'=>'RC4-SHA', 'verify_peer'=>false, 'verify_peer_name'=>false) 
       ); 


     $params = array (
      'encoding' => 'UTF-8', 
      'verifypeer' => false, 
      'verifyhost' => false, 
      'soap_version' => SOAP_1_2, 
      'trace' => 1, 'exceptions' => 1, 
      "connection_timeout" => 180, 
      'stream_context' => stream_context_create($opts)); 

     //disable wsdl cache 
     ini_set("soap.wsdl_cache_enabled", "0"); 




     $client = new SoapClient("http://example.com?WSDL",$params); 

     $result = $client->getSiteInfo(); 
     $zone = $result->Sites; 
     $output = ''; 
     if(isset($_POST['search'])){ 
      $searchq = $_POST['search']; 
      $searchq = preg_replace("#[^0-9a-z]#i","",$searchq); 
      $zone = $result->Sites; 

      if($zone == ''){ 
       $output = 'There was no search results!'; 
      } 
      else{ 
       $output .= '<div>' .$zone->techName.''.$zone->managerName.'<div>'; 
       echo $output; 
     }} 
?> 
<form action="champ.search.php" method="post"> 
      <input type="text" name="search" placeholder="Search for Contacts..."> 
      <input id="submit" name="submit" type="submit" value="submit" /> 
     </form>