Bing 广告 api - get_ad_extensions_associations 的萨翁错误

Bing ads api - savon error for get_ad_extensions_associations

维护 gem 来包装 bing 广告 api,我正在使用 this wsdl from 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>

操作的文档 is there 但 gem 应该像我尝试的其他操作一样正确地包装所有内容。

最后我不知道在哪里调试,因为它似乎是 wsdl 的内部处理。

我已经有很长时间没有使用 soap 了,但如果您知道名称空间是问题所在,那么我会写 'ins0:long' => <number> 而不是 long:<number>。这就是我规避这些问题的方法。