It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

Sending Multidimensional Array using php

Sending Multidimensional Array using php

Postby gilbertsavier on Wed Aug 19, 2009 12:53 pm

Hi,
For anybody facing troubles with sending complex array to KF webservice, this might help.
After considerable hairpulling i managed to solve the riddle.
This is for the function InsertInvoice. Note: you have to provide explicit type for <anytype> element.
You are free to thank me anytime
<?
require_once('nusoap.php');
//$client = new soapclient('https://secure.kashflow.co.uk/api/service.asmx?WSDL','wsdl');
$soapaction = "KashFlow/InsertInvoice";
$wsdl = "https://secure.kashflow.co.uk/api/service.asmx";
$namespace = "KashFlow";
$client = new soapclient($wsdl);
$mysoapmsg = $client->serializeEnvelope('
<InsertInvoice xmlns="KashFlow"><UserName>yourusername</UserName><Password>yourpassword</Password><Inv><InvoiceDate>2009-01-20T11:11:04+00:00</InvoiceDate><DueDate>2009-01-20T11:11:04+00:00</DueDate><CustomerID>525434</CustomerID><Lines><anyType xsi:type="InvoiceLine"><Quantity>150</Quantity><Description>Bindaas baby</Description><Rate>30</Rate><ChargeType>812270</ChargeType><VatRate>21</VatRate></anyType></Lines></Inv></InsertInvoice>
','',array(),'document', 'literal');

$response = $client->send($mysoapmsg, $soapaction);

if ($client->fault) {
echo '<h3>Fault</h3><pre>';
print_r($response);
echo '</pre>';
}

echo "<p>SOAP query</p>";
echo '<pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>';
echo "<p>SOAP response</p>";
echo '<pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>';
?>
gilbertsavier
 
Posts: 24
Joined: Fri Jun 26, 2009 11:34 am

Who is online

Users browsing this forum: No registered users and 9 guests