我目前正在尝试使用PHP中的SOAP客户端发送一些订单数据。
大多数请求都可以正常工作,并且看起来很好,数据最终出现在另一端。
但是,数组的多维部分将被忽略,并且不会在请求中发送。
我的请求中忽略了“ cedOrderRows” 下的所有数组“子项”。
示例数组/数据-https://pastebin.com/4aiZTLjz
我尝试了几种不同的数组结构,但它们似乎都不起作用,从我在其他文章/线程中看到的来看,这似乎是添加多个数组元素的方法(使用相同的键) 到SOAP请求。
我正在调用此函数“ CEDCreateB2COrder” / “ CEDCreateB2COrderRequest”
<xsd:element name="CEDCreateB2COrderRequest">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="custCode" minOccurs="0" maxOccurs="1" type="xsd:string"/>
<xsd:element name="payCond" minOccurs="0" maxOccurs="1" type="xsd:string"/>
<xsd:element name="currency" minOccurs="0" maxOccurs="1" type="xsd:string"/>
<xsd:element name="payRef" minOccurs="0" maxOccurs="1" type="xsd:string"/>
<xsd:element name="custName" minOccurs="0" maxOccurs="1" type="xsd:string"/>
<xsd:element name="address1" minOccurs="0" maxOccurs="1" type="xsd:string"/>
<xsd:element name="address2" minOccurs="0" maxOccurs="1" type="xsd:string"/>
<xsd:element name="postalAdd" minOccurs="0" maxOccurs="1" type="xsd:string"/>
<xsd:element name="state" minOccurs="0" maxOccurs="1" type="xsd:string"/>
<xsd:element name="countryCode" minOccurs="0" maxOccurs="1" type="xsd:string"/>
<xsd:element name="webOrderId" minOccurs="0" maxOccurs="1" type="xsd:string"/>
<xsd:element name="webOrderNo" minOccurs="0" maxOccurs="1" type="xsd:string"/>
<xsd:element name="freight" minOccurs="0" maxOccurs="1" type="xsd:double"/>
<xsd:element name="freightTax" minOccurs="0" maxOccurs="1" type="xsd:double"/>
<xsd:element name="orderDate" minOccurs="0" maxOccurs="1" type="xsd:string"/>
<xsd:element name="phone" minOccurs="0" maxOccurs="1" type="xsd:string"/>
<xsd:element name="email" minOccurs="0" maxOccurs="1" type="xsd:string"/>
<xsd:element name="ordertotal" minOccurs="0" maxOccurs="1" type="xsd:string"/>
<xsd:element name="vat" minOccurs="0" maxOccurs="1" type="xsd:string"/>
<xsd:element name="cedOrderRows" minOccurs="0" maxOccurs="1" type="tns:cedOrderRow"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
每个“订单行”都应包含。...
<xsd:complexType name="cedOrderRow">
<xsd:sequence>
<xsd:element name="artCode" minOccurs="0" maxOccurs="1" type="xsd:string"/>
<xsd:element name="qty" minOccurs="0" maxOccurs="1" type="xsd:int"/>
<xsd:element name="orderLinePrice" minOccurs="0" maxOccurs="1" type="xsd:double"/>
<xsd:element name="orderLinePricePerUnit" minOccurs="0" maxOccurs="1" type="xsd:double"/>
<xsd:element name="orderLineTax" minOccurs="0" maxOccurs="1" type="xsd:double"/>
</xsd:sequence>
</xsd:complexType>
我的代码SOAP请求代码如下。...
$options = array(
'exceptions' => true,
'trace' => 1,
'cache_wsdl' => WSDL_CACHE_NONE,
'connection_timeout' => 60,
);
$client = new SoapClient(TARGET_URL, $options);
$result = new stdClass();
try {
// $result->data = $client->CEDCreateB2COrder($data); // THIS GIVES THE SAME RESULT
$result->data = $client->__soapCall('CEDCreateB2COrder', array($data));
$result->req = $client->__getLastRequest();
} catch (Exception $e) {
$result->request = $client->__getLastRequest();
$result->response = $client->__getLastResponse();
$result->e = $e->getMessage();
}
return $result;
我的 __ getLastRequest()返回。...
<soap-env:envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://example.com">
<soap-env:body>
<ns1:cedcreateb2corderrequest>
<ns1:custcode>W1000</ns1:custcode>
<ns1:paycond>CHE</ns1:paycond>
<ns1:currency>EUR</ns1:currency>
<ns1:payref>ManualOrderRef</ns1:payref>
<ns1:custname>Foo Bar</ns1:custname>
<ns1:address1>Street 1</ns1:address1>
<ns1:postaladd>1234 City</ns1:postaladd>
<ns1:countrycode>CE</ns1:countrycode>
<ns1:weborderid>1875</ns1:weborderid>
<ns1:weborderno>WS18750</ns1:weborderno>
<ns1:freight>39.2</ns1:freight>
<ns1:freighttax>9.8</ns1:freighttax>
<ns1:orderdate>190410</ns1:orderdate>
<ns1:phone>0000000000</ns1:phone>
<ns1:email>foo@bar.com</ns1:email>
<ns1:ordertotal>1477.30</ns1:ordertotal>
<ns1:cedorderrows></ns1:cedorderrows>
</ns1:cedcreateb2corderrequest>
</soap-env:body>
</soap-env:envelope>
并且您会看到 ns1:cedorderrows (靠近底部)为空。
如何正确/正确地将多维数组项添加到我的SOAP请求中?
谢谢!