PHP SOAP - classmap - choice in complex type

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

 



Hi All,

I am a new bee to the PHP SOAP and have following problem. Any help is greatly appreciated. 

The WSDL file I am using has following complex type

<xs:element name="elemgreeting">
        <xs:complexType>
            <xs:choice>
                <xs:element name="greeting1" type="xs:string"/>
                <xs:element name="greeting2" type="xs:string"/>
                <xs:element name="greeting3" type="xs:string"/>
            </xs:choice>
        </xs:complexType>
</xs:element>

I am using PHP with SOAP extensions to handle server side operations. Using classmap feature I have created classmap for above complex type as 

class GreetingDataTypeMap
{
    public $greeting1;
    public $greeting2;
    public $greeting3;
}

This class is mapped properly to the elemtn and passed to the SOAP server. 

Function sayHello (its present in WSDL and added properly to SOAP server) returns greeting as 

function sayHello (NameDataType $n)
{
    $g = new GreetingDataTypeMap;
    $g->greeting2 = "greeting2";
    return $g;
} 

If this function sets any other greeting other than $greeting1 (i.e.greeting2 or greeting3) then that greeting is not being returned properly and SOAP message shows up as follows 

   <SOAP-ENV:Body>
      <ns1:elemgreeting>
         <greeting1/>
      </ns1:elemgreeting>
   </SOAP-ENV:Body> 

Ideally above function should return 
 
<SOAP-ENV:Body>
      <ns1:elemgreeting>
         <greeting2>greeting2</greeting2>
      </ns1:elemgreeting>
   </SOAP-ENV:Body> 
Can someone please point out what I am doing wrong in above classmap? 

Thanks in advance for your help

thanks,
rahul

       
---------------------------------
Park yourself in front of a world of choices in alternative vehicles.
Visit the Yahoo! Auto Green Center.

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

  Powered by Linux