can't get the Talking SOAP With Exchange to work

Discussion in 'HOWTO-Related Questions' started by eescudier, Jan 27, 2009.

  1. eescudier

    eescudier New Member


    I am trying to use the code samples in this HOWTO, but I have some problems.


    are working correctly, but I can't get anything else to work.

    My Exchange server is running Exchange 2007

    My PHP box is a somewhat old Ubuntu 6.1 with PHP 5

    These are the kind of errors that I don't know what to do with :

    Fatal error: Uncaught SoapFault exception: [Client] SoapSlient::__doRequest() returned non string value in /var/www/html/exch_eric/index.php:197 Stack trace: #0 [internal function]: SoapClient->__call('FindFolder', Array) #1 /var/www/html/exch_eric/index.php(197): ExchangeNTLMSoapClient->FindFolder(Object(stdClass)) #2 {main} thrown in /var/www/html/exch_eric/index.php on line 197

    Any Ideas ?

    Thanks for any help.

  2. ErikCederstrand

    ErikCederstrand New Member

    Hi Eric

    The user bosco here on this site had the same. We mailed back and forth and concluded it was a SOAP XML-generation issue but I don't know if he found a solution.

  3. eescudier

    eescudier New Member

    Could you tell us wich platform (OS version and PHP version) you used for your HOWTO ?
    Maybe this way it will be easier for me to get it to work.

    Thanks in advance

  4. ErikCederstrand

    ErikCederstrand New Member

    I'm running on FreeBSD 7.1 with PHP 5.2.8 with SOAP and CURL extensions.
  5. eescudier

    eescudier New Member

    Unbuntu 8.10

    I installed a Ubuntu 8.10 server vith PHP 5.2.6, SOAP and CURL extensions and everything works fine... :D

    Thanks for your help.

  6. ErikCederstrand

    ErikCederstrand New Member

    I'm glad to hear that. I've had some other replies to the howto, but you're the first user I've heard about who actually got it to work :)
  7. jmclen

    jmclen New Member

    This may help

    If you followed the instructions like me and got this problem it is probably due to an authentication issue. The reason everything else doesn't work is because the first 2 commands are simply reading your local xml file.

    In my case, I had a test exchange server that did not have a valid certificate.
    In the NTLMSoapClient class, I had to add:

    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);

    and again in the createBuffer function in the NTLMStream class I had to add:

    curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($this->ch, CURLOPT_SSL_VERIFYHOST, false);

    Obviously in a production environment you want valid certificates, but maybe this will help you out.
  8. eoasis

    eoasis New Member

    Using work-around throws error

    Trying the work-around where Services.wsdl is stored locally and the

    <wsdl:service name="ExchangeServices">

    is added. Also messages.xsd and types.xsd are stored locally.

    I'm getting this error:

    PHP Fatal error: SOAP-ERROR: Parsing Schema: can't import schema from '/home/ews/messages.xsd'
  9. eoasis

    eoasis New Member

    Exchange 2007 SOAP PHP examples working

    I switched to ubuntu server 8.10, upgraded to PHP 5.2.8, did an apt-get upgrade php-soap, and upgraded curl to version 7.18.2

    Here are the steps I followed after upgrading:

    1. I grabbed the Services.wsdl, Types.xsd, and Messages.xsd directly from the exchange server and placed them locally.
    2. Added the "ExchangeServiceBinding" to the Services.wsdl file per Erik Cerstand's excellent original post.
    3. Renamed the Services.wsdl, Types.xsd, and Messages.xsd to all lower case so they could be found.

    I can get all the examples working from Erik's excellent blog post.

    However, I believe there is some kind of a PHP-SOAP parsing error because when trying to do a "CreateItem" for e-mail, I'm unable to properly specify both the <Body> tag and it's attribute <Body BodyType="Text"> in PHP so that the parser formats it correctly.

    Has anyone gotten "CreateItem" for e-mail to work? Can you post the PHP example code?

    And Thanks! Erik for the original example!
  10. jmclen

    jmclen New Member


    I've gotten just about everything else to work except UpdateItem. Has anyone gotten this working?
  11. eoasis

    eoasis New Member

    Check your date ranges if failing schema validation

    What error message are you getting? Check the date ranges you are passing and make sure, for example, you don't pass an invalid date range. For example, Feb. only has 28 days so if you pass this it will fail schema validation:

    $FindItem->CalendarView->EndDate = "2008-02-31T00:00:00Z";
  12. jmclen

    jmclen New Member


    My problem is not with FindItem, it is with UpdateItem. If anyone has a working example I would love to see it. The error I'm getting is regarding the Path not being defined. I've been trying to find this in the schema, but haven't yet.
  13. eoasis

    eoasis New Member

    Please post the php for UpdateItem

    Sorry for not reading more carefully. Can you post the PHP snippet you are using to form the UpdateItem request?
  14. jmclen

    jmclen New Member


    What I really need to see is a working example. I've tried many things and keep getting the message "Uncaught SoapFault exception: [Client] SOAP-ERROR: Encoding: object hasn't 'Path' property".

    an example of the code I've tried would be:
    $client = new ExchangeNTLMSoapClient($wsdl);
    $UpdateItem->ConflictResolution = "AutoResolve";
    $UpdateItem->ItemChanges->ItemChange->ItemId->Id = $itemid;
    $UpdateItem->ItemChanges->ItemChange->ItemId->ChangeKey = $changekey;
    $UpdateItem->ItemChanges->ItemChange->Updates->SetItemField->Subject = $newsubject;
    $result = $client->UpdateItem($UpdateItem);

    Again, I've manage to find items, create and delete items. This is the last one for me to tackle and I just haven't seen any examples of it.

    Thank You,
  15. eoasis

    eoasis New Member

    Are you missing required attribute MessageDisposition?


    What happens when you also add the MessageDisposition attribute?

    //MessageDisposition is one of:
    //SaveOnly The item is updated and saved back to its current folder.
    // SendOnly The item is updated and sent but no copy is saved.
    //SendAndSaveCopy The item is updated and a copy is saved in the folder // identified by the SavedItemFolderId element.

    $UpdateItem->MessageDisposition = "SaveOnly";

    Also, if you got CreateItem to work, I'm completely stumped on that one. Here's my PHP code which will send a message with a blank body. But as soon as I add the body text, I get a schema error.

    $CreateItem->MessageDisposition = "SendAndSaveCopy";
    $CreateItem->SavedItemFolderId->DistinguisedFolderId->Id = "sentitems";
    $CreateItem->Items->Message->ItemClass = "IPM.Note";
    $CreateItem->Items->Message->Subject = "My Subject";
    $CreateItem->Items->Message->Body->BodyType = "Text";

    // Adding this line for the body throws schema error

    $CreateItem->Items->Message->Body = "Body Text";

  16. jmclen

    jmclen New Member


    Are you getting UpdateItem to work for you? Adding the MessageDisposition hasn't helped any. If you've been able to update any item, even one field, I would love to see how you did it.

    Thanks for your help
  17. jmclen

    jmclen New Member

    I will also look at your CreateItem example and see what happens to me. I haven't tried populating the body of a message yet. I will let you know what happens when I do.
  18. eoasis

    eoasis New Member

    CreateItem just needs to properly pass PHP-Soap attribute

    In looking at your problem, I did solve my CreateItem blunder in passing attributes to PHP-Soap.

    Here is the code snippet that works.

    //Create array to pass attributes and value for PHP-Soap

    $CreateItem->Items->Message[$i]->Body[_] = "BODY TEXT";
    $CreateItem->Items->Message[$i]->Body['BodyType'] = "Text";

    //Results in <ns1:Body BodyType="Text">BODY TEXT</ns1:Body>

    I'll look at your UpdateItem next

  19. eoasis

    eoasis New Member

    UpdateItem PHP-Soap Error Encoding: object hasn't 'Path' property

    Jesse - I thought this error indicated that attribute "FieldURI" was not set. But I added this and I also get the "Path" error above.

    Try variations of FieldURI in your code in case I'm doing something else wrong:

    $UpdateItem->ItemChanges->ItemChange->Updates->SetItemField->FieldURI = "item:Subject";
  20. jmclen

    jmclen New Member


    Every variation I've tried yields the same result. If I specify Path in the array, then I get a different error about Path being abstract. Have you had any different luck?

Share This Page