• AdWords API versions v13, v200909, v201003, v201008, v201101
If you would like your applications to run without interruption, you must migrate to AdWords API v201109 by February 29th. Migration resources are available here. In addition, if you have specific questions, we encourage you to attend office hours or post questions to the forum.

Share on Twitter Share on Facebook

Share on Twitter Share on Facebook

 
Share on Twitter Share on Facebook

You might not realize it if you use our client libraries, but at its core the AdWords API is based on SOAP and XML. Crafting a request by hand can be tricky, and even some SOAP toolkits have problems serializing to the correct format. In version v201109 of the API we enabled additional XML validation so that you will now be alerted to structural issues with your requests.

The format of the request’s XML payload is specified by an XML Schema definition (XSD) embedded in the WSDL document for the service. The schema describes very precisely the types and elements that can appear in the request. In past versions of the API the server was somewhat lenient in how it processed the incoming XML. For example, it would silently ignore unknown elements. This had the potential to hide problems with your code or cause mysterious behavior.

With enhanced XML validation enabled, the aforementioned errors can be caught earlier, as the request payload must fully match the format in the schema. Below is a sample request and response showing a validation error for an unknown element.

Request
<?xml version="1.0"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
  <soapenv:Header>
    <RequestHeader 
      xmlns="https://adwords.google.com/api/adwords/cm/v201109">
      <applicationToken>...</applicationToken>
      <authToken>...</authToken>
      <clientCustomerId>...</clientCustomerId>
      <developerToken>...</developerToken>
      <userAgent>...</userAgent>
    </RequestHeader>
  </soapenv:Header>
  <soapenv:Body>
    <get xmlns="https://adwords.google.com/api/adwords/cm/v201109">
      <serviceSelector>
        <fields>Id</fields>
        <fields>Name</fields>
        <ordering>
          <field>Name</field>
        </ordering>
        <foo>bar</foo>
      </serviceSelector>
    </get>
  </soapenv:Body>
</soapenv:Envelope>


Response
<?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <soap:Fault>
      <faultcode>soap:Client</faultcode>
      <faultstring>
        Unmarshalling Error: cvc-complex-type.2.4.a: Invalid content 
        was found starting with element 'foo'. One of '{
         "https://adwords.google.com/api/adwords/cm/v201109":ordering, 
         "https://adwords.google.com/api/adwords/cm/v201109":paging
        }' is expected.
      </faultstring>
    </soap:Fault>
  </soap:Body>
</soap:Envelope>


In this case the response is indicating that only the elements "ordering" or "paging" are permitted in this part of the request. Please note that this error is thrown as a raw SOAP fault, and is not wrapped in an ApiError object. There is no need to add special exception handling for these errors, as they are designed to be detected and resolved during the development phase of your application. If they do occur in your production environment you should log them for later analysis.

There are some side effects of using stricter XML validation that you should be aware of: