savonrb / savon

Heavy metal SOAP client
https://www.savonrb.com
MIT License
2.07k stars 616 forks source link

Bing ads sdk - failure for one action #895

Closed apneadiving closed 5 years ago

apneadiving commented 5 years ago

Bug report

Maintaining a gem to wrap bing ads api, I am using this wsdl from bing.

Most api calls work fine so far (thanks!), but I am stumbling upon the get_ad_extensions_associations one.

What I type is:

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

What is sent to bing is the following:

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>

What I get back is the following:

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>

Documentation for the action is there but the gem is supposed to wrap everything properly as it does for the other actions I tried.

Edit: this happens each time an argument is an ArrayOflong. Maybe I dont pass data as expected?

In the end I do not know where to debug as it seems to be internal handling of the wsdl.

System information:

apneadiving commented 5 years ago

It seems to be a problem of namespaces.

I have <tns:long>8177659860409</tns:long> Whereas it should be <ins0:long>8177659860409</ins0:long>

This should be the wsdl job to adjust namespaces right? How could I change it?

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Ecco commented 5 years ago

I'm being hit by the exact same issue, on another WSDL

Ecco commented 5 years ago

Seems related to #874

Ecco commented 5 years ago

Also, this stale bot thing is lame. That issue is still there, why close the issue?