2014-08-27 120 views
1

我的SOAP請求中有一個深度爲幾個級別的數組,如下所示。當我運行我的SoapRequest時,我得到Notice(8):Array to string conversion,而我的XML響應不會將RTrans中的Array轉換爲XML,我不知道爲什麼。我如何創建SOAP請求及其XML版本可以在下面找到。php soapclient數組到字符串轉換

的請求:

$r['request'] = array(
'request' => array(
    'user' => 'test', 
    'password' => 'test', 
    'RTrans' => array(
     'Transactions' => array(
      'Criteria' => array(
       'Name' => 'Thomas' 
      ) 
     ) 
    ) 
) 
); 

try{ 
    $response = $this->apiClient->DoQuery($r); 
} 
catch(Exception $e){ 
    debug($e); 
} 

XML版本

<?xml version="1.0" encoding="UTF-8"?> 
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:ns1="http://webServices/"> 
<SOAP-ENV:Body> 
    <ns1:DoNormalEnquiry> 
     <request> 
      <username>test</usernmae> 
      <password>test</password> 
      <RTrans>Array</RTrans> 
     </request> 
    </ns1:DoNormalEnquiry> 
</SOAP-ENV:Body> 

回答

0

我覺得RTRANS被定義爲一個字符串。請看看wsdl文件。 也許這就是你在xml中獲得「數組」的原因。

要發送一個數組到你的soapservice你可以將它轉換成json。 json_encode(陣列( '交易'=>數組( '標準'=>數組( '姓名'=> '托馬斯')));

或限定複雜的數據類型

也許SoapVar將幫助你?

+0

從我知道它期待一個XML字符串,所以我應該有它在這種格式 RTRANS =「<交易>托馬斯」; – user1005319 2014-08-27 12:18:41