我使用PHP ()来使用SoapClient服务。
$sc = new SoapClient($uri);
$sc->MyAction($params);$params将是一个数组,用于创建下面的OrderLine,但我不确定如何格式化有多个OrderLine键的数组。
<args>
<OrderLines>
<OrderLine>
<LineNumber>1</LineNumber>
<Product>Acme Foos</Product>
<Description>Bars and Bazzes</Description>
<Quantity>1</Quantity>
<Price>5.00</Price>
</OrderLine>
<OrderLine>
<LineNumber>2</LineNumber>
<Product>Kittens</Product>
<Description>Very sleepy</Description>
<Quantity>1</Quantity>
<Price>12.00</Price>
</OrderLine>
</OrderLines>
</args>这是我要发送的数组格式的转储,但没有成功,因为我不知道如何使用多个OrderLine键来生成数组。
[args] => Array
(
[OrderLines] => Array
(
[0] => Array
(
[LineNumber] => 1
[Product] => 'Acme Foos'
[Description] => 'Bars and Bazzes'
[Quantity] => 1
[Price] => 5.00
)
[1] => Array
(
[LineNumber] => 2
[Product] => 'Kittens'
[Description] => 'Very sleepy'
[Quantity] => 1
[Price] => 12.00
)
)
)当将它发送到web服务时,我将得到以下SoapFault异常:
服务器无法读取请求。-> XML文档(2,1001)中有一个错误。-输入字符串格式不正确。
发布于 2012-03-12 22:31:01
这个例子是正确的。错误与数组无关。这是我的对词中的其他一些无效的数据。
https://stackoverflow.com/questions/9668837
复制相似问题