Google Apps SOAP 请求似乎发送 GET 请求而不是 POST

汤普森b06

我正在尝试发送一个我知道通过 SOAPUI 进行测试的简单 SOAP 请求,但似乎下面的 Google Apps 脚本忽略了 POST 方法并作为 get 发送,因为响应以 WSDL 页面的 GET 返回。

var webservice = 'https://ws.campaigner.com/2013/01/contactmanagement.asmx?WSDL';
//Various XML parsing.  
var xml = '<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:ns="https://ws.campaigner.com/2013/01">'
+'   <soap:Header/>'
+'   <soap:Body>'
+'      <ns:ImmediateUpload>'
+'         <!--Optional:-->'
+'        <ns:authentication>'
+'            <!--Optional:-->'
+'            <ns:Username>user</ns:Username>'
+'            <!--Optional:-->'
+'            <ns:Password>pass</ns:Password>'
+'         </ns:authentication>'
+'         <ns:UpdateExistingContacts>true</ns:UpdateExistingContacts>'
+'         <ns:TriggerWorkflow>false</ns:TriggerWorkflow>'
+'         <!--Optional:-->'
+'         <ns:contacts>'
+'            <!--Zero or more repetitions:-->'
+'            <ns:ContactData>'
+'               <!--Optional:-->'
+'               <ns:ContactKey>'
+'                  <!--<ns:ContactId>?</ns:ContactId>-->'
+'                  <!--Optional:-->'
+'                  <ns:ContactUniquedentifier>email</ns:ContactUniqueIdentifier>'
+'               </ns:ContactKey>'
+'               <!--Optional:-->'
+'               <ns:EmailAddress IsNull="false">email</ns:EmailAddress>'
+'               <!--Optional:-->'
+'               <ns:FirstName IsNull="true"></ns:FirstName>'
+'               <!--Optional:-->'
+'               <ns:LastName IsNull="true"></ns:LastName>'
+'               <!--Optional:-->'
+'               <ns:PhoneNumber IsNull="true"></ns:PhoneNumber>'
+'               <!--Optional:-->'
+'               <ns:Fax IsNull="true"></ns:Fax>'
+'               <ns:Status>Subscribed</ns:Status>'
+'               <ns:MailFormat>Both</ns:MailFormat>'
+'               <ns:IsTestContact>false</ns:IsTestContact>'
+'               <!--Optional:-->'
+'               <ns:CustomAttributes>'
+'                  <!--Zero or more repetitions:-->'
+'                  <ns:CustomAttribute Id="9553008" IsNull="false">08/19/2020 4:00 PM</ns:CustomAttribute>'
+'               </ns:CustomAttributes>'
+'               <!--Optional:-->'
+'               <ns:AddToGroup>'
+'                  <!--Zero or more repetitions:-->'
+'                  <!--<ns:int>?</ns:int>-->'
+'               </ns:AddToGroup>'
+'               <!--Optional:-->'
+'               <ns:RemoveFromGroup>'
+'                  <!--Zero or more repetitions:-->'
+'                  <!--<ns:int>?</ns:int>-->'
+'               </ns:RemoveFromGroup>'
+'            </ns:ContactData>'
+'         </ns:contacts>'
+'         <!--Optional:-->'
+'         <ns:globalAddToGroup>'
+'            <!--Zero or more repetitions:-->'
+'            <!--<ns:int>?</ns:int>-->'
+'         </ns:globalAddToGroup>'
+'         <!--Optional:-->'
+'         <ns:globalRemoveFromGroup>'
+'            <!--Zero or more repetitions:-->'
+'            <!--<ns:int>?</ns:int>-->'
+'         </ns:globalRemoveFromGroup>'
+'      </ns:ImmediateUpload>'
+'   </soap:Body>'
+'</soap:Envelope>';

var options = {   
  headers:{
       method : 'post',
       payload  : xml,
       contentType : 'text/xml; charset=utf-8',
      'SOAPAction' : '"https://ws.campaigner.com/2013/01/ImmediateUpload"',
       muteHttpExceptions : true
  },

};  


//UrlFetchApp is a powerful built-in library from Google  

var serviceaddress =  webservice ;
  var response = UrlFetchApp.fetch(serviceaddress, options); 

我是使用 Google Apps 脚本的新手。

插件仓库

您的选项对象格式不正确。它应该读作:

var options = {
    method:"POST",
    contentType: "text/xml; charset=utf-8",
    muteHttpExceptions:true,
    headers:{
        "SOAPAction": "https://ws.campaigner.com/2013/01/ImmediateUpload"
    },
    payload:xml
};

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章