1
我正在嘗試調用.NET項目時遇到「SOAP錯誤:編碼:對象沒有'first_name'屬性」錯誤消息用PHP Web服務編寫的Web方法。該web方法返回一個PHP數組$result_data
。我已經在WSDL中爲數組返回的字段添加了元素。由於我是PHP新手,無法獲得返回數組的結構。該陣列似乎是兩個級別。SOAP-ERROR:編碼:對象沒有'first_name'屬性
$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);
請幫忙。
你有任何解決方案...... !! –