Su Gin
Su Gin

Reputation: 11

php soap: how to get it to generate <soap:Envelope instead of <SOAP-ENV:Envelope?

I'm new at this, and have been poring through forums trying to figure out how to use PHP's soap.

I'm going to pull my hair out soon!

spend a gazillion years trying to figure out how to generate this header.

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

ended up using this:

$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);

it keeps generating the 'ns' like this -> when i use this method.

<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); 

now i need to get it to change from <soap:Envelope to <SOAP-ENV:Envelope . Help!

Upvotes: 0

Views: 210

Answers (1)

Umesh Chavan
Umesh Chavan

Reputation: 614

class 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);

Hope this will resolve your problem

Upvotes: 1

Related Questions