views:

24

answers:

1

Here's the code I'm using to generate the request headers:

$headers = array(
                  new SOAPHEADER($this->_ns,'username',$this->_username,false, $this->_actor),
                  new SOAPHEADER($this->_ns,'password',$this->_password,false, $this->_actor));

$this->_client->__setSOAPHeaders($headers);

This generates:

<SOAP-ENV:Header>
  <ns2:username SOAP-ENV:actor="http://schemas.xmlsoap.org/soap/actor/next"&gt;test&lt;/ns2:username&gt;
  <ns2:password SOAP-ENV:actor="http://schemas.xmlsoap.org/soap/actor/next"&gt;test&lt;/ns2:password&gt;
</SOAP-ENV:Header>

That's all fine and dandy.

Here are my two questions:

The API doc requires that username be ns1:username and password be ns2:password. Mine are both ns2. First of all, what is the significance of the ns1|2? How can I fix this?

Second question is just is there a way to generate the same result by only calling SOAPHEADER() once?

A: 
  1. Not easy to say whether the namespace makes a difference without seeing the declaration & knowing the service, but usually the receiving service looks only for the tags in that particular namespace. As you add $this->_ns to both of them, of course they'll be the same. You'll have to provide the proper namespace yourself (prefix doesn't matter, uri does).
  2. Why would you want only 1 call?
Wrikken
I posted the url to the WSDL which should answer #1. For #2, I was just wondering due to my lack of familiarity with the PHP SOAP lib if I was setting the headers as efficiently.
Joshua McGinnis
Wrikken
Just for sh*ts and giggles, how would I get the username to be ns1?
Joshua McGinnis
Wrikken