SOAP & anyType

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I'm having a problem with an API I'm attempting to interface with via SOAP.

The API is for an online accounting system and one of the functions is
to add a new invoice. One of the elements is an invoiceLine which is a
specific item on the invoice. This is defined like so:

<Lines>
<anyType />
<anyType />
</Lines>

The issue here is <anyType />. I am using nusoap (0.7.3) in WSDL mode
and it is unable translate the PHP array into an "anyType" object for
this particular API call. The structure of the <anyType /> element
needs to be like so, as I am told by their support rep:

<Lines>
<anyType xsi:type="InvoiceLine">
<Quantity>1</Quantity>
<Description>some Widgets</Description>
<Rate>10.00</Rate>
<ChargeType>12345</ChargeType>
<VatRate>17.5</VatRate>
<VatAmount>1.75</VatAmount>
<LineID>0</LineID>
</anyType>
<anyType xsi:type="InvoiceLine">
<Quantity>1</Quantity>
<Description>some other widgets</Description>
<Rate>10.00</Rate>
<ChargeType>12345</ChargeType>
<VatRate>17.5</VatRate>
<VatAmount>1.75</VatAmount>
<LineID>0</LineID>
</anyType>
</Lines>

I have tried using just a raw array in the call but that doesn't work
- I get an error - "Unable to cast object of type 'System.Array' to
type 'KashFlow.InvoiceLine'."

I have also tried to create a new soapval:

$lines[] = array('Quantity' => 2, 'Description' => 'Per Word', 'Rate'
=> 0.99, 'ChargeType' => 0);
$lines[] = array('Quantity' => 1, 'Description' => 'Base Fee', 'Rate'
=> 4.99, 'ChargeType' => 0);

foreach ($lines as $line)
{
$invoice_lines[] = new soapval('Line', 'KashFlow.InvoiceLine', $line);
}

$param['Inv'] = array('CustomerID' => $customer_id, 'NetAmount' =>
5.99, 'Description' => 'December 2007 Service Charges', 'Lines' =>
$invoice_lines);
$result = $client->call('InsertInvoice', array('parameters' => $param));

However this results in "Unable to cast object of type 'System.Object'
to type 'KashFlow.InvoiceLine'." with the actual request being:

<?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/";
xmlns:xsd="http://www.w3.org/2001/XMLSchema";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/";
xmlns:ns7975="http://tempuri.org";><SOAP-ENV:Body><InsertInvoice
xmlns="KashFlow"><UserName>attenalert</UserName><Password>78bn53526</Password><Inv><CustomerID>110088</CustomerID><Lines><anyType></anyType></Lines><NetAmount>5.99</NetAmount></Inv></InsertInvoice></SOAP-ENV:Body></SOAP-ENV:Envelope>

The specific function I am calling is documented at
https://secure.kashflow.co.uk/api/service.asmx?op=InsertInvoice

Can anyone advise on what I'm doing wrong here please? I have tried
posting in the NuSoap mailing list but have had no response.
-- 
David Mytton
www.mytton.net

-- 
PHP Soap Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Kernel Newbies]     [PHP Database]     [Yosemite]

  Powered by Linux