【发布时间】:2014-10-13 17:38:41
【问题描述】:
有谁知道如何使用 PHP 响应 EWS(Exchange Web 服务)推送通知。
我已启动EWS Push Subscription,但当 EWS 向我的服务发送 SOAP 通知时,我似乎无法发送正确的 SOAP 响应(以保持订阅有效)。
取自this页面,我的印象是我的SOAP响应应该如下:
<s:Envelope xmlns:s= "http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<SendNotificationResult xmlns="http://schemas.microsoft.com/exchange/services/2006/messages">
<SubscriptionStatus>OK</SubscriptionStatus>
</SendNotificationResult>
</s:Body>
</s:Envelope>
但是,EWS 似乎并不认为我的回复是有效的。
我尝试了以下 2 个代码 sn-ps,但没有成功:
使用带有 Content-Type 标头的 SOAP 字符串响应
header( 'Content-Type: text/xml; charset=utf-8' );
echo '<?xml version="1.0" encoding="utf-8"?>'.
'<s:Envelope xmlns:s= "http://schemas.xmlsoap.org/soap/envelope/">'.
'<s:Body>'.
'<SendNotificationResult xmlns="http://schemas.microsoft.com/exchange/services/2006/messages">'.
'<SubscriptionStatus>OK</SubscriptionStatus>'.
'</SendNotificationResult>'.
'</s:Body>'.
'</s:Envelope>';
或使用 SOAP 服务响应
class ewsService {
public function SendNotification( $arg ) {
$result = new EWSType_SendNotificationResultType();
$result->SubscriptionStatus = 'OK';
return $result;
}
}
$server = new SoapServer( null, array(
'uri' => $_SERVER['REQUEST_SCHEME'].'://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'],
));
$server->setObject( new ewsService() );
$server->handle();
知道我在代码中使用的类来自PHP-EWS library 可能会有所帮助。
任何帮助将不胜感激。
我还发布了一个更具体的问题here,但没有得到任何回复,所以我想问一下是否有人真的用任何方法让它工作了。
【问题讨论】:
-
你知道传入的推送消息记录在哪里吗?
-
@simbabque 这是很久以前的事了,不记得了。你必须用谷歌搜索它,但他们为 365 实现了 REST API,我不会再为 SOAP 实现而烦恼了。如果您无法支持旧版本,那很遗憾。
标签: php web-services soap exchangewebservices