Bing Ads API-get_ad_extensions_associations的savon错误

时间:2019-01-10 11:02:29

标签: ruby savon bing-ads-api

维护宝石来包装bing ads 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的内部处理。

1 个答案:

答案 0 :(得分:1)

自从我使用soap以来已经很长时间了,但是如果您知道名称空间是问题,那么我只写'ins0:long' => <number>而不是long:<number>。这就是我规避这些问题的方式。