none
Advice regarding Exchange Web Services (EWS) findItem operation RRS feed

  • Question

  • Hi, 

    I am trying to use EWS to get the emails in a number of inboxes and send them on to a call logging solution.  Using SOAPUI I can get a list of message ID's from my Inbox so I anticipate the following workflow:  Connect to mailbox > Get list of message id's in Inbox (using findItem) > for each ID getItem to return the sender/subject/body/etc then forward to the call logging system.  The tool I am using to automate this is working for operations like createItem and findFolder, but findItems is complaining.

    Currently I get: "NonEmptyArrayOfPathsToElementTypeChoice cannot be null!!"

    If I locate this in findItem > itemShape > additionalProperties it gives me an option to set a "path" aka "BasePathToElementType" but I cannot see what this should be.  If I leave it blank I get: "The request failed schema validation: The 'http://schemas.xmlsoap.org/soap/envelope/:mustUnderstand' attribute is not declared."

    If I set a value (e.g. A) I get: "Unable to create complex or array type with value A, the value must be a saved variable from a prior job."

    I am using Automic's ONE Automation and their Web Service agent, I have their support looking at this to no avail, so I need advice from an EWS expert.  

    Thanks in advance for your help

    -Phill..

    P.s. Happy to WebEx if you think you can help.

    Monday, August 8, 2016 4:30 PM

Answers

  • <?xml version="1.0" encoding="UTF-8"?>
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
      <soapenv:Header>
        <ns1:ExchangeImpersonation soapenv:mustUnderstand="0" xmlns:ns1="http://schemas.microsoft.com/exchange/services/2006/types">
          <ns1:ConnectingSID>
            <ns1:PrincipalName>mailbox@domain</ns1:PrincipalName>
          </ns1:ConnectingSID>
        </ns1:ExchangeImpersonation>
        <ns1:MailboxCulture soapenv:mustUnderstand="0" xmlns:ns1="http://schemas.microsoft.com/exchange/services/2006/types">en</ns1:MailboxCulture>
        <ns1:RequestServerVersion Version="Exchange2010_SP2"
          soapenv:mustUnderstand="0" xmlns:ns1="http://schemas.microsoft.com/exchange/services/2006/types"/>    
        <ns1:TimeZoneContext soapenv:mustUnderstand="0" xmlns:ns1="http://schemas.microsoft.com/exchange/services/2006/types">
          <ns1:TimeZoneDefinition Id="UTC"/>
        </ns1:TimeZoneContext>
        <ns1:DateTimePrecision xmlns:ns1="http://schemas.microsoft.com/exchange/services/2006/types">Seconds</ns1:DateTimePrecision>
      </soapenv:Header>
      <soapenv:Body>
        <ns2:FindItem Traversal="Shallow" xmlns:ns2="http://schemas.microsoft.com/exchange/services/2006/messages">
          <ns2:ItemShape>
            <ns1:BaseShape xmlns:ns1="http://schemas.microsoft.com/exchange/services/2006/types">AllProperties</ns1:BaseShape>
          </ns2:ItemShape>
          <ns2:IndexedPageItemView MaxEntriesReturned="1000" Offset="0" BasePoint="Beginning" />
          <ns2:ParentFolderIds>
            <ns1:DistinguishedFolderId  xmlns:ns1="http://schemas.microsoft.com/exchange/services/2006/types" Id="contacts" />
          </ns2:ParentFolderIds>
        </ns2:FindItem>
      </soapenv:Body>
    </soapenv:Envelope>
    If I drop that attribute out of the DateTimePrecision Node (or just drop that altogether then I can make your request work) see above
    Wednesday, August 10, 2016 2:39 AM
  • Thanks Glen - I have used your reply to narrow it down further to the inclusion of the soapenv:mustUnderstand="0" on the DateTimePrecision - if I remove this it works.  The trouble is the vendor solution adds this (not me) so I will take this up with them.

    I appreciate all the help, hope this helps someone else in the future.

    • Marked as answer by FateAccompli Wednesday, August 10, 2016 9:38 AM
    Wednesday, August 10, 2016 9:38 AM

