Is the xsi:type accessible from the returned SOAP object?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
This is just an example... I don't have the access/ability to upload
the actual code.

Here is the meat in the XML that is returned from the $client-
Quoted text here. Click to load it
<VesselConfigurations xmlns=" ">
    <VehicleConfiguration xsi:type="CarConfig"
    Color="red" />
    <VehicleConfiguration xsi:type="TruckConfig"
    Color="blue" />
    <VehicleConfiguration xsi:type="SUVConfig"
    Color="black" />

If I go through and print_r the object returned:

$val = $client->GetVesselConfigurations();

I get this:
stdClass Object
    [VesselConfigurations] => stdClass Object
            [VehicleConfiguration] => Array
                    [0] => stdClass Object
                            [Manufacturer] => Porsche
                            [Model] => 911
                            [SerialNumber] => 1234567890-A
                            [Color] => red

                    [1] => stdClass Object
                            [Manufacturer] => Chevy
                [Model] => S-10
                [SerialNumber] => 2345678901-B
                            [Color] => blue

                    [2] => stdClass Object
                            [Manufacturer] => Saturn
                [Model] => Vue
                [SerialNumber] => 3456789012-C
                            [Color] => black

Why is it not possible to access the xsi:type (which is returned in
the XML) in the returned object?  Or am I missing something and just
don't know how to access it?  It obviously returns the xsi:type in the
XML that is returned.  The keys in the VehicleConfiguration array are
just numbers.  I don't see a way for me to check if the values in the
array belong to a certain type.  Like if I wanted to see if $val-
Quoted text here. Click to load it
to a CarConfig or a TruckConfig... I'm not seeing how that is
possible.  In ANY service (not just this one), is the xsi:type just
not accessible in the returned object?  Maybe they should have set it
up to where the type is listed in with the manufacturer, model, etc...
but with the way they have it setup now... I just don't see a way to
associate vehicle configurations with the corresponding xsi:type or
get that from the returned object.

Thanks for your time and any help you can lend!


Re: Is the xsi:type accessible from the returned SOAP object?

On Jun 11, 8:07=A0pm, wrote:
Quoted text here. Click to load it

Your function GetVesselConfigurations() does the converting from XML
to an object. Obviously, it does not do what you want as it does not
expose the type of the object. However, you don't give any information
on this function, so I can't tell how you can fix this. Please post
the code of the function.

Re: Is the xsi:type accessible from the returned SOAP object?

Quoted text here. Click to load it

It is most likely not a self defined function, but a SOAP function, i.e.  
most likely specified by wdsl, and the return of a SOAP::__call() is a  
tree of stdClass Objects unless specified otherwise.

@the op:
You can use a SOAPClient::__getTypes() to examine the types returned, and  
specifiy you own objects/classes to be used for those in the  
SOAP::__construct() statement (classmap). Possibly you can employ  
something there that uses the SimpleXML or DOM capabilities. Failing that,  
you could ofcourse use a SOAPClient::__getLastResponse() and parse that  
Rik Wasmus
...spamrun finished

Site Timeline