Hope someone can help me with this. I am building nusoap client using the following partial WSDL:
<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>
My client looks like this:
$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);
This isn't working and sends a PICKITEMS like this:
<PICKITEMS>
<0>
<PARTNUMBER>BLAH</PARTNUMBER>
<BRANCH>BLAH</BRANCH>
ETC.
</0>
<1>
ANOTHER ITEM SET
</1>
</PICKITEMS>
What I want is this:
<PICKITEMS>
<PICKITEM>
<PARTNUMBER>BLAH</PARTNUMBER>
<BRANCH>BLAH</BRANCH>
ETC.
</PICKITEM>
<PICKITEM>
ANOTHER ITEM SET
</PICKITEM>
</PICKITEMS>
Since you can't have duplicate 'PICKITEM' keys in PHP I can't figure out how to do this. Any help would be appreciated.
'PICKITEMS' =>
array (
'PICKITEM' =>
array(
0 => array('PARTNUMBER' => 'param1', 'BRANCH' => 'value1'),
1 => array('PARTNUMBER' => 'param2', 'BRANCH' => 'value2')
)
)