如何在PHP中获得值SOAP响应?

时间:2013-05-25 09:10:41

标签: php soap wsdl

请帮助我们......我正在努力解决这个问题..

问题 如何从此获得FirstName值... 用PHP

GetReportResponse Object
(
[GetReportResult] => MBPeopleSearchRs_Type Object
    (
        [MsgRsHdr] => MsgRsHdr_Type Object
            (
                [RqUID] => {29B1A627-D908-4A57-BC17-8E2592DC154A}
                [Status] => Status_Type Object
                    (
                        [StatusCode] => 0
                        [ServerStatusCode] => 
                        [Severity] => Info
                        [StatusDesc] => OK
                        [AdditionalStatus] => 
                    )

            )

        [Subject] => Subject Object
            (
                [RefNum] => 
                [PersonInfo] => PersonInfo_Type Object
                    (
                        [PersonName] => PersonName_Type Object
                            (
                                [LastName] => JANARDHANAN
                                [FirstName] => SENTHINBABU
                                [FullName] => 
                                [MiddleName] => 
                                [TitlePrefix] => 
                                [NameSuffix] =>  
                                [Nickname] => 
                                [LegalName] => 
                                [MaidenName] => 
                                [OfficialTitle] => 
                                [Source] => MB
                                [EffDt] => 2013-05-24
                            )

2 个答案:

答案 0 :(得分:0)

你可以试试这个:

$xml = simplexml_load_string($response);
foreach ($xml->xpath('//GetReportResult//Subject//PersonInfo//PersonName//FirstName') as $item)
{
    var_dump($item);

}

其中$ response是对wsdl中函数的调用。

答案 1 :(得分:0)

function getFirstName(GetReportResponse $response) {
    return $response->GetReportResult->Subject->PersonInfo->PersonName->FirstName;
}

现在您可以按如下方式使用此功能:

$firstName = getFirstName($response); // $response var here represents your response object