希望有人可以帮助我。我正在使用以下部分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”键,我无法弄清楚如何执行此操作。任何帮助将不胜感激。
答案 0 :(得分:0)
您可以使用$ client-&gt; send()方法发送原始XML。
$raw_xml = "<Your_XML>...</Your_XML>";
$msg = $client->serializeEnvelope("$raw_xml");
$result=$client->send($msg, $endpoint);
您可以在此处看到示例:
http://itworkarounds.blogspot.com/2011/07/send-raw-xml-with-php-nusoap.html
如果这不起作用,您可以尝试使用CURL发布XML。
答案 1 :(得分:0)
'PICKITEMS' =>
array (
'PICKITEM' =>
array(
0 => array('PARTNUMBER' => 'param1', 'BRANCH' => 'value1'),
1 => array('PARTNUMBER' => 'param2', 'BRANCH' => 'value2')
)
)