使用Google AdWords API的XMLException

时间:2014-09-15 14:32:54

标签: c# xml visual-studio adsense google-adwords

所以我尝试使用广告组服务的mutate方法,无法解决我遇到的问题。每当线

    retVal = adGroupService.mutate(operations.ToArray());

[其中

    operations = new List<AdGroupOperation>();

调用

,我收到以下错误消息

    An exception of type 'System.Xml.XmlException' occurred in 
    System.Xml.dll but was not handled in user code

    Additional information: Data at the root level is invalid. Line 1, position 1.

在上一行之前,我已经放置了代码

    XmlDocument doc = new XmlDocument();
    doc.Load(@"file-path");

测试我的web.config是否存在问题,这是应用程序获取相关AdWords设置的位置,例如开发人员令牌。这没有任何问题,我可以断点并检查&#39; doc&#39;,所有都是有序的。

有没有人有任何建议?我在C#工作,如果这对你有帮助的话。如果需要进一步的详细信息,请告诉我。

谢谢, 康纳

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="dataProviderModel" type="MSharp.Framework.Data.DataProviderModelConfigurationSection, MSharp.Framework" />
    <section name="AdWordsApi" type="System.Configuration.DictionarySectionHandler"/>
  </configSections>
  <connectionStrings>

    <add name="AppDatabase" connectionString="Database=GeeksBanners; Data Source=.\SQLEXPRESS;User ID=app;Password=geeks;MultipleActiveResultSets=True;" providerName="System.Data.SqlClient" />
  </connectionStrings>
  <appSettings>
    <add key="BaseUrl" value="" />
    <add key="Database.Storage.Path" value="C:\@Database.Files" />
    <add key="Temp.Databases.Location" value="C:\@Database.Files" />
    <add key="UploadFolder" value="App_Documents" />
    <add key="UploadFolder.Secure" value="App_Data" />
    <add key="UploadFolder.VirtualRoot" value="/App_Documents/" />
    <add key="Email.Enable.Ssl" value="true" />
    <add key="Email.Sender.Address" value="" />
    <add key="Email.Sender.Name" value="GeeksBanners Application" />
    <add key="Email.Permitted.Domains" value="for-test.net|uat.co" />
    <add key="Email.Maximum.Retries" value="4" />
    <add key="Email.Auto.CC.Address" value="" />
    <add key="Log.Record.Application.Events" value="false" />
    <add key="Log.Record.Exceptions" value="true" />
    <add key="Database.Cache.Enabled" value="true" />
    <add key="Error.Notification.Receiver" value="" />
    <add key="Database.Session.Memory.Enabled" value="false" />
    <add key="Data.Access.Log.Custom.Queries" value="false" />
    <add key="PdfConverter.LicenseKey" value="" />
    <add key="CKeditor:BasePath" value="~/Content/@Ckeditor" />
    <add key="GZip.Pages.Response" value="true" />
    <add key="Pages.CommonResources.Enabled" value="false" />
  </appSettings>
  <location path="Pages/Settings.aspx">
    <system.web>
      <pages validateRequest="false" />
    </system.web>
  </location>
  <system.net>
    <mailSettings>
      <smtp deliveryMethod="Network">
        <network host="smtp.gmail.com" port="587" userName="" password="" defaultCredentials="true" />
      </smtp>
    </mailSettings>
  </system.net>
  <!--Ajax stuff:-->
  <dataProviderModel>
    <providers>
      <add assembly="GeeksBanners.Model" providerFactoryType="AppData.AdoDotNetDataProviderFactory, GeeksBanners.Model" />
    </providers>
  </dataProviderModel>
  <system.web>
    <httpRuntime maxRequestLength="20000" requestValidationMode="2.0" enableVersionHeader="false" />
    <pages pageBaseType="MSharp.Framework.UI.Page, MSharp.Framework">
      <controls>
        <add tagPrefix="cke" namespace="CKEditor.NET" assembly="CKEditor.NET" />
        <add tagPrefix="asp" namespace="MSharp.Framework.UI" assembly="MSharp.Framework" />
        <add tagPrefix="asp" namespace="MSharp.Framework.UI.Controls" assembly="MSharp.Framework" />
        <add tagPrefix="asp" namespace="AjaxControlToolkit" assembly="AjaxControlToolkit" />
        <add tagPrefix="asp" namespace="System.Web.UI.DataVisualization.Charting" assembly="System.Web.DataVisualization" />
      </controls>
      <namespaces>
        <add namespace="System.Linq" />
        <add namespace="MSharp.Framework" />
        <add namespace="App" />
      </namespaces>
    </pages>
    <httpHandlers>
      <!--<add verb="GET" path="File.ashx" type="Utilities.FileRequestHandler, CommonUtilities"/>-->
    </httpHandlers>
    <compilation debug="true" defaultLanguage="c#" targetFramework="4.0">
      <assemblies>
        <add assembly="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=" />
        <add assembly="System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=" />
        <add assembly="System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=" />
        <add assembly="System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=" />
        <add assembly="System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=" />
        <add assembly="System.Web.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=" />
        <add assembly="System.Runtime.Remoting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=" />
        <add assembly="System.Transactions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=" />
        <add assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=" />
        <add assembly="System.Windows.Forms.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=" />
        <add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=" />
      </assemblies>
      <buildProviders>
        <!--<add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.Common, Version=8.0.0.0, Culture=neutral, PublicKeyToken=" />-->
        <add extension=".asbx" type="Microsoft.Web.Services.BridgeBuildProvider" />
      </buildProviders>
    </compilation>
    <customErrors mode="Off" />
    <trace enabled="false" requestLimit="10" pageOutput="false" traceMode="SortByTime" localOnly="true" />
    <sessionState mode="InProc" stateConnectionString="tcpip=" sqlConnectionString="data source=; Trusted_Connection=yes" cookieless="false" timeout="20" />
    <globalization requestEncoding="utf-8" responseEncoding="utf-8" uiCulture="en-GB" culture="en-GB" />
    <webServices>
      <protocols>
        <add name="HttpGet" />
        <add name="HttpPost" />
      </protocols>
      <soapExtensionTypes>
        <add type="Google.Api.Ads.Common.Lib.SoapListenerExtension, Google.Ads.Common"
             priority="1" group="High"/>
      </soapExtensionTypes>
    </webServices>
    <authentication mode="Forms">
      <forms loginUrl="Login.aspx" protection="All" timeout="20" slidingExpiration="true" />
    </authentication>
    <authorization>
      <allow users="*" />
    </authorization>
  </system.web>
  <system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider,System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=" warningLevel="4" compilerOptions="/warnaserror-">
        <providerOption name="CompilerVersion" value="v4.0" />
      </compiler>
    </compilers>
  </system.codedom>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <probing privatePath="bin;Framework;" />
    </assemblyBinding>
  </runtime>
  <system.webServer>
    <handlers>
      <add name="HTML Pagehandler" path="*.html" verb="*" type="System.Web.UI.PageHandlerFactory" resourceType="Unspecified" preCondition="integratedMode" />
      <add name="Ajax Combined Script" path="AjaxScriptManagerCombinedScriptProvider.axd" verb="GET" type="MSharp.Framework.UI.AjaxScriptManagerCombinedScriptProvider, MSharp.Framework" preCondition="integratedMode" />
      <add name="Google login handler" verb="GET" path="GoogleLoginHandler.ashx" type="Geeks.OAuth.Google.GoogleLoginHandler, Geeks.OAuth" />
    </handlers>
    <httpProtocol>
      <customHeaders>
        <remove name="Server" />
        <remove name="X-Powered-By" />
        <remove name="X-AspNet-Version" />
      </customHeaders>
    </httpProtocol>
    <!--<modules>
      <add type="Geeks.WebTest.HttpModule" name="HttpModule" />
    </modules>-->
  </system.webServer>
  <AdWordsApi>
    <!-- Settings specific to AdWords API.-->
    <add key="UserAgent" value="GeeksBanner"/>
    <!--<add key="DeveloperToken" value=""/>-->
    <add key="DeveloperToken" value=""/>
    <add key="ClientCustomerId" value=""/>

    <!-- OAuth2 configuration -->
    <add key="AuthorizationMethod" value="" />
    <add key="OAuth2ClientId" value="" />
    <add key="OAuth2ClientSecret" value="" />
    <add key="OAuth2Mode" value="APPLICATION" />
    <add key="OAuth2RefreshToken" value="" />
  </AdWordsApi>
</configuration>

0 个答案:

没有答案