Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Seems PHP does not handle complex array properly. Using PHP 5.

WSDL

<?xml version="1.0"?>
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
    xmlns:tns="urn:CostQueryServicewsdl" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" name="CostQueryService"
    targetNamespace="urn:CostQueryServicewsdl">
    <wsdl:types xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
        <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            targetNamespace="urn:CostQueryServicewsdl">
            <xsd:complexType name="WsdService_QueryCostParams">
                <xsd:all>
                    <xsd:element name="date_from" type="xsd:string" />
                    <xsd:element name="date_to" type="xsd:string" />
                    <xsd:element name="hotel_id_array" type="soap-enc:Array" />
                </xsd:all>
            </xsd:complexType>
            <xsd:complexType name="WsdService_CostHotelArray">
                <xsd:sequence>
                    <xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                        name="WsdService_CostHotel" type="tns:WsdService_CostHotel"
                        minOccurs="0" maxOccurs="unbounded" />
                </xsd:sequence>
            </xsd:complexType>
            <xsd:complexType name="WsdService_CostHotel">
                <xsd:all>
                    <xsd:element name="id" type="xsd:string" />
                    <xsd:element name="reserv_policy" type="xsd:string" />
                    <xsd:element name="cancel_policy" type="xsd:string" />
                    <xsd:element name="category_array"
                        type="tns:WsdService_CostHotelCategoryArray" />
                    <xsd:element name="btype_value" type="xsd:string" />
                </xsd:all>
            </xsd:complexType>
            <xsd:complexType name="WsdService_CostHotelCategoryArray">
                <xsd:sequence>
                    <xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                        name="WsdService_CostHotelCategory" type="tns:WsdService_CostHotelCategory"
                        minOccurs="0" maxOccurs="unbounded" />
                </xsd:sequence>
            </xsd:complexType>
            <xsd:complexType name="WsdService_CostHotelCategory">
                <xsd:all>
                    <xsd:element name="value" type="xsd:string" />
                    <xsd:element name="name" type="xsd:string" />
                </xsd:all>
            </xsd:complexType>
        </xsd:schema>
    </wsdl:types>
    <wsdl:message xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
        name="queryCostRowsRequest">
        <wsdl:part name="params" type="tns:WsdService_QueryCostParams" />
    </wsdl:message>
    <wsdl:message xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
        name="queryCostRowsResponse">
        <wsdl:part name="return" type="tns:WsdService_CostHotelArray" />
    </wsdl:message>
    <wsdl:message xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
        name="testEchoRequest">
        <wsdl:part name="value" type="xsd:string" />
    </wsdl:message>
    <wsdl:message xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
        name="testEchoResponse">
        <wsdl:part name="return" type="xsd:string" />
    </wsdl:message>
    <wsdl:portType xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
        name="CostQueryServicePortType">
        <wsdl:operation name="queryCostRows">
            <wsdl:documentation></wsdl:documentation>
            <wsdl:input message="tns:queryCostRowsRequest" />
            <wsdl:output message="tns:queryCostRowsResponse" />
        </wsdl:operation>
        <wsdl:operation name="testEcho">
            <wsdl:documentation></wsdl:documentation>
            <wsdl:input message="tns:testEchoRequest" />
            <wsdl:output message="tns:testEchoResponse" />
        </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
        name="CostQueryServiceBinding" type="tns:CostQueryServicePortType">
        <soap:binding xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
            style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
        <wsdl:operation name="queryCostRows">
            <soap:operation xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
                soapAction="urn:CostQueryServicewsdl#queryCostRows" style="rpc" />
            <wsdl:input xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
                <soap:body xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
                    use="encoded" namespace="urn:CostQueryServicewsdl" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
            </wsdl:input>
            <wsdl:output xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
                <soap:body xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
                    use="encoded" namespace="urn:CostQueryServicewsdl" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
            </wsdl:output>
        </wsdl:operation>
        <wsdl:operation name="testEcho">
            <soap:operation xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
                soapAction="urn:CostQueryServicewsdl#testEcho" style="rpc" />
            <wsdl:input xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
                <soap:body xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
                    use="encoded" namespace="urn:CostQueryServicewsdl" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
            </wsdl:input>
            <wsdl:output xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
                <soap:body xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
                    use="encoded" namespace="urn:CostQueryServicewsdl" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:service xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
        name="CostQueryServiceService">
        <wsdl:port xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
            name="CostQueryServicePort" binding="tns:CostQueryServiceBinding">
            <soap:address xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
                location="http://hs.localhost:8080/wsd_server/service.php?CostQueryService" />
        </wsdl:port>
    </wsdl:service>
</definitions>

PHP

$options['classmap'] = array('WsdService_QueryCostParams'=>'WsdService_QueryCostParams', 'WsdService_CostHotel'=>'WsdService_CostHotel');
$server = new SoapServer($url . "?" . $classname.'.wsdl', $options);
$server->setClass($classname);
$server->handle();

Output dump of SoapClient

stdClass::__set_state(array(
    'WsdService_CostHotel' => 
    array (
    0 => 
    WsdService_CostHotel::__set_state(array(
       'id' => 'HKG001',
       'day_cell_array' => 
      array (
      ),
       'reserv_policy' => NULL,
       'cancel_policy' => NULL,
       'category_array' => 
      stdClass::__set_state(array(
      )),
       'btype_value' => NULL,
    )),
    1 => 
    WsdService_CostHotel::__set_state(array(
       'id' => 'HKG002',
       'day_cell_array' => 
      array (
      ),
       'reserv_policy' => NULL,
       'cancel_policy' => NULL,
       'category_array' => 
      stdClass::__set_state(array(
         'WsdService_CostHotelCategory' => 
        stdClass::__set_state(array(
           'value' => 'STANDARD',
           'name' => 'Standard',
        )),
      )),
       'btype_value' => NULL,
    )),
  ),
))

What I would expect is an array without the extra array around the actural data.

share|improve this question

closed as unclear what you're asking by pduersteler, Tomasz Kowalczyk, greg-449, Nathan Hughes, Yannick Blondeau Nov 12 '13 at 16:35

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

    
Please state your question. –  Sébastien Nov 12 '13 at 13:13

Browse other questions tagged or ask your own question.