2014-08-27 122 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