All replies

  • You need to look at what the SOAP message that your application produces is (and post that if it doesn't work as your question is very vendor specific). There are plenty of examples of what the SOAP should look like eg

    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <soap:Header>
        <t:RequestServerVersion Version="Exchange2010" />
      </soap:Header>
      <soap:Body>
        <m:FindItem Traversal="Shallow">
          <m:ItemShape>
            <t:BaseShape>AllProperties</t:BaseShape>
          </m:ItemShape>
          <m:IndexedPageItemView MaxEntriesReturned="3" Offset="5" BasePoint="Beginning" />
          <m:SortOrder>
            <t:FieldOrder Order="Ascending">
              <t:FieldURI FieldURI="contacts:DisplayName" />
            </t:FieldOrder>
          </m:SortOrder>
          <m:ParentFolderIds>
            <t:DistinguishedFolderId Id="contacts" />
          </m:ParentFolderIds>
        </m:FindItem>
      </soap:Body>
    </soap:Envelope>

    You can test your SOAP using the POST tool in the EWSEditor https://ewseditor.codeplex.com/ (It sounds to me you actually adding into the SOAP message fields that aren't needed).

    Cheers
    Glen


    Tuesday, August 9, 2016 4:27 AM
  • Thanks for your reply Glen.  The vendor has provided a new version of their product that no longer requires the "NonEmptyArrayOfPathsToElementTypeChoice".

    However I am still getting the mustUnderstand attribute error:

    SOAP request xml
    <?xml version="1.0" encoding="UTF-8"?>
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
      <soapenv:Header>
        <ns1:ExchangeImpersonation soapenv:mustUnderstand="0" xmlns:ns1="http://schemas.microsoft.com/exchange/services/2006/types">
          <ns1:ConnectingSID>
            <ns1:PrincipalName>name.removed</ns1:PrincipalName>
          </ns1:ConnectingSID>
        </ns1:ExchangeImpersonation>
        <ns1:MailboxCulture soapenv:mustUnderstand="0" xmlns:ns1="http://schemas.microsoft.com/exchange/services/2006/types">en</ns1:MailboxCulture>
        <ns1:RequestServerVersion Version="Exchange2010_SP2"
          soapenv:mustUnderstand="0" xmlns:ns1="http://schemas.microsoft.com/exchange/services/2006/types"/>
        <ns1:TimeZoneContext soapenv:mustUnderstand="0" xmlns:ns1="http://schemas.microsoft.com/exchange/services/2006/types">
          <ns1:TimeZoneDefinition Id="UTC"/>
        </ns1:TimeZoneContext>
        <ns1:DateTimePrecision soapenv:mustUnderstand="0" xmlns:ns1="http://schemas.microsoft.com/exchange/services/2006/types">Seconds</ns1:DateTimePrecision>
      </soapenv:Header>
      <soapenv:Body>
        <ns2:FindItem Traversal="Shallow"
          xmlns:ns2="http://schemas.microsoft.com/exchange/services/2006/messages"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns2:FindItemType">
          <ns2:ItemShape>
            <ns1:BaseShape xmlns:ns1="http://schemas.microsoft.com/exchange/services/2006/types">Default</ns1:BaseShape>
          </ns2:ItemShape>
        </ns2:FindItem>
      </soapenv:Body>
    </soapenv:Envelope>
    
    SOAP response xml
    <?xml version="1.0" encoding="UTF-8"?>
    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
      <s:Body>
        <s:Fault>
          <faultcode xmlns:a="http://schemas.microsoft.com/exchange/services/2006/types">a:ErrorSchemaValidation</faultcode>
          <faultstring xml:lang="en-GB">The request failed schema validation: The 'http://schemas.xmlsoap.org/soap/envelope/:mustUnderstand' attribute is not declared.</faultstring>
          <detail>
            <e:ResponseCode xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors">ErrorSchemaValidation</e:ResponseCode>
            <e:Message xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors">The request failed schema validation.</e:Message>
            <t:MessageXml xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
              <t:LineNumber>1</t:LineNumber>
              <t:LinePosition>938</t:LinePosition>
              <t:Violation>The 'http://schemas.xmlsoap.org/soap/envelope/:mustUnderstand' attribute is not declared.</t:Violation>
            </t:MessageXml>
          </detail>
        </s:Fault>
      </s:Body>
    </s:Envelope>


    Tuesday, August 9, 2016 3:26 PM
  • <?xml version="1.0" encoding="UTF-8"?>
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
      <soapenv:Header>
        <ns1:ExchangeImpersonation soapenv:mustUnderstand="0" xmlns:ns1="http://schemas.microsoft.com/exchange/services/2006/types">
          <ns1:ConnectingSID>
            <ns1:PrincipalName>mailbox@domain</ns1:PrincipalName>
          </ns1:ConnectingSID>
        </ns1:ExchangeImpersonation>
        <ns1:MailboxCulture soapenv:mustUnderstand="0" xmlns:ns1="http://schemas.microsoft.com/exchange/services/2006/types">en</ns1:MailboxCulture>
        <ns1:RequestServerVersion Version="Exchange2010_SP2"
          soapenv:mustUnderstand="0" xmlns:ns1="http://schemas.microsoft.com/exchange/services/2006/types"/>    
        <ns1:TimeZoneContext soapenv:mustUnderstand="0" xmlns:ns1="http://schemas.microsoft.com/exchange/services/2006/types">
          <ns1:TimeZoneDefinition Id="UTC"/>
        </ns1:TimeZoneContext>
        <ns1:DateTimePrecision xmlns:ns1="http://schemas.microsoft.com/exchange/services/2006/types">Seconds</ns1:DateTimePrecision>
      </soapenv:Header>
      <soapenv:Body>
        <ns2:FindItem Traversal="Shallow" xmlns:ns2="http://schemas.microsoft.com/exchange/services/2006/messages">
          <ns2:ItemShape>
            <ns1:BaseShape xmlns:ns1="http://schemas.microsoft.com/exchange/services/2006/types">AllProperties</ns1:BaseShape>
          </ns2:ItemShape>
          <ns2:IndexedPageItemView MaxEntriesReturned="1000" Offset="0" BasePoint="Beginning" />
          <ns2:ParentFolderIds>
            <ns1:DistinguishedFolderId  xmlns:ns1="http://schemas.microsoft.com/exchange/services/2006/types" Id="contacts" />
          </ns2:ParentFolderIds>
        </ns2:FindItem>
      </soapenv:Body>
    </soapenv:Envelope>
    If I drop that attribute out of the DateTimePrecision Node (or just drop that altogether then I can make your request work) see above
    Wednesday, August 10, 2016 2:39 AM
  • Thanks Glen - I have used your reply to narrow it down further to the inclusion of the soapenv:mustUnderstand="0" on the DateTimePrecision - if I remove this it works.  The trouble is the vendor solution adds this (not me) so I will take this up with them.

    I appreciate all the help, hope this helps someone else in the future.

    • Marked as answer by FateAccompli Wednesday, August 10, 2016 9:38 AM
    Wednesday, August 10, 2016 9:38 AM