PHP soap调用来自函数的结果

问题描述

我有一个带有返回结果的函数的wsdl文件

<s:element name="RecordDataResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="RecordDataResult" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="message" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>

我尝试了此操作,但想出了一个无效的函数结果。.我只想从此函数获取

$response2 = $soapclient->RecordDataResponse()->RecordDataResult;

但出现此错误

Uncaught SoapFault exception: [Client] Function ("RecordDataResponse") is not a valid method for this service in ...

有什么提示吗?使用Windows PHP,我可以将数据放入..

解决方法

该函数名称实际上是ImportData1,并且属性RecordDataResult可能在响应中存在,也可能不存在。所以这里是:

$responseObject = $soapclient->ImportData1(/* put parameters here if any */);
if (isset($responseObject -> RecordDataResult)) 
{
    $response2 = $responseObject -> RecordDataResult;
}
else
{
    $response2 = 'N/A'; // For example
};