du4373 2015-02-20 03:11
浏览 92

PHP SOAP请求失败,错误消息错误请求

I tried to add the lead to exacttarget api, but always get error "Bad Request". All the code are follow the sample from Exacttarget, can anyone hlep

Below is the SOPA envelop:

<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <Header>
     <Security xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
        <UsernameToken>
           <Username>****</Username>
           <Password>****</Password>
        </UsernameToken>
     </Security>
  </Header>
  <Body>
     <CreateRequest xmlns="http://exacttarget.com/wsdl/partnerAPI">
        <Objects xsi:type="Subscriber">
           <EmailAddress>test@example</EmailAddress>
           <SubscriberKey>test@example</SubscriberKey>
           <EmailTypePreference>HTML</EmailTypePreference>
           <Attributes>
              <Name>FIRST_NAME</Name>
              <Value>test</Value>
           </Attributes>
           <Attributes>
              <Name>LAST_NAME</Name>
              <Value>test</Value>
           </Attributes>
           <Attributes>
              <Name>BIRTHDAY</Name>
              <Value>'04/03/1988'</Value>
           </Attributes>
           <lists>
                    <partnerkey xsi:nil="true"></partnerkey>
                    <id>111111</id>
                    <objectid xsi:nil="true"></objectid>
                    <status>Active</status>
            </lists>
           <Status>Active</Status>
        </Objects>
     </CreateRequest>
  </Body>
</Envelope>

Here is my curl code:

$endpoint = 'https://webservice.s6.exacttarget.com/service.asmx';
    $soap_do = curl_init();
    curl_setopt($soap_do, CURLOPT_URL, $endpoint);
    curl_setopt($soap_do, CURLOPT_CONNECTTIMEOUT, 10);
    curl_setopt($soap_do, CURLOPT_TIMEOUT, 10);
    curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($soap_do, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($soap_do, CURLOPT_POST, true);
    curl_setopt($soap_do, CURLOPT_POSTFIELDS, $dataString);
    curl_setopt($soap_do, CURLOPT_HTTPHEADER, array('Content-Type: text/xml; charset=utf-8', 'Content-Length: ' . strlen($dataString),'SOAPAction: "http://exacttarget.com/wsdl/partnerAPI/Create"'));
$result = curl_exec($soap_do);

Please help

  • 写回答

2条回答 默认 最新

  • du958642589 2015-02-23 15:40
    关注

    The email address in your sample SOAP envelope doesn't appear to be valid. Not sure why you have single quote around the Birthday attribute value.

    Here's a working SOAP envelope that I used to test this functionality in an Enterprise 2.0 account:

    <?xml version="1.0" encoding="UTF-8"?>
    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing">
       <s:Header>
          <a:Action s:mustUnderstand="1">Create</a:Action>
          <a:MessageID>urn:uuid:4f8fcac0-3506-4d01-b946-c197fad3517a</a:MessageID>
          <a:ReplyTo>
             <a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address>
          </a:ReplyTo>
       </s:Header>
       <s:Body xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
          <CreateRequest xmlns="http://exacttarget.com/wsdl/partnerAPI">
             <Options>
                <Client>
                   <ID><!-- BU MID GOES HERE --></ID>
                </Client>
             </Options>
             <Objects xmlns:q1="http://exacttarget.com/wsdl/partnerAPI" xsi:type="q1:Subscriber">
                <q1:Client>
                   <q1:ID><!-- BU MID GOES HERE --></q1:ID>
                </q1:Client>
                <q1:PartnerKey xsi:nil="true" />
                <q1:ObjectID xsi:nil="true" />
                <q1:EmailAddress>aspriggs@degdigital.com</q1:EmailAddress>
                <q1:Attributes>
                   <q1:Name>Attribute1</q1:Name>
                   <q1:Value>whee</q1:Value>
                </q1:Attributes>
                <q1:SubscriberKey>aspriggs@degdigital.com</q1:SubscriberKey>
                <q1:Status>Active</q1:Status>
                <q1:EmailTypePreference>HTML</q1:EmailTypePreference>
                <q1:Lists>
                   <q1:PartnerKey xsi:nil="true" />
                   <q1:ID><!-- LIST ID GOES HERE --></q1:ID>
                   <q1:ObjectID xsi:nil="true" />
                   <q1:Status>Active</q1:Status>
                </q1:Lists>
             </Objects>
          </CreateRequest>
       </s:Body>
    </s:Envelope>
    

    Also, there are a lot more people answering SFMC questions over at salesforce.stackexchange.com -- mostly tagged with marketing-cloud, ampscript, and soap-api.

    评论

报告相同问题?

悬赏问题

  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 一直显示正在等待HID—ISP