在PHP中发送重复的XML节并使用数组构造
我正在与PHP的SOAP客户端交互,以向远程SOAP服务器发送和接收请求,并且我必须随请求发送的一个XML文档具有重复的部分。我的意思是XML是这样的:在PHP中发送重复的XML节并使用数组构造,php,xml,arrays,soap,Php,Xml,Arrays,Soap,我正在与PHP的SOAP客户端交互,以向远程SOAP服务器发送和接收请求,并且我必须随请求发送的一个XML文档具有重复的部分。我的意思是XML是这样的: <pSalesInvoiceInput> <SalesInvoice> <invoice_date>[unknown type: string]</invoice_date> <due_date>[unknown type: string]<
<pSalesInvoiceInput>
<SalesInvoice>
<invoice_date>[unknown type: string]</invoice_date>
<due_date>[unknown type: string]</due_date>
<notes>[unknown type: string?]</notes>
<line_data>
<description></description>
<net_amount>[unknown type: string]</net_amount>
<vat_amount>[unknown type: string]</vat_amount>
<nominal_code>[unknown type: string]</nominal_code>
</line_data>
<line_data>
<description></description>
<net_amount>[unknown type: string]</net_amount>
<vat_amount>[unknown type: string]</vat_amount>
<nominal_code>[unknown type: string]</nominal_code>
</line_data>
</SalesInvoice>
</pSalesInvoiceInput>
有人知道怎么解决这个问题吗?如果可能的话,我希望继续使用数组构建我的请求XML,因为它是在代码库的其他地方以这种方式完成的。修复了这个问题,事实证明PHP SOAP客户端已经预料到了这一点,并允许我们执行以下操作:
'line_data' => [
['description' => 'Test #1',
'net_amount' => '50.00',
'vat_amount' => '10.00',
'nominal_code' => '6110',
'glue_house_id' => $this->Houses->id],
['description' => 'Test #1',
'net_amount' => '50.00',
'vat_amount' => '10.00',
'nominal_code' => '6110',
'glue_house_id' => $this->Houses->id]
]
所以只要提供一个多维数组,SOAP客户机就会自动正确格式化它
'line_data' => [
['description' => 'Test #1',
'net_amount' => '50.00',
'vat_amount' => '10.00',
'nominal_code' => '6110',
'glue_house_id' => $this->Houses->id],
['description' => 'Test #1',
'net_amount' => '50.00',
'vat_amount' => '10.00',
'nominal_code' => '6110',
'glue_house_id' => $this->Houses->id]
]