SOAP serialization of PHP classes

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

 



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

 

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



[Index of Archives]     [PHP Home]     [PHP Users]     [Kernel Newbies]     [PHP Database]     [Yosemite]

  Powered by Linux