2013-05-01 58 views
0

我有一個很差的WSDL文件,我無法理解如何從中檢索信息。使用SOAP從WSDL檢索值 - PHP

VM不是從外部網絡訪問,所以我不能共享整個WSDL文件

我想用getList函數,它接受一個參數,並且返回一個字符串,具有多重價值。

SOAP Request 

<?xml version="1.0" encoding="UTF-8"?> 
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"> 
    <S:Header/> 
    <S:Body> 
     <ns2:getList xmlns:ns2="http://Wishlist.eBookCafe/"> 
      <arg0>2</arg0> 
     </ns2:getList> 
    </S:Body> 
</S:Envelope> 

SOAP Response 

<?xml version="1.0" encoding="UTF-8"?> 
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"> 
    <S:Body> 
     <ns2:getListResponse xmlns:ns2="http://Wishlist.eBookCafe/"> 
      <return>[1]</return> 
     </ns2:getListResponse> 
    </S:Body> 
</S:Envelope> 

我的問題是,因爲值包含內部return標籤,我不知道我怎麼能使用SOAP將其存儲在一個PHP變量。

$list = $service->getList(array('arg0'=>$id)); 
print_r($list); 

即使我使用靜態的數字作爲傳遞參數,它總是返回包含給id = 1

回答

0

用戶和博客文章(這是現在去除 :()的值>>

<?php 
$url = 'your_url_orFilePath'; 
$client = new SoapClient($url); 

$xmlr = new SimpleXMLElement("<main_key></main_key>"); 
$xmlr->addChild('childName1', $childName1); 
$xmlr->addChild('childName2', $childName2); 
------ 
----likewise--- 

$params = new stdClass(); 
$params->xml = $xmlr->asXML(); 
$result = $client->main_key_function($params); 
?>