Domanda

I am trying to create the following element in my soup call

<Item xsi:type="Service">
    <ID>9910</ID>
</Item>

I have the following php code

class Service {
    private $ID;

    public function __construct($ID){
        $this->ID = $ID;
    }
}

$service = new Service(9910);
$param['Item'] = $service;

$soapItem->client->SoapFunction($param);

The XML that I am generating is

<Item/>

Obviously there are numerous other items in this soap call that are being formed correctly. This is the only item that is type cast. What am I doing wrong?

È stato utile?

Soluzione

This got the result I wanted

class Service {
    private $ID;

    public function __construct($ID){
        $this->ID = $ID;
    }
}

$service = new Service(9910);
$param['Item'] =  new SoapVar($service, SOAP_ENC_OBJECT, 'Service', 'http://name.space.com/');

$soapItem->client->SoapFunction($param);
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top