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

Re: SOAP & anyType

Assuming anyType element is of type XSD Any in the WSDL, it is quite impossible to convert PHP data to the required XML format because any type basically means that it can have any XML format.

You may have to manually formulate the XML request I suppose.

You can easily do this with WSF/PHP.


David Mytton wrote:

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:

<anyType />
<anyType />

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:

<anyType xsi:type="InvoiceLine">
<Description>some Widgets</Description>
<anyType xsi:type="InvoiceLine">
<Description>some other widgets</Description>

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' =>
$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

The specific function I am calling is documented at

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.

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

[PHP Home]     [PHP Users]     [Kernel Newbies]     [PHP Database]     [Yosemite]

  Powered by Linux