在的NuSOAP和PHP发送数据数组 [英] Sending data arrays in nusoap and PHP
本文介绍了在的NuSOAP和PHP发送数据数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
希望有人能帮助我与此有关。我使用以下部分的WSDL建设的NuSOAP客户端:
< S:元素名称=保存prestaPicklist>
< S:复杂类型>
&所述氏:序列GT;
< S:元素的minOccurs =0的maxOccurs =1NAME =username的类型=S:字符串/>
< S:元素的minOccurs =0的maxOccurs =1NAME =密码类型=S:字符串/>
< S:元素的minOccurs =0的maxOccurs =1NAME =科类型=S:字符串/>
&所述氏:元件的minOccurs =0maxOccurs的=1名称=CUSTOMERNUMBER类型=S:串/>
&所述氏:元件的minOccurs =0maxOccurs的=1名称=CUSTOMERPO类型=S:串/>
&所述氏:元件的minOccurs =0maxOccurs的=1名称=SHIPMETHOD类型=S:串/>
&所述氏:元件的minOccurs =0maxOccurs的=1名称=preSTAPO类型=S:串/>
< S:元素的minOccurs =0的maxOccurs =1NAME =PICKITEMSTYPE =TNS:ArrayOfPICKITEM/>
&所述; /秒:序列GT;
< / s的:复杂类型>
&所述; /秒:组件>
< S:复杂类型名称=ArrayOfPICKITEM>
&所述氏:序列GT;
< S:元素的minOccurs =0的maxOccurs =无界NAME =PICKITEM的nillable =真TYPE =TNS:PICKITEM/>
&所述; /秒:序列GT;
< / s的:复杂类型>
< S:复杂类型名称=PICKITEM>
&所述氏:序列GT;
< S:元素的minOccurs =0的maxOccurs =1NAME =PARTNUMBER类型=S:字符串/>
< S:元素的minOccurs =0的maxOccurs =1NAME =科类型=S:字符串/>
< S:元素的minOccurs =0的maxOccurs =1NAME =MFR code型=S:字符串/>
< S:元素的minOccurs =0的maxOccurs =1NAME =量类型=S:字符串/>
&所述; /秒:序列GT;
< / s的:复杂类型>
我的客户是这样的:
$ orderdata = getorder('123');
$ orderdata =阵列(
USERNAME => $配置['export_username'],
密码= GT; $配置['export_password'],
BRANCH'=> 01,
CUSTOMERNUMBER'=> $数据['秩序'] ['地址1'],
CUSTOMERPO'=> $数据['秩序'] ['GIFT_MESSAGE'],
SHIPMETHOD'=> $ shipMethod,
'preSTAPO'=> $数据['秩序'] ['id_order']); //建立pickitem的pickitems数组。 $ pickitems =阵列();
的foreach($数据['产品']为$项目){ $ pickitem =阵列(
PARTNUMBER'=> $项目['名'],
BRANCH'=> 01,
MFR code'=> '642',
量= GT; $项目['product_quantity']); $ pickitems [] = $ pickitem;
}
$数据['PICKITEMS'] = $ pickitems; $ usingWsdl =真;
$客户端=新nusoap_client($配置['export_wsdl'],$ usingWsdl); $响应= $客户 - >调用(保存prestaPicklist',$ orderdata);
这是行不通的,并发送一个PICKITEMS是这样的:
< PICKITEMS>
&℃,GT;
<&PARTNUMBER GT;&BLAH LT; / PARTNUMBER>
<分行及GT;&BLAH LT; /支>
等等。
< / 0 GT;
&所述1为卤素;
其他项设置
< / 1 GT;
< / PICKITEMS>
我想是这样的:
< PICKITEMS>
< PICKITEM>
<&PARTNUMBER GT;&BLAH LT; / PARTNUMBER>
<分行及GT;&BLAH LT; /支>
等等。
< / PICKITEM>
< PICKITEM>
其他项设置
< / PICKITEM>
< / PICKITEMS>
既然你不能有重复的'PICKITEM在PHP中键我无法弄清楚如何做到这一点。任何帮助将是AP preciated。
解决方案
'PICKITEMS'=>
阵列(
PICKITEM'=>
阵列(
0 =>阵列('PARTNUMBER'=>'参数1','分公司'=>'值1'),
1 =>阵列('PARTNUMBER'=>'参数2','分公司'=>'值')
)
)
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')
)
)
这篇关于在的NuSOAP和PHP发送数据数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文