From: Vidyut Luther on
Hello,
I think I just need a fresh pair of eyes looking at this.

Goal: Talk to the Yahoo EWS Sandbox and make it add a campaign.
Problem: The headers don't seem to be correctly formed down the wire.


The EWS API says I need to send the following as part of the soap headers.
<code>
$header = array(
"username" => "myusername",
"password" => "mypassword",
"masterAccountID" => "12345689",
"accountID" => "789654321",
"license" => "one-somewhat-lengthy-string"
);

function createHeaders($headerArray)
{

$headers = array();
$attribs = array();
$attribs = array(
'namespace' => EWS_NAMESPACE);
foreach($headerArray as $aHeaderName => $aHeaderValue)
{
debug("Creating $aHeaderName header -> $aHeaderValue");

$aHeader = new SOAP_Header(
$aHeaderName,NULL,
$aHeaderValue
);

array_push($headers,$aHeader);
}

return $headers;
}



$client = new
SOAP_Client("https://sandbox.marketing.ews.yahooapis.com/services/V1/LocationService?wsdl",true);

$soapHeaders = createHeaders($header);
$client->addHeader($soapHeaders);

$params = array();
$options = array('trace' => 1);

$response = $client->call("getMasterAccountLocation",$params,$options);
</code>


When I try to view the response, I get a SOAP Error:

[message] => Missing Header: username, password, master account, or license.


When I try to see what was in the wire going out, I see the following:


POST / HTTP/1.0
User-Agent: PEAR-SOAP 0.8.0RC4-devel
Host: Use_Address_Returned_By_Location_Service
Content-Type: text/xml; charset=UTF-8
Content-Length: 1113
SOAPAction: ""

<?xml version="1.0" encoding="UTF-8"?>

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns4="http://marketing.ews.yahooapis.com/V1"
>
<SOAP-ENV:Header>

<Object SOAP-ENV:actor="Object" SOAP-ENV:mustUnderstand="1">
<password SOAP-ENV:actor="http://schemas.xmlsoap.org/soap/actor/next" SOAP-ENV:mustUnderstand="0">mypassword</password></Object>
</SOAP-ENV:Header>
<SOAP-ENV:Body>


As you can see, only the password is being sent as part of the header, and even that seems to not work.

I have tried doing this using PHP 5's Soap Extension and everything works, but I need to use Pear::Soap and PHP 4, as upgrading to PHP 5 is not an option.

I'm pretty sure i'm just tired and missing something glaringly obvious, I need another pair of eyes probably.
Thanks.