simbor / google-api-adwords-php

Automatically exported from code.google.com/p/google-api-adwords-php
Apache License 2.0
0 stars 0 forks source link

Unmarshalling Error caused by duplicate xsi:type attributes #50

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Which version of the library are you using?
2.4.1

Which version of PHP are you using?
5.2.14 , Zend Server CE for on Mac OS X 10.5

What steps will reproduce the problem?
1) Set up a valid sandbox account
2) Run the AddCampaign example (any API version)
3) Receive Unmarshalling Error

What is the expected output? What do you see instead?

Expected: 
Campaign with name "<campaign name>" and id "<campaign id>" was added.

Actual:
Unmarshalling Error: ParseError at [row,col]:[2,1067]
Message: 
http://www.w3.org/TR/1999/REC-xml-names-19990114#AttributeNSNotUnique?ns1:biddin
gStrategy&type&http://www.w3.org/2001/XMLSchema-instance

Please provide any additional information below.

Tracing through the code and SOAP request reveals that by default the xsi:type 
attribute is duplicated on the <ns1:biddingStrategy> element, thus:

<ns1:biddingStrategy xsi:type="ns1:ManualCPC" xsi:type="ns1:ManualCPC" 
xmlns:ns1="https://adwords.google.com/api/adwords/cm/v201008"/>

I think the culprit is the version-and-OS detection incorrectly determining 
that the XSI Types need to be added manually, in AdsSoapClient::PrepareRequest. 
Disabling the check such that $addXsiTypes remains false results in a 
successful request. I don't know what the actual check should be in order to 
give correct results, however.

I also think this hints at a bug in the the XML processing used by PHP's 
SoapClient, since it's the mechanism that allows the duplicate attribute in the 
first place?

Original issue reported on code.google.com by mcegie...@gmail.com on 12 Jan 2011 at 5:29

GoogleCodeExporter commented 8 years ago
Thank you for reporting this issue.  PHP's SoapClient extension has strange 
bugs in some versions and for some operating systems, which is why we added in 
the SoapRequestXmlFixer class.  I'll try to adjust the logic so that extra 
elements aren't added in for your environment.

Original comment by api.ekol...@gmail.com on 14 Jan 2011 at 3:45

GoogleCodeExporter commented 8 years ago

Original comment by api.ekol...@gmail.com on 14 Jan 2011 at 3:45

GoogleCodeExporter commented 8 years ago
I've added a simple check to Google/Api/Ads/Common/Util/SoapRequestXmlFixer.php 
to ensure that xsi:type attributes aren't added twice.  Can you undo your 
changes, apply the attached patch to SoapRequestXmlFixer.php and let me know if 
that resolves the issue?

Original comment by api.ekol...@gmail.com on 14 Jan 2011 at 4:51

Attachments:

GoogleCodeExporter commented 8 years ago
Patch appears to function as intended - rolled back to a clean 2.4.1 and 
retested with the patch applied, no errors. Thank you!

Original comment by mcegie...@gmail.com on 17 Jan 2011 at 11:47

GoogleCodeExporter commented 8 years ago

Original comment by api.ekol...@gmail.com on 18 Jan 2011 at 2:42