Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

NuSoap and Exchange 2007

Help
seaan
2009-06-04
2013-06-06
  • seaan
    seaan
    2009-06-04

    Hello,
    I'm developing a simple client to consume Exchange 2007 web services and access my own Outlook inbox.

    I can successfully retrieve information like count of unread messages and message headers which make use of operations "FindFolder" and "FindItem": nuSOAP works like a charm.

    To retrieve full messages, the operation to use is "GetItem" and this is where nuSOAP  fails.
    When I execute:
    $response=soap_client->call('GetItem',$xmlout); //where $xmlout contains the formatted request

    no error is detected but $response is null.

    However, if I inspect soap_client->response,  I see the correct soap payload as per Exchange 2007 specs (including message Body etc.)
    So the question is, why nuSOAP is unable to parse the SOAP payload, leaving the return variable empty and without returning an error?
    Any suggestions on how to troubleshoot this?

    See below an abridged snippet of the response, where I'm just reporting a few of the many items found in the response payload:

    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soap:Header>
    <t:ServerVersionInfo MajorVersion="8" MinorVersion="1" MajorBuildNumber="359" MinorBuildNumber="2" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" />
    </soap:Header>
    <soap:Body>
    <m:GetItemResponse xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
    <m:ResponseMessages><m:GetItemResponseMessage ResponseClass="Success">
    <m:ResponseCode>NoError</m:ResponseCode>
    <m:Items>
    <t:Message>
    <t:Body BodyType="HTML">
    THIS IS THE BODY OF THE MESSAGE
    </t:Body>
    <t:DateTimeReceived>2009-06-04T09:39:49Z</t:DateTimeReceived>
    <t:Size>5465</t:Size>
    ...
    </t:Message>
    </m:Items>
    </m:GetItemResponseMessage>
    </m:ResponseMessages>
    </m:GetItemResponse>
    </soap:Body>
    </soap:Envelope>

    Thanks in advance
    Sergio

     
    • seaan
      seaan
      2009-06-07

      Hi,
      problem solved.
      For the record and posterity, the issue resides in the way nuSOAP handles elements in the XML soap payload through callback "start_element" in file nusoap.php.
      It searches for the beginning of the Body element without ensuring that it's a SOAP body. Since Exchange response to GetItem contains a nested Body item as part of the message (see above), this gets nusoap parser quite confused.

      The solution is to include an additional check at line 6565 on the tag prefix which must be "soap" like this:

      elseif($name == 'Body' && $this->status = 'envelope' and $prefix=='soap'){

      Bye
      Sergio