gpt4 book ai didi

php - 在 nusoap 和 PHP 中发送数据数组

转载 作者:搜寻专家 更新时间:2023-10-31 22:15:57 25 4
gpt4 key购买 nike

希望有人能帮我解决这个问题。我正在使用以下部分 WSDL 构建 nusoap 客户端:

      <s:element name="SavePrestaPicklist">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="USERNAME" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="PASSWORD" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="BRANCH" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="CUSTOMERNUMBER" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="CUSTOMERPO" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="SHIPMETHOD" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="PRESTAPO" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="PICKITEMS" type="tns:ArrayOfPICKITEM" />
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="ArrayOfPICKITEM">
<s:sequence>
<s:element minOccurs="0" maxOccurs="unbounded" name="PICKITEM" nillable="true" type="tns:PICKITEM" />
</s:sequence>
</s:complexType>
<s:complexType name="PICKITEM">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="PARTNUMBER" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="BRANCH" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="MFRCODE" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="QUANTITY" type="s:string" />
</s:sequence>
</s:complexType>

我的客户是这样的:

   $orderdata = getorder('123');
$orderdata = array(
'USERNAME' => $config['export_username'],
'PASSWORD' => $config['export_password'],
'BRANCH' => '01',
'CUSTOMERNUMBER' => $data['order']['address1'],
'CUSTOMERPO' => $data['order']['gift_message'],
'SHIPMETHOD' => $shipMethod,
'PRESTAPO' => $data['order']['id_order']);

// Build the pickitems array of pickitem.

$pickitems = array();
foreach($data['products'] as $item) {

$pickitem = array(
'PARTNUMBER' => $item['name'],
'BRANCH' => '01',
'MFRCODE' => '642',
'QUANTITY' => $item['product_quantity']);

$pickitems[] = $pickitem;
}
$data['PICKITEMS'] = $pickitems;

$usingWsdl = true;
$client = new nusoap_client($config['export_wsdl'], $usingWsdl);

$response = $client->call('SavePrestaPicklist', $orderdata);

这不起作用并发送如下 PICKITEMS:

<PICKITEMS>
<0>
<PARTNUMBER>BLAH</PARTNUMBER>
<BRANCH>BLAH</BRANCH>
ETC.
</0>
<1>
ANOTHER ITEM SET
</1>
</PICKITEMS>

我想要的是:

<PICKITEMS>
<PICKITEM>
<PARTNUMBER>BLAH</PARTNUMBER>
<BRANCH>BLAH</BRANCH>
ETC.
</PICKITEM>
<PICKITEM>
ANOTHER ITEM SET
</PICKITEM>
</PICKITEMS>

由于在 PHP 中不能有重复的“PICKITEM”键,所以我不知道该怎么做。任何帮助将不胜感激。

最佳答案

'PICKITEMS' => 
array (
'PICKITEM' =>
array(
0 => array('PARTNUMBER' => 'param1', 'BRANCH' => 'value1'),
1 => array('PARTNUMBER' => 'param2', 'BRANCH' => 'value2')
)
)

关于php - 在 nusoap 和 PHP 中发送数据数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6286081/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com