API объявлений Bing - ошибка сохранения для get_ad_extensions_associations - PullRequest
0 голосов
/ 10 января 2019

Поддерживая драгоценный камень, чтобы обернуть bing ads api, я использую этот wsdl от bing .

До сих пор большинство вызовов API работают нормально, но я сталкиваюсь с get_ad_extensions_associations.

Что я печатаю:

client.call(
  :get_ad_extensions_associations, 
  message: { account_id: 150168726, association_type: "Campaign", ad_extension_type: "CallAdExtension", entity_ids: [ { long: 8177659860409 }] },
  soap_header: header
)

На bing отправляется следующее:

I, [2019-01-10T11:33:52.222852 #19132]  INFO -- : SOAP request: https://campaign.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/V12/CampaignManagementService.svc
I, [2019-01-10T11:33:52.222951 #19132]  INFO -- : SOAPAction: "GetAdExtensionsAssociations", Content-Type: text/xml;charset=UTF-8, Content-Length: 2152
D, [2019-01-10T11:33:52.223282 #19132] DEBUG -- : <?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="https://bingads.microsoft.com/CampaignManagement/v12" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ins0="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns:ins1="http://schemas.datacontract.org/2004/07/System.Collections.Generic" xmlns:ins2="http://schemas.datacontract.org/2004/07/System" xmlns:ins3="https://adapi.microsoft.com">
  <env:Header>
    <tns:AuthenticationToken>***FILTERED***</tns:AuthenticationToken>
    <tns:DeveloperToken>***FILTERED***</tns:DeveloperToken>
    <tns:CustomerId>***FILTERED***</tns:CustomerId>
    <tns:CustomerAccountId>***FILTERED***</tns:CustomerAccountId>
  </env:Header>
  <env:Body>
    <tns:GetAdExtensionsAssociationsRequest>
      <tns:AccountId>150168726</tns:AccountId>
      <tns:AdExtensionType>CallAdExtension</tns:AdExtensionType>
      <tns:AssociationType>Campaign</tns:AssociationType>
      <tns:EntityIds>
        <tns:long>8177659860409</tns:long>
      </tns:EntityIds>
    </tns:GetAdExtensionsAssociationsRequest>
  </env:Body>
</env:Envelope>

Я получаю следующее:

D, [2019-01-10T11:33:52.223406 #19132] DEBUG -- : HTTPI /peer POST request to campaign.api.bingads.microsoft.com (excon)
I, [2019-01-10T11:33:52.906376 #19132]  INFO -- : SOAP response (status 500)
D, [2019-01-10T11:33:52.907343 #19132] DEBUG -- : <?xml version="1.0"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Body>
    <s:Fault>
      <faultcode xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher">a:DeserializationFailed</faultcode>
      <faultstring xml:lang="en-US">The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter https://bingads.microsoft.com/CampaignManagement/v12:EntityIds. The InnerException message was 'There was an error deserializing the object of type System.Int64[]. End element 'EntityIds' from namespace 'https://bingads.microsoft.com/CampaignManagement/v12' expected. Found element 'tns:long' from namespace 'https://bingads.microsoft.com/CampaignManagement/v12'. Line 1, position 2046.'.  Please see InnerException for more details.</faultstring>
      <detail>
        <ExceptionDetail xmlns="http://schemas.datacontract.org/2004/07/System.ServiceModel" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
          <HelpLink i:nil="true"/>
          <InnerException>
            <HelpLink i:nil="true"/>
            <InnerException>
              <HelpLink i:nil="true"/>
              <InnerException i:nil="true"/>
              <Message>End element 'EntityIds' from namespace 'https://bingads.microsoft.com/CampaignManagement/v12' expected. Found element 'tns:long' from namespace 'https://bingads.microsoft.com/CampaignManagement/v12'. Line 1, position 2046.</Message>
              <StackTrace>   at System.Xml.XmlExceptionHelper.ThrowXmlException(XmlDictionaryReader reader, String res, String arg1, String arg2, String arg3)&#xD;
   at System.Xml.XmlExceptionHelper.ThrowEndElementExpected(XmlDictionaryReader reader, String localName, String ns)&#xD;
   at System.Xml.XmlBaseReader.ReadEndElement()&#xD;
   at System.Runtime.Serialization.CollectionDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)&#xD;
   at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator reader, String name, String ns, Type declaredType, DataContract&amp; dataContract)&#xD;
   at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator xmlReader, Type declaredType, DataContract dataContract, String name, String ns)&#xD;
   at System.Runtime.Serialization.DataContractSerializer.InternalReadObject(XmlReaderDelegator xmlReader, Boolean verifyObjectName, DataContractResolver dataContractResolver)&#xD;
   at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)</StackTrace>
              <Type>System.Xml.XmlException</Type>
            </InnerException>
            <Message>There was an error deserializing the object of type System.Int64[]. End element 'EntityIds' from namespace 'https://bingads.microsoft.com/CampaignManagement/v12' expected. Found element 'tns:long' from namespace 'https://bingads.microsoft.com/CampaignManagement/v12'. Line 1, position 2046.</Message>
            <StackTrace>   at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)&#xD;
   at System.Runtime.Serialization.DataContractSerializer.ReadObject(XmlDictionaryReader reader, Boolean verifyObjectName)&#xD;
   at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.PartInfo.ReadObject(XmlDictionaryReader reader, XmlObjectSerializer serializer)&#xD;
   at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeParameterPart(XmlDictionaryReader reader, PartInfo part, Boolean isRequest)</StackTrace>
            <Type>System.Runtime.Serialization.SerializationException</Type>
          </InnerException>
          <Message>The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter https://bingads.microsoft.com/CampaignManagement/v12:EntityIds. The InnerException message was 'There was an error deserializing the object of type System.Int64[]. End element 'EntityIds' from namespace 'https://bingads.microsoft.com/CampaignManagement/v12' expected. Found element 'tns:long' from namespace 'https://bingads.microsoft.com/CampaignManagement/v12'. Line 1, position 2046.'.  Please see InnerException for more details.</Message>
          <StackTrace>   at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeParameterPart(XmlDictionaryReader reader, PartInfo part, Boolean isRequest)&#xD;
   at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeParameters(XmlDictionaryReader reader, PartInfo[] parts, Object[] parameters, Boolean isRequest)&#xD;
   at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeBody(XmlDictionaryReader reader, MessageVersion version, String action, MessageDescription messageDescription, Object[] parameters, Boolean isRequest)&#xD;
   at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeBodyContents(Message message, Object[] parameters, Boolean isRequest)&#xD;
   at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeRequest(Message message, Object[] parameters)&#xD;
   at System.ServiceModel.Dispatcher.DispatchOperationRuntime.DeserializeInputs(MessageRpc&amp; rpc)&#xD;
   at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&amp; rpc)&#xD;
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&amp; rpc)&#xD;
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc&amp; rpc)&#xD;
   at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)</StackTrace>
          <Type>System.ServiceModel.Dispatcher.NetDispatcherFaultException</Type>
        </ExceptionDetail>
      </detail>
    </s:Fault>
  </s:Body>
</s:Envelope>

Документация для действия есть , но камень должен обернуть все правильно, как и для других действий, которые я пробовал.

В конце концов, я не знаю, где отлаживать, так как это похоже на внутреннюю обработку wsdl.

1 Ответ

0 голосов
/ 16 января 2019

Прошло много времени с тех пор, как я работал с мылом, но если вы знаете, что проблема заключается в пространстве имен, я просто написал бы 'ins0:long' => <number> вместо long:<number>. Вот так я обхожу эти проблемы.

...