In using PHP - Curl - and Soapui (to construct and validate the necessary soap/xml script to send in the Curl Postfields) I find that all I get returned when trying to, for example, add a contact to the default contacts folder are the wsdl definitions in xml format. I believe I have resolved some of my earlier issues by using the Curl code set up as:
$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);
The data in $xmlstr is:
$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;
The response/return from the server is:
HTTP/1.1 200 OK
Content-Type: text/xml
Last-Modified: Tue, 05 Feb 2013 23:00:32 GMT
Accept-Ranges: bytes
ETag: "0685999f43ce1:0"
Server: Microsoft-IIS/7.5
Persistent-Auth: true
X-Powered-By: ASP.NET
Date: Mon, 08 Apr 2013 10:13:46 GMT
Content-Length: 101206
followed by the xml formatted definitions from the wsdl file.
I would be thankful for some direction on this. I am experienced in several coding languages, but soap/xml and the Curl component in PHP is not within my current knowledge.