2012-03-12 36 views
0

我正在使用PHP SoapClient()来使用Web服务。

$sc = new SoapClient($uri); 
$sc->MyAction($params); 

$ PARAMS将是一个数组创建下面的XML,但我不知道该如何在有多个订单行键的排列格式。

<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> 

这是阵列格式我送的转储,失败是因为我不知道如何使多个订单行键阵列。

[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)中存在错误。 --->输入字符串格式不正确。

+0

我可以理解你不确定。但是,如果您概述了迄今为止所做的工作(以及如何解决问题),那么回答您的问题将更容易。 – hakre 2012-03-12 14:25:04

+0

好的,我更新了我正在提交的内容以及SoapFault异常错误字符串。 – Coder1 2012-03-12 19:10:25

回答

0

这个例子是正确的。该错误与数组无关。这是我的一些其他无效数据。