SOAP serialization of PHP classes
| From: | Smith, Corbin | Date: | Tue, 17 May 2005 18:55:49 +0000 |
| Subject: | SOAP serialization of PHP classes | ||
| Groups: | php.soap | ||
| Request: | Send a blank email to php-soap+get-1915@lists.php.net to get a copy of this message | ||
Greetings,
I am moderately new to SOAP, but catching up fast.
To drop right down to my question,
I've got slightly tortuous issue dealing with creating a soap request.
I'd like to drop user-defined PHP classes in the soap client and have
some control over the XML serialization:
class InventoryRequestDocument {
private $Line = array();
private $Catalog = '4353666234';
public function __construct(){
$this->Line[] = new Line();
$this->Line[] = new Line();
}
}
class Line{
public $LineNumber = 1;
public $ItemNumber = 7005298;
}
Which happily serializes to:
<?xml version="1.0"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<InventoryRequestDocument>
<Line>
<item>
<LineNumber>1</LineNumber>
<ItemNumber>7005298</ItemNumber>
</item>
<item>
<LineNumber>1</LineNumber>
<ItemNumber>7005298</ItemNumber>
</item>
</Line>
<Catalog>4353666234</Catalog>
</InventoryRequestDocument>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
What I'd like is this:
<?xml version="1.0"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<InventoryRequestDocument>
<Line>
<LineNumber>1</LineNumber>
<ItemNumber>7005298</ItemNumber>
</Line>
<Line>
<LineNumber>1</LineNumber>
<ItemNumber>7005298</ItemNumber>
</Line>
<Catalog>4353666234</Catalog>
</InventoryRequestDocument>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Can this be done with the PHP soapclient?
Do I need to do this in WSDL (if so, how do I force the encoding)?
I'm using 5.0.3, and discovered the classmap option only seems to apply
to responses.
Thanks,
Cory
---
Corbin Smith
Principal Software Engineer
www.Gateway.com
+1-949-471-7803 Desk
+1-323-908-3432 Cell