bad header?

4 views
Skip to first unread message

Jcyr

unread,
Apr 28, 2007, 12:05:34 PM4/28/07
to AdSense API Forum
I am stumped on getting the header seen by the api. I am all new to
SOAP, so I am sure it is something silly.

The error I get is that the header developer_email wasn't found.

It is difficult to know exactly what google got, so I tested with a
local echo service and this is the sample header that would be sent.

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/
envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<soapenv:Header>

<developer_email soapenv:actor="" soapenv:mustUnderstand="0"
xmlns="https://sandbox.google.com/api/adsense/v2" xmlns:ns1="https://
sandbox.google.com/api/adsense/v2">sandboxd...@google.com</
developer_email>

<developer_password soapenv:actor="" soapenv:mustUnderstand="0"
xmlns="https://sandbox.google.com/api/adsense/v2" xmlns:ns2="https://
sandbox.google.com/api/adsense/v2">devpass</developer_password>

</soapenv:Header>

<soapenv:Body><ns3:echo_me soapenv:encodingStyle="http://
schemas.xmlsoap.org/soap/encoding/" xmlns:ns3="http://
googleapi"><in_here xsi:type="xsd:string">hello world</in_here></
ns3:echo_me></soapenv:Body>

</soapenv:Envelope>

Justin Mattson

unread,
Apr 28, 2007, 12:26:08 PM4/28/07
to AdSen...@googlegroups.com
The reason you're getting this error is that the namespace is incorrect in the header elements.

xmlns:ns1="https://sandbox.google.com/api/adsense/v2"

should be

xmlns:ns1="https://www.google.com/api/adsense/v2"

Namespaces are the same, regardless of the server you're accessing.

Cheers,
Justin
Google AdSense Team

Jcyr

unread,
Apr 28, 2007, 2:15:46 PM4/28/07
to AdSense API Forum
Ok, good to know. Doesn't solve the error, but gets one problem out
of the way. :-)

Here is my CF code thus far. I actually try to set the header two
different ways. The formatting for how the header shows up is the
difference. I tried one way, the other way, and then for fun both.
All same error.

