PHP SOAP请求失败,错误消息请求错误
我试图将lead添加到ExactTargetAPI中,但总是出现错误“请求错误”。所有的代码都是按照Exacttarget的示例编写的,有人能帮忙吗 以下是SOPA信封:PHP SOAP请求失败,错误消息请求错误,php,curl,soap,salesforce,exacttarget,Php,Curl,Soap,Salesforce,Exacttarget,我试图将lead添加到ExactTargetAPI中,但总是出现错误“请求错误”。所有的代码都是按照Exacttarget的示例编写的,有人能帮忙吗 以下是SOPA信封: <Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Header> <Security xmlns="h
<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>
请帮助您的示例SOAP信封中的电子邮件地址似乎无效。不确定为什么在生日属性值周围有单引号 下面是一个工作SOAP信封,我用来在Enterprise 2.0帐户中测试此功能:
<?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>
--大部分标记为和。如果要测试SOAP请求,请尝试我的漂亮脚本:
<?php
if(isset($_POST['request'])){
$XML = $_POST['request'];
$URL = $_POST['url'];
$ch = curl_init("$URL");
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_TIMEOUT, 60);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch,CURLOPT_POSTFIELDS,$XML);
$result=curl_exec ($ch);
curl_close($ch);
}
?>
<form method="post" style="margin: 0; padding: 0;">
<input name='url' type="text" placeholder="URL here" value="<?php if(isset($_POST['url'])) echo $_POST['url']; ?>" style="height: 10%; width:90%">
<button style="width: 9%; height: 10%;">LOAD SOAP</button>
<div style="width: 49%; float:left;">
<textarea style="width: 100%; height:89%;" placeholder='REQUEST HERE' name="request"><?php if(isset($_POST['request'])) echo $_POST['request']; ?></textarea>
</div>
<div style="width: 50%; display: inline;">
<textarea placeholder="RESPONSE HERE" disabled="true" style="width: 50%; height: 40%;"><?php if(isset($result)) echo strtok($result, '<'); ?></textarea>
<textarea placeholder="RESPONSE HERE" disabled="true" style="width: 50%; height: 49%;"><?php if(isset($result)) $config = array('indent'=>true,'output-xml'=>true,'input-xml'=> true); $tidyxml = new tidy; $tidyxml->parseString(strstr($result, '<'), $config, 'utf8'); echo $tidyxml;?></textarea>
</div>
</form>
哪里是$dataString.?$dataString是SOAP信封
<?php
if(isset($_POST['request'])){
$XML = $_POST['request'];
$URL = $_POST['url'];
$ch = curl_init("$URL");
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_TIMEOUT, 60);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch,CURLOPT_POSTFIELDS,$XML);
$result=curl_exec ($ch);
curl_close($ch);
}
?>
<form method="post" style="margin: 0; padding: 0;">
<input name='url' type="text" placeholder="URL here" value="<?php if(isset($_POST['url'])) echo $_POST['url']; ?>" style="height: 10%; width:90%">
<button style="width: 9%; height: 10%;">LOAD SOAP</button>
<div style="width: 49%; float:left;">
<textarea style="width: 100%; height:89%;" placeholder='REQUEST HERE' name="request"><?php if(isset($_POST['request'])) echo $_POST['request']; ?></textarea>
</div>
<div style="width: 50%; display: inline;">
<textarea placeholder="RESPONSE HERE" disabled="true" style="width: 50%; height: 40%;"><?php if(isset($result)) echo strtok($result, '<'); ?></textarea>
<textarea placeholder="RESPONSE HERE" disabled="true" style="width: 50%; height: 49%;"><?php if(isset($result)) $config = array('indent'=>true,'output-xml'=>true,'input-xml'=> true); $tidyxml = new tidy; $tidyxml->parseString(strstr($result, '<'), $config, 'utf8'); echo $tidyxml;?></textarea>
</div>
</form>