当我尝试调用用 PHP Web 服务编写的 Web 方法时,我在 .NET 项目中收到“SOAP-ERROR: Encoding: object has not 'first_name' property”错误消息。Web 方法返回一个 PHP 数组$result_data
。我在 WSDL 中为数组返回的字段添加了元素。由于我是 PHP 新手,因此无法获取返回数组的结构。该数组似乎是两级的。
$result_data => array(array( "first_name"
"last_name")
array( "first_name"
"last_name")
array( "first_name"
"last_name")
)
这是我的 WSDL:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:tns="http://10.20.1.161/api/soap/"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
targetNamespace="http://10.20.1.161/api/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<s:schema targetNamespace="http://10.20.1.161/api/soap/" elementFormDefault="qualified">
<s:import namespace="http://microsoft.com/wsdl/types/"/>
<s:element name="getUsers">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="message" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="getUsersResponse">
<s:complexType>
<s:sequence>
<s:element name="getUsersArray" type="tns:getUsersArray"/>
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="getUsersArray">
<s:sequence>
<s:element minOccurs="0" maxOccurs="unbounded" name="User" nillable="true" type="tns:User" />
</s:sequence>
</s:complexType>
<s:complexType name="User">
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="first_name" type="s:string"/>
<s:element minOccurs="1" maxOccurs="1" name="last_name" type="s:string"/>
<s:element minOccurs="1" maxOccurs="1" name="regular_time" type="s:string"/>
<s:element minOccurs="1" maxOccurs="1" name="regular_time_wage" type="s:string"/>
<s:element minOccurs="1" maxOccurs="1" name="regular_time_wage_with_burden" type="s:string"/>
<s:element minOccurs="1" maxOccurs="1" name="regular_time_hourly_rate" type="s:string"/>
<s:element minOccurs="1" maxOccurs="1" name="regular_time_hourly_rate_with_burden" type="s:string"/>
<s:element minOccurs="1" maxOccurs="1" name="gross_wage" type="s:string"/>
<s:element minOccurs="1" maxOccurs="1" name="gross_wage_with_burden" type="s:string"/>
<s:element minOccurs="1" maxOccurs="1" name="worked_time" type="s:string"/>
<s:element minOccurs="1" maxOccurs="1" name="worked_days" type="s:string"/>
<s:element minOccurs="1" maxOccurs="1" name="verified_time_sheet" type="s:string"/>
<s:element minOccurs="1" maxOccurs="1" name="verified_time_sheet_date" type="s:string"/>
<!-- <s:element minOccurs="1" maxOccurs="1" name="absence_policy-3" type="s:string"/>
<s:element minOccurs="1" maxOccurs="1" name="absence_policy-3_wage" type="s:string"/>
<s:element minOccurs="1" maxOccurs="1" name="absence_policy-3_wage_with_burden" type="s:string"/>
<s:element minOccurs="1" maxOccurs="1" name="absence_policy-3_hourly_rate" type="s:string"/>
<s:element minOccurs="1" maxOccurs="1" name="absence_policy-3_hourly_rate_with_burden" type="s:string"/>-->
</s:sequence>
</s:complexType>
</s:schema>
</wsdl:types>
<wsdl:message name="getUsersSoapIn">
<wsdl:part name="parameters" element="tns:getUsers"/>
</wsdl:message>
<wsdl:message name="getUsersSoapOut">
<wsdl:part name="parameters" element="tns:getUsersResponse"/>
</wsdl:message>
<wsdl:portType name="TestSoap">
<wsdl:operation name="getUsers">
<wsdl:documentation xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'>
Function ("getUsers")
</wsdl:documentation>
<wsdl:input message="tns:getUsersSoapIn"/>
<wsdl:output message="tns:getUsersSoapOut"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:portType name="TestSoap12">
<wsdl:operation name="getUsers">
<wsdl:documentation xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'>
Function ("getUsers")
</wsdl:documentation>
<wsdl:input message="tns:getUsersSoapIn"/>
<wsdl:output message="tns:getUsersSoapOut"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="TestSoap" type="tns:TestSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getUsers">
<soap:operation soapAction="http://10.20.1.161/api/soap/getUsers" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="TestSoap12" type="tns:TestSoap12">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getUsers">
<soap12:operation soapAction="http://test-uri/soap/export/getUsers" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="TestService">
<wsdl:port name="TestPort" binding="tns:TestSoap">
<soap:address location="http://10.20.1.161/api/soap/server.php"/>
</wsdl:port>
<wsdl:port name="TestSoap12" binding="tns:TestSoap12">
<soap12:address location="http://10.20.1.161/api/soap/server.php"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
我的返回代码部分。
$getUsersArray = $result->getResultData();
return array("getUsersArray" => $getUsersArray);
请帮忙。