Php 如何将多个同名对象传递给SOAP?
我已经找到了几个适用于标量但不适用于嵌套对象的答案。为了简单起见,这是我应该生成的简化XML:Php 如何将多个同名对象传递给SOAP?,php,xml,soap,Php,Xml,Soap,我已经找到了几个适用于标量但不适用于嵌套对象的答案。为了简单起见,这是我应该生成的简化XML: <order> <date>2019-08-28</date> <orderLines> <orderLine> <productCode>123</productCode> <quantity>12</quantity&
<order>
<date>2019-08-28</date>
<orderLines>
<orderLine>
<productCode>123</productCode>
<quantity>12</quantity>
<unitPrice>99.66</unitPrice>
</orderLine>
<orderLine>
<productCode>987</productCode>
<quantity>1</quantity>
<unitPrice>4500.00</unitPrice>
</orderLine>
</orderLines>
</order>
这显然是行不通的,因为我无法确定orderItem XML元素的名称
如何在对象中表示此XML结构
$order = new \stdClass();
$order->date = "2019-08-27"
$orderItems = [];
foreach($orderManager->getOrderItems() as $orderCartItem){
$orderItem = new \stdClass();
$orderItem->productCode = $orderCartItem->getProdCode();
$orderItem->quantity = $orderCartItem->getQty();
$orderItem->unitPrice = $orderCartItem->getUnitPrice();
$orderItems[] = $orderItem;
}
$order->orderLines = $orderItems;