似乎 PHP 不能正确处理复杂的数组。使用 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();
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,
)),
),
))
我期望的是一个没有实际数据周围额外数组的数组。