<cfscript>
myvar = CreateObject("webservice", "https://sandbox.google.com/api/
adsense/v2/AccountService?wsdl");


AddSOAPRequestHeader(myvar, "https://www.google.com/api/adsense/v2",
"developer_email", "sandboxd...@google.com");

AddSOAPRequestHeader(myvar, "https://www.google.com/api/adsense/v2",
"developer_password", "devpass");

// Set the password header as a CFML XML object.
doc2 = XmlNew();
doc2.developer_password = XmlElemNew(doc2, "https://www.google.com/
api/adsense/v2", "developer_password");
doc2.developer_password.XmlText = "devpass";

doc = XmlNew();
doc.developer_email = XmlElemNew(doc, "https://www.google.com/api/
adsense/v2", "developer_email");
doc.developer_email.XmlText = "sandboxd...@google.com";

AddSOAPRequestHeader(myvar, "https://www.google.com/api/adsense/v2",
"developer_email", doc);

AddSOAPRequestHeader(myvar, "https://www.google.com/api/adsense/v2",
"developer_password", doc2);


</cfscript>
<cfset servicelist = myvar.getAllSyndicationServices(1)>
<cfdump var="#servicelist#">

The error I get is:
AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/
envelope/}Server.userException
faultSubcode:
faultString: The request did not contain a header named
'developer_email'.
faultActor:
faultNode:
faultDetail:
{http://www.google.com/api/adsense/v2}code:101
{http://www.google.com/api/adsense/v2}message:The request did not
contain a header named 'developer_email'.
{http://www.google.com/api/adsense/v2}fault:
101
false
The request did not contain a header named 'developer_email'.

''

If I run an echo on setting those headers on my local machine I get
the following:

Echo Code:
<cfscript>
myvar = CreateObject("webservice",
"http://127.0.0.1:8500/googleapi/soaptest.cfc?WSDL");


AddSOAPRequestHeader(myvar, "https://www.google.com/api/adsense/v2",
"developer_email", "sandboxd...@google.com");

AddSOAPRequestHeader(myvar, "https://www.google.com/api/adsense/v2",
"developer_password", "devpass");

// Set the password header as a CFML XML object.
doc2 = XmlNew();
doc2.developer_password = XmlElemNew(doc2, "https://www.google.com/
api/adsense/v2", "developer_password");
doc2.developer_password.XmlText = "devpass";

doc = XmlNew();
doc.developer_email = XmlElemNew(doc, "https://www.google.com/api/
adsense/v2", "developer_email");
doc.developer_email.XmlText = "sandboxd...@google.com";

AddSOAPRequestHeader(myvar, "https://www.google.com/api/adsense/v2",
"developer_email", doc);

AddSOAPRequestHeader(myvar, "https://www.google.com/api/adsense/v2",
"developer_password", doc2);

myvar.echo_me("hello world");
req = getSOAPRequest(myvar);
</cfscript>

<cfoutput>#HTMLCodeFormat(xmlparse(req))#</cfoutput>

XML Output:

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


<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/
envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-

instance"><soapenv:Header><ns1:developer_email soapenv:actor="http://
schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0"
xmlns:ns1="https://www.google.com/api/adsense/v2"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xsi:type="soapenc:string">sandboxd...@google.com</
ns1:developer_email><ns2:developer_password soapenv:actor="http://
schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0"
xmlns:ns2="https://www.google.com/api/adsense/v2"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xsi:type="soapenc:string">devpass</
ns2:developer_password><developer_email soapenv:actor=""
soapenv:mustUnderstand="0" xmlns="https://www.google.com/api/adsense/
v2" xmlns:ns3="https://www.google.com/api/adsense/
v2">sandboxd...@google.com</developer_email><developer_password


soapenv:actor="" soapenv:mustUnderstand="0" xmlns="https://

www.google.com/api/adsense/v2" xmlns:ns4="https://www.google.com/api/
adsense/v2">devpass</developer_password></
soapenv:Header><soapenv:Body><ns5:echo_me
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns5="http://googleapi"><in_here xsi:type="xsd:string">hello
world</in_here></ns5:echo_me></soapenv:Body></soapenv:Envelope>

On Apr 28, 12:26 pm, "Justin Mattson" <j...@google.com> wrote:
> The reason you're getting this error is that the namespace is incorrect in
> the header elements.
>
> xmlns:ns1="https://sandbox.google.com/api/adsense/v2"
>
> should be
>
> xmlns:ns1="https://www.google.com/api/adsense/v2"
>
> Namespaces are the same, regardless of the server you're accessing.
>
> Cheers,
> Justin
> Google AdSense Team
>

> On 4/28/07, Jcyr <j...@joshuacyr.com> wrote:
>
>
>
> > I am stumped on getting the header seen by the api. I am all new to
> > SOAP, so I am sure it is something silly.
>
> > The error I get is that the header developer_email wasn't found.
>
> > It is difficult to know exactly what google got, so I tested with a
> > local echo service and this is the sample header that would be sent.
>
> > <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/
> > envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>
> > <soapenv:Header>
>
> > <developer_email soapenv:actor="" soapenv:mustUnderstand="0"
> > xmlns="https://sandbox.google.com/api/adsense/v2" xmlns:ns1="https://

> > sandbox.google.com/api/adsense/v2">sandboxdevelo...@google.com</

Justin Mattson

unread,
Apr 28, 2007, 2:54:50 PM4/28/07
to AdSen...@googlegroups.com
Now it appears that you have the headers twice <developer_email> and <ns1:developer_email>


Cheers,
Justin
Google AdSense Team

Jcyr

unread,
Apr 28, 2007, 3:47:47 PM4/28/07
to AdSense API Forum
Yes, that is just to show you the two styles of header I attempted.
In my tries I actually tried both independently with the same error.
Does the API not care which way it is formated?

On Apr 28, 2:54 pm, "Justin Mattson" <j...@google.com> wrote:
> Now it appears that you have the headers twice <developer_email> and
> <ns1:developer_email>
>
> Cheers,
> Justin
> Google AdSense Team
>

> On 4/28/07, Jcyr <j...@joshuacyr.com> wrote:
>
>
>
> > Ok, good to know. Doesn't solve the error, but gets one problem out
> > of the way. :-)
>
> > Here is my CF code thus far. I actually try to set the header two
> > different ways. The formatting for how the header shows up is the
> > difference. I tried one way, the other way, and then for fun both.
> > All same error.
>
> > <cfscript>
> > myvar = CreateObject("webservice", "https://sandbox.google.com/api/
> > adsense/v2/AccountService?wsdl");
>
> > AddSOAPRequestHeader(myvar, "https://www.google.com/api/adsense/v2",

> > "developer_email", "sandboxdevelo...@google.com");


>
> > AddSOAPRequestHeader(myvar, "https://www.google.com/api/adsense/v2",
> > "developer_password", "devpass");
>
> > // Set the password header as a CFML XML object.
> > doc2 = XmlNew();
> > doc2.developer_password = XmlElemNew(doc2, "https://www.google.com/
> > api/adsense/v2", "developer_password");
> > doc2.developer_password.XmlText = "devpass";
>
> > doc = XmlNew();
> > doc.developer_email = XmlElemNew(doc, "https://www.google.com/api/
> > adsense/v2", "developer_email");

> > doc.developer_email.XmlText = "sandboxdevelo...@google.com";

> > "developer_email", "sandboxdevelo...@google.com");


>
> > AddSOAPRequestHeader(myvar, "https://www.google.com/api/adsense/v2",
> > "developer_password", "devpass");
>
> > // Set the password header as a CFML XML object.
> > doc2 = XmlNew();
> > doc2.developer_password = XmlElemNew(doc2, "https://www.google.com/
> > api/adsense/v2", "developer_password");
> > doc2.developer_password.XmlText = "devpass";
>
> > doc = XmlNew();
> > doc.developer_email = XmlElemNew(doc, "https://www.google.com/api/
> > adsense/v2", "developer_email");

> > doc.developer_email.XmlText = "sandboxdevelo...@google.com";


>
> > AddSOAPRequestHeader(myvar, "https://www.google.com/api/adsense/v2",
> > "developer_email", doc);
>
> > AddSOAPRequestHeader(myvar, "https://www.google.com/api/adsense/v2",
> > "developer_password", doc2);
>
> > myvar.echo_me("hello world");
> > req = getSOAPRequest(myvar);
> > </cfscript>
>
> > <cfoutput>#HTMLCodeFormat(xmlparse(req))#</cfoutput>
>
> > XML Output:
>
> > <?xml version="1.0" encoding="UTF-8"?>
> > <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/
> > envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> > xmlns:xsi="http://www.w3.org/2001/XMLSchema-
> > instance"><soapenv:Header><ns1:developer_email soapenv:actor="http://
> > schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0"
> > xmlns:ns1="https://www.google.com/api/adsense/v2"
> > xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"

> > xsi:type="soapenc:string">sandboxdevelo...@google.com</


> > ns1:developer_email><ns2:developer_password soapenv:actor="http://
> > schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0"
> > xmlns:ns2="https://www.google.com/api/adsense/v2"
> > xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
> > xsi:type="soapenc:string">devpass</
> > ns2:developer_password><developer_email soapenv:actor=""
> > soapenv:mustUnderstand="0" xmlns="https://www.google.com/api/adsense/
> > v2" xmlns:ns3="https://www.google.com/api/adsense/

> > v2">sandboxdevelo...@google.com</developer_email><developer_password

Jcyr

unread,
Apr 29, 2007, 11:41:37 AM4/29/07
to AdSense API Forum
Just to clarify. I am not clear that the header I am sending is
something that google is reading correctly. Any insight on what the
API wants or why my headers are wrong would be greatly appreciated.
The API looks pretty strong and easy to implement if I could only get
my headers worked out.

Thanks!

Justin Mattson

unread,
Apr 29, 2007, 1:02:33 PM4/29/07
to AdSen...@googlegroups.com
Can you post the entire text of the message you're sending with namespace qualified headers?

Thanks,
Justin
Google AdSense Team

Jcyr

unread,
Apr 29, 2007, 2:00:57 PM4/29/07
to AdSense API Forum
I will try to find a way to do that. The code is sort of automatic,
so I am not typing out all the headers manually. What it makes is in
the example above (though only one set of headers, not both). Is
there an echo function in the API so I can run it to see what exactly
it is receiving?

On Apr 29, 1:02 pm, "Justin Mattson" <j...@google.com> wrote:
> Can you post the entire text of the message you're sending with namespace
> qualified headers?
>
> Thanks,
> Justin
> Google AdSense Team
>

Jcyr

unread,
Apr 29, 2007, 5:05:12 PM4/29/07
to AdSense API Forum
Ok Here are two different attempts. This is what I am sending, though
I an running through my own local echo service to find out exactly how
the headers are formated.

Option A:

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/
envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<soapenv:Header>

<ns1:developer_email soapenv:actor="http://schemas.xmlsoap.org/soap/


actor/next" soapenv:mustUnderstand="0" xmlns:ns1="https://
www.google.com/api/adsense/v2" xmlns:soapenc="http://
schemas.xmlsoap.org/soap/encoding/"

xsi:type="soapenc:string">sandboxd...@google.com</
ns1:developer_email>

<ns2:developer_password soapenv:actor="http://schemas.xmlsoap.org/soap/
actor/next" soapenv:mustUnderstand="0" xmlns:ns2="https://
www.google.com/api/adsense/v2" xmlns:soapenc="http://


schemas.xmlsoap.org/soap/encoding/" xsi:type="soapenc:string">devpass</
ns2:developer_password>

</soapenv:Header>

</soapenv:Envelope>

Option B:

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/
envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<soapenv:Header>

<developer_email soapenv:actor="" soapenv:mustUnderstand="0"

xmlns="https://www.google.com/api/adsense/v2" xmlns:ns1="https://
www.google.com/api/adsense/v2">sandboxd...@google.com</developer_email>

<developer_password soapenv:actor="" soapenv:mustUnderstand="0"

xmlns="https://www.google.com/api/adsense/v2" xmlns:ns2="https://
www.google.com/api/adsense/v2">devpass</developer_password>

</soapenv:Header>

</soapenv:Envelope>

Option A Code:

<cfscript>
myvar = CreateObject("webservice",
"http://127.0.0.1:8500/googleapi/soaptest.cfc?WSDL");


AddSOAPRequestHeader(myvar, "https://www.google.com/api/adsense/v2",
"developer_email", "sandboxd...@google.com");

AddSOAPRequestHeader(myvar, "https://www.google.com/api/adsense/v2",
"developer_password", "devpass");

myvar.echo_me("hello world");
req = getSOAPRequest(myvar);
</cfscript>


Option B Code:

<cfscript>
myvar = CreateObject("webservice",
"http://127.0.0.1:8500/googleapi/soaptest.cfc?WSDL");

// Set the password header as a CFML XML object.


doc2 = XmlNew();
doc2.developer_password = XmlElemNew(doc2, "https://www.google.com/
api/adsense/v2", "developer_password");
doc2.developer_password.XmlText = "devpass";

doc = XmlNew();
doc.developer_email = XmlElemNew(doc, "https://www.google.com/api/
adsense/v2", "developer_email");

doc.developer_email.XmlText = "sandboxd...@google.com";

AddSOAPRequestHeader(myvar, "https://www.google.com/api/adsense/v2",
"developer_email", doc);

AddSOAPRequestHeader(myvar, "https://www.google.com/api/adsense/v2",
"developer_password", doc2);

myvar.echo_me("hello world");
req = getSOAPRequest(myvar);
</cfscript>

Jcyr

unread,
Apr 30, 2007, 9:12:11 AM4/30/07
to AdSense API Forum
Just realized that my name space here is still wrong. There should be
no https:// but http:// instead. I will try that code a bit later
today and report.

On Apr 29, 5:05 pm, Jcyr <j...@joshuacyr.com> wrote:
> Ok Here are two different attempts. This is what I am sending, though
> I an running through my own local echo service to find out exactly how
> the headers are formated.
>
> Option A:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/
> envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>
> <soapenv:Header>
>
> <ns1:developer_email soapenv:actor="http://schemas.xmlsoap.org/soap/

> actor/next" soapenv:mustUnderstand="0" xmlns:ns1="https://www.google.com/api/adsense/v2" xmlns:soapenc="http://
> schemas.xmlsoap.org/soap/encoding/"


> xsi:type="soapenc:string">sandboxdevelo...@google.com</
> ns1:developer_email>
>

> <ns2:developer_password soapenv:actor="http://schemas.xmlsoap.org/soap/

> actor/next" soapenv:mustUnderstand="0" xmlns:ns2="https://www.google.com/api/adsense/v2" xmlns:soapenc="http://


> schemas.xmlsoap.org/soap/encoding/" xsi:type="soapenc:string">devpass</
> ns2:developer_password>
>
> </soapenv:Header>
>
> </soapenv:Envelope>
>
> Option B:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/
> envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>
> <soapenv:Header>
>
> <developer_email soapenv:actor="" soapenv:mustUnderstand="0"

> xmlns="https://www.google.com/api/adsense/v2" xmlns:ns1="https://www.google.com/api/adsense/v2">sandboxdevelo...@google.com</developer_email>


>
> <developer_password soapenv:actor="" soapenv:mustUnderstand="0"

> xmlns="https://www.google.com/api/adsense/v2" xmlns:ns2="https://www.google.com/api/adsense/v2">devpass</developer_password>


>
> </soapenv:Header>
>
> </soapenv:Envelope>
>
> Option A Code:
>
> <cfscript>
> myvar = CreateObject("webservice",
> "http://127.0.0.1:8500/googleapi/soaptest.cfc?WSDL");
>
> AddSOAPRequestHeader(myvar, "https://www.google.com/api/adsense/v2",

> "developer_email", "sandboxdevelo...@google.com");
>
> AddSOAPRequestHeader(myvar, "https://www.google.com/api/adsense/v2",
> "developer_password", "devpass");
>

> myvar.echo_me("hello world");
> req = getSOAPRequest(myvar);
> </cfscript>
>
> Option B Code:
>
> <cfscript>
> myvar = CreateObject("webservice",
> "http://127.0.0.1:8500/googleapi/soaptest.cfc?WSDL");
>
> // Set the password header as a CFML XML object.
> doc2 = XmlNew();
> doc2.developer_password = XmlElemNew(doc2, "https://www.google.com/
> api/adsense/v2", "developer_password");
> doc2.developer_password.XmlText = "devpass";
>
> doc = XmlNew();
> doc.developer_email = XmlElemNew(doc, "https://www.google.com/api/
> adsense/v2", "developer_email");

> ...
>
> read more »

Jcyr

unread,
Apr 30, 2007, 12:19:15 PM4/30/07
to AdSense API Forum
That was exactly the problem. The namespace wasn't supposed to use
SSL. All set now thanks.

> ...
>
> read more »

Justin Mattson

unread,
Apr 30, 2007, 12:18:03 PM4/30/07
to AdSen...@googlegroups.com
Yes, that would do it. Sorry that I gave you the wrong namespace.


Cheers,
Justin
Google AdSense Team


> read more �





Jcyr

unread,
Apr 30, 2007, 5:44:23 PM4/30/07
to AdSense API Forum
For any CF developers that stumble on this, I did a quick blog entry
with exactly how I set it all up, and how to output some results.
Very simple, but should help get you going.

http://www.usefulconcept.com/index.cfm/2007/4/30/Google-Adsense-API-Headers-with-ColdFusion

On Apr 30, 12:18 pm, "Justin Mattson" <j...@google.com> wrote:
> Yes, that would do it. Sorry that I gave you the wrong namespace.
>
> Cheers,
> Justin
> Google AdSense Team
>

> ...
>
> read more »

Reply all
Reply to author
Forward
0 new messages