在使用PHP-Curl和Soapui(構建並驗證在Curl Postfields中發送必需的soap/xml腳本)時,我發現我嘗試例如,向默認聯繫人文件夾添加聯繫人是xml格式的wsdl定義。我相信我已經通過捲曲代碼設置爲解決我的一些早期的問題:在通過PHP和Curl通過EWS連接到Microsoft Exchange 2007
$ch = curl_init('https://'.$host.'/ews/services.wsdl');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_NONE);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_NTLM);
curl_setopt($ch, CURLOPT_USERPWD, $username.':'.$password);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml; charset=utf-8' , 'Expect:'));
curl_setopt($ch, CURLOPT_POST, false);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET"); *this resolves the 405 http code return*
curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlstr);
$response = curl_exec($ch);
數據$ xmlstr是:從服務器
$xmlstr = <<<XML
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<soap:Body>
<CreateItem xmlns="http://schemas.microsoft.com/exchange/services/2006/messages">
<SavedItemFolderId xmlns="http://schemas.microsoft.com/exchange/services/2006/messages">
<DistinguishedFolderId Id="contacts" xmlns="http://schemas.microsoft.com/exchange/services/2006/types"/>
</SavedItemFolderId>
<Items xmlns="http://schemas.microsoft.com/exchange/services/2006/messages">
<Contact xmlns="http://schemas.microsoft.com/exchange/services/2006/types">
<FileAs>Friend A</FileAs>
<GivenName>Don</GivenName>
<CompanyName>AdventureWorks</CompanyName>
<EmailAddresses>
<Entry Key="EmailAddress1">[email protected]</Entry>
</EmailAddresses>
</Contact>
</Items>
</CreateItem>
</soap:Body>
</soap:Envelope>
XML;
響應/回報是:HTTP/1.1 200 OK
的Content-Type
:
文本/ XML的Last-Modified:塗即,2013年2月5日23時〇〇分32秒GMT
接受-範圍:字節
的ETag: 「0685999f43ce1:0」
服務器:Microsoft-IIS/7.5
持久驗證:真
X供電,通過:ASP.NET
日期:星期一,2013年4月8日10時十三分46秒GMT
的Content-Length:101206
,然後從WSDL文件中的XML格式的定義。
我會感激這方面的一些方向。我在幾種編碼語言方面經驗豐富,但soap/xml和PHP中的Curl組件並不在我目前的知識範圍內。