Hi Louis,
As far as I can tell, you are facing a combination of a mis-configured
library and a library bug. Here's what's triggering the exception:
- Somehow, the app.config is still mis-configured, so Email and
Password defaults to empty strings
- So Authtoken also defaults to null
- Since Authtoken is null, the library doesn't send an AuthToken to
the server.
- The server returns a SoapHeaderException (as opposed to a
SoapException) about missing header, and hence its Details node is
null
- AdWordsApiService.cs tries to read Details node and throws a NPE.
I'm listing the steps required to configure a fresh project to use the
client library. Let me know if this works for you.
1. Create a Console application project.
2. Copy google-api-adwords-dotnet.dll over to your working directory.
If you rename this dll, remember to change the assembly name in your
app.config as well (in step 4)
3. Add reference to google-api-adwords-dotnet.dll, System.Web.Services
and System.Configuration in Console application.
4. Copy src\app.config and use it to replace your app.config (Or if
you can, copy the relevant nodes - AdWordsApi, System.net, System.web,
configsections\AdWordsApi)
5. Add relevant credentials in app.config - CompanyName, Email,
Password, ClientEmail, DeveloperToken
6. Add your code to call AdWords API - Refer to the code samples to
get started easier.
7. Build and run your project.
As for the bug, you need a check on line 45 of adwordsapiservice.cs,
as follows:
if (!string.IsNullOrEmpty(defaultNs) && ex.Detail != null) {
...
}
There is an open bug about this issue, see
http://code.google.com/p/google-api-adwords-dotnet/issues/detail?id=42.
I'll fix this issue in the next version of the client library.
Best,
- Anash P. Oommen, AdWords API Team
On May 27, 6:39 am, louis <[email protected]> wrote:
> Hi
>
> Im getting an "authToken is missing in SoapHeader", simple project,
> downloaed the dll and referenced them, c# below. Firstly had one or
> two issues with the app config not pulling in the authentication
> correctly, fixed that then this which i dont see a hell of a lot
> about.
>
> Have set the properties to log the soap which worked for the
> authentication errors but not for this one which is a bit strange
>
> any ideas?
>
> c# class
>
> AdWordsUser user = new AdWordsUser();
>
> TargetingIdeaService service =
> (TargetingIdeaService)user.GetService(AdWordsService.v200909.TargetingIdeaS
> ervice);
>
> TargetingIdeaSelector selector = new
> TargetingIdeaSelector();
>
> Keyword[] keyword = new Keyword[1];
>
> keyword[0] = new Keyword();
>
> keyword[0].text = "data recovery";
>
> RelatedToKeywordSearchParameter related = new
> RelatedToKeywordSearchParameter();
>
> related.keywords = keyword;
>
> CountryTargetSearchParameter countries = new
> CountryTargetSearchParameter();
>
> CountryTarget[] country = new CountryTarget[1];
>
> country[0] = new CountryTarget();
> country[0].countryCode = "GB";
>
> countries.countryTargets = country;
>
> TargetingIdeaSelector targetidea = new
> TargetingIdeaSelector();
>
> SearchParameter[] parms = new SearchParameter[1];
> parms[0] = related;
>
> targetidea.ideaType = IdeaType.KEYWORD;
> targetidea.requestType = RequestType.STATS;
> targetidea.searchParameters = parms;
>
> AttributeType[] attributes = new AttributeType[2];
> attributes[0] = new AttributeType();
> attributes[1] = new AttributeType();
>
> attributes[0] = AttributeType.TARGETED_MONTHLY_SEARCHES;
> attributes[1] = AttributeType.KEYWORD;
>
> targetidea.requestedAttributeTypes = attributes;
>
> Paging paging = new Paging();
>
> paging.numberResults=150;
>
> targetidea.paging = paging;
>
> TargetingIdeaPage page = service.get(targetidea);
>
> app config
>
> <?xml version="1.0" encoding="utf-8" ?>
> <configuration>
> <configSections>
> <section name="AdWordsApi"
>
> type="com.google.api.adwords.lib.ApplicationConfiguration,google-api-
> adwords-dotnet"/>
> </configSections>
> <AdWordsApi>
> <!-- Change the appropriate flags to turn on SOAP logging. -->
> <add key="LogPath" value="C:\Logs\"/>
> <add key="LogToConsole" value="false"/>
> <add key="LogToFile" value="true"/>
> <add key="MaskCredentials" value="true"/>
>
> <!-- Uncomment this key if you want to disable gzip compression in
> SOAP requests.-->
> <!--<add key="EnableGzipCompression" value="false"/>-->
>
> <!-- Fill the header values. -->
> <add key="CompanyName" value="X"/>
> <add key="Email" value="X"/>
> <add key="Password" value="X"/>
> <!-- <add key="ClientEmail" value="X"/>-->
> <add key="DeveloperToken" value="X"/>
> <!-- Application token is now optional and will be ignored by the
> server.-->
> <!-- <add key="ApplicationToken"
> value="ENTER_YOUR_APPLICATION_TOKEN_HERE"/> -->
>
> <!-- Uncomment this key and comment ClientEmail if you want to
> specify
> customer id instead of customer email. -->
> <add key="ClientCustomerId"
> value="X"/> -->
>
> <!-- Uncomment this if you want to reuse an authToken multiple
> times. -->
> <!--<add key="AuthToken" value="ENTER_YOUR_AUTH_TOKEN_HERE"/> -->
>
> <!-- Uncomment this key if you want to use v13 sandbox. -->
> <!-- <add key="LegacyAdWordsApi.Url" value="https://
> sandbox.google.com"/>-->
>
> <!-- Uncomment this key if you want to use AdWords API sandbox. --
>
> <add key="AdWordsApi.Url" value="https://adwords-
> sandbox.google.com"/>
> </AdWordsApi>
> <system.web>
> <webServices>
> <soapExtensionTypes>
> <add type="com.google.api.adwords.lib.TraceExtension,
> google-api-adwords-dotnet" priority="1" group="0"/>
> <add type="com.google.api.adwords.lib.ApiUnitsExtension,
> google-api-adwords-dotnet" priority="1" group="0"/>
> </soapExtensionTypes>
> </webServices>
> </system.web>
> <system.net>
> <settings>
> <httpWebRequest maximumErrorResponseLength="-1" />
> </settings>
> </system.net>
> </configuration>
>
> error i get on debug
>
> authToken is missing in SoapHeader. while invoking public abstract
> com.google.ads.api.services.targetingideas.v200909.jaxbgen.TargetingIdeaPag e
> com.google.ads.api.services.targetingideas.v200909.jaxbgen.TargetingIdeaSer
> viceInterface.get(com.google.ads.api.services.targetingideas.v200909.jaxbge
> n.TargetingIdeaSelector)
> throws
> com.google.ads.api.services.targetingideas.v200909.jaxbgen.ApiException_Exc
> eption
> with params
> [com.google.ads.api.services.targetingideas.v200909.jaxbgen.TargetingIdeaSe
> lec...@96a05b].
>
> which then causes a null reference in line 46 of adwordsapiservice.cs
>
> "XmlNamespaceManager xmlns = new
> XmlNamespaceManager(ex.Detail.OwnerDocument.NameTable);" because
> ex.Detail is null
>
> any help much appreciated!
>
> thanks!
>
> Cheers
>
> Louis
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
http://adwordsapi.blogspot.com
http://groups.google.com/group/adwords-api
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
You received this message because you are subscribed to the Google
Groups "AdWords API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en