2012-06-18 44 views
0

我對此很感興趣,並且一直在努力研究如何使用PHP的肥皂。php soap:如何讓它生成<soap:Envelope而不是<SOAP-ENV:Envelope?

我即將把我的頭髮拉出來!

花了數年時間試圖弄清楚如何生成這個頭文件。

<AutenticationToken> 
     <Username>admin</Username> 
     <Password>123456</Password> 
    </AutenticationToken> 

結束了使用這樣的:

$sh_param = "<AutenticationToken><Username>admin</Username><Password>123456</Password></AutenticationToken>"; 
$auth = new SoapVar($sh_param, XSD_ANYXML, null, null, null); 
$headers = new SoapHeader($wdsl, 'AuthenticationToken', $auth); 

它不斷生成 'NS' 這樣的 - >當我使用此方法。

<ns2:AuthenticationToken> 
    <item> 
    <key>Username</key> 
    <value>admin</value> 
    </item> 
    <item> 
    <key>Password</key> 
    <value>123456</value> 
    </item> 
</ns2:AuthenticationToken> 


$sh_param = array( 
        'Username' => 'admin', 
        'Password' => '123456'); 
$headers = new SoapHeader($wsdl, 'AuthenticationToken', $sh_param); 

現在我需要把它改變從<soap:Envelope<SOAP-ENV:Envelope。 幫助!

回答

1

類SOAPStruct

{

function __construct($user, $pass) 
{ 
    $this->Username = $user; 
    $this->Password = $pass; 
} 

}

//set username and password 
$auth = new SOAPStruct("admin","123456"); 

//soap header object 
$header = new SoapHeader("http://gateway.asiagategroup.com/","AutenticationToken",$auth,false); 
$client->__setSoapHeaders($header); 

希望這將解決您的問題

相關問題