Annamaria Annamaria - 4 months ago 14
PHP Question

php soapclient call params

I need to transform the above call in php and the particularity is that in the call it is mandatory to have three params in the same argument:

<v20:searchItem>
<!--Optional:-->
<arg0>customer_id</arg0>
<arg1>table_name</arg1>
<arg3><field_name>Barcode</field_name><value>record_id</value></arg3>
<arg3><field_name>DOC_DATE min</field_name><value>date_min</value></arg3>
<arg3><field_name>DOC_DATE max</field_name><value>date_max</value></arg3>
<arg4></arg4>
<arg5>0</arg5>
<arg6>1000</arg6>
</v20:searchItem>


My code is:

$myParams1 = array('field_name' => 'Barcode',
'value' => $barcode);
$myParams2 = array('field_name' => 'DOC_DATE min',
'value' => $datai);
$myParams3 = array('field_name' => 'DOC_DATE max',
'value' => $newdate);
$params = array(
"arg0" => $sasAliasSP,
"arg1" => $sasAliasDA,
"arg2" => "",
"arg3" =>$myParams1,
"arg3" =>$myParams2,
"arg3" =>$myParams3,
"arg4" => "",
"arg5" => "0",
"arg6" => "1000"
);


but is not working, can you please help.
Thank you

Answer

I finally found the solution in this post: http://stackoverflow.com/a/19774498/6564057

arg3 needs to be an array with ascending keys starting with 0, so my code now is:

$myParams[] = array('nome_Campo' => 'Barcode', 'valore' => $barcode);
$myParams[] = array('nome_Campo' => 'DOC_DATE min', 'valore' => $datai);
$myParams[] = array('nome_Campo' => 'DOC_DATE max', 'valore' => $newdate);

$params = array(
    "arg0" => $sasAliasSP,  
    "arg1" => $sasAliasDA,
    "arg2" => "",
    "arg3" => $myParams,
    "arg4" => "",
    "arg5" => "0",
    "arg6" => "1000"
);

and it works like charms. Thank you very much.