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

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 ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 06-11-2008
oh.i.love.spam@gmail.com
 
Posts: n/a
Default Is the xsi:type accessible from the returned SOAP object?

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
Reply With Quote
  #2 (permalink)  
Old 06-12-2008
Sjoerd
 
Posts: n/a
Default Re: Is the xsi:type accessible from the returned SOAP object?

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.
Reply With Quote
  #3 (permalink)  
Old 06-12-2008
Rik Wasmus
 
Posts: n/a
Default Re: Is the xsi:type accessible from the returned SOAP object?

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
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 09:48 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0