php soapclient call params

时间:2016-07-08 07:26:16

标签: php xml soap-client

我需要在php中转换上面的调用,并且特殊性是在调用中必须在同一个参数中有三个参数:

<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>

我的代码是:

$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"
);

但是没有用,请你帮忙。 谢谢

2 个答案:

答案 0 :(得分:0)

试试这个:

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

答案 1 :(得分:0)

我终于在这篇文章中找到了解决方案:https://stackoverflow.com/a/19774498/6564057

arg3需要是一个以0开头的升序键的数组,所以我的代码现在是:

var str = '<AB AA="10" BB="20" C="30" FLG="40" F="50" START="60"></AB>',
    parser, xml, attrib, obj = {};

if(window.DOMParser) {
  parser = new DOMParser();
  xml = parser.parseFromString(str, "text/xml");
  attrib = xml.documentElement.attributes;

  for(var i = 0; i < attrib.length; i++) {
    obj[attrib.item(i).name] = attrib.item(i).value;
  }
  console.log(obj);
}

它就像魅力一样。 非常感谢你。