PHP Web サービスで記述された Web メソッドを呼び出そうとすると、.NET プロジェクトで "SOAP-ERROR: Encoding: object has not 'first_name' property" エラー メッセージが表示されます。Web メソッドは PHP 配列を返します$result_data
。配列が返すフィールドの要素を WSDL に追加しました。私はPHPが初めてなので、返される配列の構造を取得できません。配列は 2 レベルのようです。
$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);
助けてください。