Response is not well-formed XML - using .net client libarary 15.5

1,119 views
Skip to first unread message

Glyph

unread,
Oct 16, 2013, 12:32:55 PM10/16/13
to adwor...@googlegroups.com

I'm doing a mutate call on the AdGroudAd service using the .net client lib v 15.5
And the response I'm getting looks like valid soap/xml when i look at it in fiddler, but i get an invalidoperationexception when reading the response saying that "Response is not well-formed XML".

Is there a known bad character or something in the response causing the .net web service client to throw this exception?

Here's the requestId that's giving me the problem.
<requestId>
        0004e8ddab5e6fc00aedc64600000f77
      </requestId>

Glyph

unread,
Oct 17, 2013, 4:58:11 PM10/17/13
to adwor...@googlegroups.com
upgraded to latest .net client library for adwords(16.2)  same issue on some responeses:

<requestId>0004e8f60a95f0400aed8a5000006e0c</requestId>

Paul Matthews (AdWords API Team)

unread,
Oct 19, 2013, 5:15:52 AM10/19/13
to adwor...@googlegroups.com
Hi Glyph,

I too have viewed the request in an XML browser and it seems to be formatted correctly. Do you have this issue on any other (smaller) requests? Or is it this particular request?

Regards,

- Paul, AdWords API Team.

Glyph

unread,
Oct 20, 2013, 1:37:07 PM10/20/13
to adwor...@googlegroups.com
The issue is with the RESPONSE, not the request.   The response comes back, and has some chars near the beginning that make .net throw an invalidoperation exception.

Paul Matthews (AdWords API Team)

unread,
Oct 20, 2013, 3:44:28 PM10/20/13
to adwor...@googlegroups.com
Apologies, I indeed meant response.

Is this happening on other requests too? Or only this one?

Regards,

- Paul, AdWords API Team.

Glyph

unread,
Oct 21, 2013, 9:31:33 AM10/21/13
to adwor...@googlegroups.com
It happens intermittantly on calls to mutate on the adgroupcriterion service.
the adwords api client says the bad chars are near 1,1 in the response, so I'm guessing that there are some non-printable characters near the beginning of the response that are causing the issue.

I agree, If you just look at the response, it does 'appear' to be valid xml.

Paul Matthews (AdWords API Team)

unread,
Oct 24, 2013, 10:58:28 AM10/24/13
to adwor...@googlegroups.com
Hi Glyph,

Our .NET library creator informs me that this is a common problem and has a standard fix.

.NET's WebRequest class trims the response to a default of 64K if it gets an http error response code. The AdWords API returns a failed response with a 500 code, and if the error response is too long (e.g. policy violation with stack trace), .NET trims the response, thus causing invalid xml error in the SOAP layer.

You should be able to resolve this by changing the App.config to include the following lines:
    <settings>
      <httpWebRequest maximumErrorResponseLength="-1"  />
    </settings>

Regards,

- Paul, AdWords API Team.

Glyph

unread,
Oct 24, 2013, 1:30:19 PM10/24/13
to adwor...@googlegroups.com
Simple indeed.  that was exactly what was needed. it fixed the issue.
Thanks for staying on this and figuring it out!
Reply all
Reply to author
Forward
0 new messages