【问题标题】:SoapClient parse responseSoapClient 解析响应
【发布时间】:2012-08-04 08:39:30
【问题描述】:

我需要解析该响应来自:

$client->__getLastResponse();

uuid:9e0096e0-de0f-11e1-8035-e656d1754971

http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous 0 ContentType text/xml 1 
Result 200 2 XMLDocumentOut <?xml version="1.0" encoding="utf-8" ?> 
<DtsAgencyLoginResponse xmlns="DTS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="DTS file:///R:/xsd/DtsAgencyLoginMessage_01.xsd">
<SessionInfo><SessionID>178827</SessionID><Profile>A</Profile><Language>ENG</Language>
<Version>1</Version>
</SessionInfo><AdvisoryInfo/></DtsAgencyLoginResponse>

如何解析它以获取 SessionID ?谢谢!

编辑:

方法$client-&gt;method($parameter)的结果是:

stdClass Object ( [result] => [ttOut] => stdClass Object ( [ttOutRow] => Array ( [0] => stdClass Object ( [ParPos] => 0 [ParNam] => ContentType [ParVal] => text/xml ) [1] => stdClass Object ( [ParPos] => 1 [ParNam] => Result [ParVal] => 200 ) [2] => stdClass Object ( [ParPos] => 2 [ParNam] => XMLDocumentOut [ParVal] => 178880AENG1 ) ) ) [opcErrorMessage] => )

【问题讨论】:

    标签: php xml soap response


    【解决方案1】:

    当通过 PHP5 SOAPClient 调用 SOAP 方法时,您总是会得到响应。也就是说,可能不需要调用 __getLastResponse() 来检索 SessionID 值。请看以下内容:

    $response = $client->myMethod();
    $sessionID = $response->SessionInfo->SessionID;
    

    还有http://www.php.net/manual/en/soapclient.soapcall.php

    【讨论】:

    • 我试试这个:$return = $client->wssigateway($pars); $sessionID = $return->SessionInfo->SessionID;回声 $sessionID;但没有打印任何内容..
    • 似乎是接收到的 xml 的问题。仔细研究__getLastResponse的结果:下面的代码应该是其中的一部分:http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous 0 ContentType text/xml 1Result 200 2 XMLDocumentOut
    • 请原谅我,但我不明白..你能解释得更好吗?
    • 那是我的错误..我会关闭这个答案..我问另一个答案..请看stackoverflow.com/questions/11807625/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-17
    • 1970-01-01
    • 1970-01-01
    • 2020-04-22
    相关资源
    最近更新 更多