【发布时间】:2010-06-28 15:26:44
【问题描述】:
这是一个我一直在处理的老问题,但仍然没有解决方案,所以尝试一种新方法。
如何提前(在脚本执行结束之前)发送 SOAP 响应?
这些问题是在 30 秒之前未发送 ACK 文件时引起的,因为该过程需要比分配的时间更长的时间才能完成。
flush() 不工作,得到这个错误:
org.xml.sax.SAXParseException: XML 文档结构必须在同一个实体内开始和结束。
没有 flush() 我得到了这个
org.xml.sax.SAXParseException: 文件过早结束。
脚本进程可能需要 180 秒才能完成,等待响应的服务器只等待大约 30 秒才超时(导致上述错误)。
有什么想法可以解决这个问题吗?
这里是一些代码:这是我为即将到来的 SOAP 请求接受和发送 ACK 文件的方式
$data = 'php://input';
$content = file_get_contents($data);
if($content) {
respond('true');
} else {
respond('false');
}
响应函数
function respond($tf) {
$ACK = <<<ACK
<?xml version = "1.0" encoding = "utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<notifications xmlns="http://soap.sforce.com/2005/09/outbound">
<Ack>$tf</Ack>
</notifications>
</soapenv:Body>
</soapenv:Envelope>
ACK;
print trim($ACK);
}
PHP 使用单线程处理方法,在线程完成处理之前不会发回 ACK 文件。有没有办法在 ACK 提交后关闭套接字并继续处理,这样我就不会在发送服务器上遇到这些超时问题?
【问题讨论】:
标签: php xml soap salesforce flush