2014-05-13 2 views
0

nusoap을 사용하여 .net 비누 서비스의 스텁 서버를 PHP로 만들려고합니다. PHP 코드에서 헤더를 인증 할 수 없습니다. 샘플 XML은PHP의 nusoap 서버에서 비누 헤더를 인증하는 방법은 무엇입니까?

<?xml version="1.0" encoding="utf-8"?> 
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 
    <soap:Header> 
    <AuthenticationHeader xmlns="http://tempuri.org/"> 
     <UserName>string</UserName> 
     <Password>string</Password> 
    </AuthenticationHeader> 
    </soap:Header> 
    <soap:Body> 
    <getUserPackDetails xmlns="http://tempuri.org/" /> 
    </soap:Body> 
</soap:Envelope> 

내가 복잡한 형식으로 SOAP 헤더를 구문 분석해야 또는 어떤 다른 방법이 무엇입니까?

답변

0

비누 헤더의 경우 nusoap에서 어떤 함수도 찾을 수 없었지만 PHP가 내용을 받아서 헤더를 인증 할 수있었습니다.

function doAuthenticate() 
{ 
    $sSoapRequest = file_get_contents('php://input'); 
    if(isset($sSoapRequest)) 
    { 
     $sUsername = hookTextBetweenTags($sSoapRequest, 'Username'); 
     $sPassword = hookTextBetweenTags($sSoapRequest, 'Password'); 
     if($sUsername=='testuser' && $sPassword=='test12345') 
      return true; 
     else 
      return false; 
    } 
} 
function hookTextBetweenTags($string, $tagname) { 
    $pattern = "/<$tagname ?.*>(.*)<\/$tagname>/"; 
    preg_match($pattern, $string, $matches); 
    return $matches[1]; 
}