xml - SOAP PHP : Generating a complex array to pass to web service -


2 distinct problems.

i'm using php soap class pass xml webservice. can generate simple arrays fine, , these work webservice.

1.when try generate complex (arrays within arrays) query i'm getting errors.

2.also don't understand how insert parameter(???) xml tag.

below copy of sample xml query webservice documentation

<?xml version="1.0" encoding="utf-8"?> <soap:envelope xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:xsd="http://www.w3.org/2001/xmlschema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">   <soap:body>     <insertinvoice xmlns="kashflow">       <username>string</username>       <password>string</password>       <inv>         <invoicedbid>int</invoicedbid>         <invoicenumber>int</invoicenumber>         <invoicedate>datetime</invoicedate>         <duedate>datetime</duedate>         <customer>string</customer>         <customerid>int</customerid>         <paid>int</paid>         <customerreference>string</customerreference>         <estimatecategory>string</estimatecategory>         <suppresstotal>int</suppresstotal>         <projectid>int</projectid>         <currencycode>string</currencycode>         <exchangerate>decimal</exchangerate>         <readablestring>string</readablestring>         <lines>           <anytype />           <anytype />         </lines>         <netamount>decimal</netamount>         <vatamount>decimal</vatamount>         <amountpaid>decimal</amountpaid>         <customername>string</customername>       </inv>     </insertinvoice>   </soap:body> </soap:envelope> 

the problem occuring in <lines></lines> section of code.

with regards xml tag parameter... need produce :

<lines> <anytype xsi:type="invoiceline">  <quantity>1</quantity>  <description>description here</description>  <rate>99</rate>  <chargetype>0</chargetype>  <vatrate>0</vatrate>  <vatamount>0</vatamount>  <productid>0</productid>  <lineid>0</lineid>  </anytype> </lines> 

the bit having problems is

<anytype xsi:type="invoiceline"> 

namely inserting xsi:type="invoiceline" .....

here's php code i'm using.

    $invoice_array = array  ( 'invoicedbid' => "", 'invoicenumber' => 1, 'invoicedate' => date("c",strtotime($invoice_data['date_purchased'])), 'duedate' => date("c",strtotime($invoice_data['date_purchased'])), 'customer' => $invoice_data['customers_name'], 'customerid' => $kfcust->customerid, 'paid' => 0, 'customerreference' => "", 'estimatecategory' => "", 'suppresstotal' => 0, 'projectid' => 0, 'currencycode' => 0, 'exchangerate' => 1, 'netamount'=> 0, 'readablestring' =>"this invoice created osc order ".$invoice_data['orders_id']);  foreach($line_data $line) { $line_array[] = array( 'quantity'=>$line['products_quantity'], 'description'=>$line['products_name'], 'rate'=>$line['products_tax'], 'chargetype'=>0, 'vatamount'=>$totals_data['ot_tax']['value'], 'vatrate'=>$line['products_tax'], 'sort'=>1, 'productid'=>$line['products_id']); }  $invoice_array['lines']=array('anytype'=> array('_'=>$line_array, 'xsi:type'=>"invoiceline")); $invoice_array['netamount']=$totals_data['ot_subtotal']['value']+$totals_data['ot_shipping']['value']; $invoice_array['vatamount']=$totals_data['ot_tax']['value']; $invoice_array['amountpaid']=$totals_data['ot_total']['value']; $invoice_array['customername']=$invoice_data['customers_name'];  $invid = $client->createinvoice($invoice_array); 

sorry inquiry little muddled - can see, both of these problems go hand in hand.

**the actual error message received

unable cast object of type 'system.xml.xmlnode[]' type 'kashflow.invoiceline'. 

but indication submitting xml not in expected format.

can please?


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -