Page 1 of 1

SOAP polymorphism

Posted: Fri Apr 06, 2007 7:21 pm
by dantleech
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


hi

im trying to achieve polymorphism with the native PHP5 SOAP implementation.

Im using a PHP WSDL generator to generate the WSDL, it seems to produce valid output

Abstract class, bg_module
[syntax="xml"]
<xsd:complexType name="bg_module" abstract="true">
  <xsd:all>
    <xsd:element name="type" type="xsd:string"/>
  </xsd:all>
</xsd:complexType>
Concrete class, bg_reviews_test

Code: Select all

<xsd:complexType name="bg_reviews_test">
  <xsd:complexContent>
    <xsd:extension base="tns:bg_module">
      <sequence>
        <xsd:element name="title" type="xsd:string"/>
        <xsd:element name="type" type="xsd:string"/>
      </sequence>
    </xsd:extension>
  </xsd:complexContent>
</xsd:complexType
i call a method thorugh the webservice that returns an array of type bg_module. I only receive the parameters laid out in the abstract class when attempting to return the concrete bg_reviews_test.

The SOAP response returns the bg_reviews_test as the abstract bg_module type:

Code: Select all

<modules SOAP-ENC:arrayType="ns1:bg_module[1]" xsi:type="ns1:bg_moduleArray">
  <item xsi:type="ns1:bg_module">
    <type xsi:type="xsd:string">bg_reviews_test</type>
  </item>
</modules>
Surely the SOAP response should be typing the concrete class and not the abstract?

am i missing something fundamental here?

cheers

dan


feyd | Please use[/syntax]

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]