2013-10-16 27 views
1

我正在使用OAuth2作爲身份驗證機制,以使用SOAP請求獲得有關「添加預算活動」的響應。在最開始中使用cUrl我面臨着如下的錯誤發送SOAP請求:使用Google Adwords API時發生解組錯誤

<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 'biddingStrategy'. One of '{"https://adwords.google.com/api/adwords/cm/v201309":conversionOptimizerEligibility, "https://adwords.google.com/api/adwords/cm/v201309":adServingOptimizationStatus, "https://adwords.google.com/api/adwords/cm/v201309":frequencyCap, "https://adwords.google.com/api/adwords/cm/v201309":settings, "https://adwords.google.com/api/adwords/cm/v201309":networkSetting, "https://adwords.google.com/api/adwords/cm/v201309":biddingStrategyConfiguration, "https://adwords.google.com/api/adwords/cm/v201309":forwardCompatibilityMap}' is expected. 
    </faultstring> 
    </soap:Fault> 
</soap:Body> 
</soap:Envelope> 

我送中使用cUrl以下XML/SOAP請求,這是在AdWords上的教程(https://developers.google.com/adwords/api/docs/guides/soap)給出了類似的代碼。

<?xml version="1.0" encoding="UTF-8"?> 
    <soap:Envelope 
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns="https://adwords.google.com/api/adwords/cm/v201309"> 
    <soap:Header> 
     <RequestHeader> 
     <authToken>MYAUTHTOKEN</authToken> 
     <userAgent>curl-tutorial</userAgent> 
     <developerToken>MYDEVTOKEN</developerToken> 
     <clientCustomerId>MYCUSTOMERID</clientCustomerId> 
     </RequestHeader> 
    </soap:Header> 
    <soap:Body> 
     <mutate> 
     <operations> 
      <operator>ADD</operator> 
      <operand> 
      <name>Test File</name> 
      <budget> 
       <period>DAILY</period> 
       <amount> 
       <microAmount>1000000000</microAmount> 
       </amount> 
       <deliveryMethod>STANDARD</deliveryMethod> 
      </budget> 
      <biddingStrategy 
       xmlns:cm="https://adwords.google.com/api/adwords/cm/v201309" 
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
       xsi:type="cm:ManualCPC"/> 
      <settings 
       xmlns:cm="https://adwords.google.com/api/adwords/cm/v201309" 
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
       xsi:type="cm:KeywordMatchSetting"> 
       <cm:optIn>false</cm:optIn> 
      </settings> 
      </operand> 
     </operations> 
     </mutate> 
    </soap:Body> 
    </soap:Envelope> 

我利用我的捲曲固定請求上述XML/SOAP請求:

curl --header "Content-Type: application/soap+xml" 
--data @test.xml https://adwords.google.com/api/adwords/cm/v201309/CampaignService 

我已搜查過關於我面臨着同樣的問題,互聯網,但沒有在那裏我能找到解決方案。如果我做錯了任何事,請告訴我,或者讓我知道是否有其他出路。

回答

相關問題