Php 如何从soap:header获取SessionID?

Php 如何从soap:header获取SessionID?,php,xml,soap,Php,Xml,Soap,我得到一个soap xml响应,我需要SessionID。我试图使用SimpleXml\u load\u字符串,但得到了一个空对象。有人知道如何获取会话ID吗 这是xml响应: <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema

我得到一个soap xml响应,我需要SessionID。我试图使用SimpleXml\u load\u字符串,但得到了一个空对象。有人知道如何获取会话ID吗

这是xml响应:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Header>
    <Header xmlns="http://www.twinfield.com/">
        <SessionID>ca363c52-c12f-4988-b06a-e0c41788e254</SessionID>
    </Header>
</soap:Header>
<soap:Body>
    <LogonResponse xmlns="http://www.twinfield.com/">
        <LogonResult>Ok</LogonResult>
        <nextAction>None</nextAction>
        <cluster>https://c3.twinfield.com</cluster>
    </LogonResponse>
</soap:Body>
</soap:Envelope>

ca363c52-c12f-4988-b06a-e0c41788e254
好啊
没有一个
https://c3.twinfield.com

我在这里发现了一些有用的东西。请阅读以下内容:


我在这里发现了一些有用的东西。请阅读以下内容:

及 尝试使用。这是一种方式:

$s = '<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Header>
    <Header xmlns="http://www.twinfield.com/">
        <SessionID>ca363c52-c12f-4988-b06a-e0c41788e254</SessionID>
    </Header>
</soap:Header>
<soap:Body>
    <LogonResponse xmlns="http://www.twinfield.com/">
        <LogonResult>Ok</LogonResult>
        <nextAction>None</nextAction>
        <cluster>https://c3.twinfield.com</cluster>
    </LogonResponse>
</soap:Body>
</soap:Envelope>';

$doc   = new DOMDocument();
$doc->loadXML( $s );
echo $doc->getElementsByTagName('SessionID')->item(0)->nodeValue;
$s='1!'
ca363c52-c12f-4988-b06a-e0c41788e254
好啊
没有一个
https://c3.twinfield.com
';
$doc=新的DOMDocument();
$doc->loadXML($s);
echo$doc->getElementsByTagName('SessionID')->item(0)->nodeValue;
尝试使用。这是一种方式:

$s = '<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Header>
    <Header xmlns="http://www.twinfield.com/">
        <SessionID>ca363c52-c12f-4988-b06a-e0c41788e254</SessionID>
    </Header>
</soap:Header>
<soap:Body>
    <LogonResponse xmlns="http://www.twinfield.com/">
        <LogonResult>Ok</LogonResult>
        <nextAction>None</nextAction>
        <cluster>https://c3.twinfield.com</cluster>
    </LogonResponse>
</soap:Body>
</soap:Envelope>';

$doc   = new DOMDocument();
$doc->loadXML( $s );
echo $doc->getElementsByTagName('SessionID')->item(0)->nodeValue;
$s='1!'
ca363c52-c12f-4988-b06a-e0c41788e254
好啊
没有一个
https://c3.twinfield.com
';
$doc=新的DOMDocument();
$doc->loadXML($s);
echo$doc->getElementsByTagName('SessionID')->item(0)->nodeValue;