This is a discussion on Is the xsi:type accessible from the returned SOAP object? within the PHP Language forums, part of the PHP Programming Forums category; This is just an example... I don't have the access/ability to upload the actual code. Here is the ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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- >GetVesselConfigurations(); call: <VesselConfigurations xmlns="http://thisUrl.com/Types"> <VehicleConfiguration xsi:type="CarConfig" Manufacturer="Porsche" Model="911" SerialNumber="1234567890-A" Color="red" /> <VehicleConfiguration xsi:type="TruckConfig" Manufacturer="Chevy" Model="S-10" SerialNumber="2345678901-B" Color="blue" /> <VehicleConfiguration xsi:type="SUVConfig" Manufacturer="Saturn" Model="Vue" SerialNumber="3456789012-C" Color="black" /> </VesselConfigurations> If I go through and print_r the object returned: $val = $client->GetVesselConfigurations(); print_r($val); 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- >VesselConfigurations->VehicleConfiguration[1][SerialNumber] belonged 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! -IBB |
|
|||
|
On Jun 11, 8:07*pm, oh.i.love.s...@gmail.com wrote:
> Why is it not possible to access the xsi:type (which is returned in > the XML) in the returned object [of function $client->GetVesselConfigurations()]? 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. |
|
|||
|
On Thu, 12 Jun 2008 11:44:19 +0200, Sjoerd <sjoerder@gmail.com> wrote:
> On Jun 11, 8:07*pm, oh.i.love.s...@gmail.com wrote: >> Why is it not possible to access the xsi:type (which is returned in >> the XML) in the returned object [of function >> $client->GetVesselConfigurations()]? > > 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. 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 manually. -- Rik Wasmus ....spamrun finished |