none
Where is the EntryId?

    Question

  • Hi!

    I would like to use the entryId (or the PR_ENTRY_ID), but i cannot find it. Can you help me,where may I find it? Thanks for all!

    Imre
    Saturday, January 05, 2008 2:01 PM

Answers

  •  

    Two main things that I noticed in the above code.

     

    1.  You are sending your request to the UM web service rather than the EWS endpoint.  You should be using:

     

    string url = https://domain/ews/Exchange.asmx;

     

    2.  Why not just set the credentials on the request directly and allow the request to negotiate the auth mechanism rather than mess with the basic headers yourself?

     

    With those changes your code worked fine on my box.

     

    Tuesday, January 15, 2008 8:07 PM

All replies

  • Where are you looking? What are you using? What are you trying to accomplish?

     

    I need more precisions to answer your question.

    Saturday, January 05, 2008 5:20 PM
  • Hi David,

    I generated my ExchnangeServiceBinding class with wsdl ("// This source code was auto-generated by wsdl, Version=2.0.50727.42."). I can find the ItemId of my message, but i would like to use the entryId or the PR_ENTRY_ID. I trying to convert with the next message:

    ...
    <ConvertId xmlns="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" DestinationFormat="EwsId">
    <SourceIds>
    <t:AlternateId Format="OwaId" Id="AAZcAGZhN2IxYTA0LWNiNzItN="
    Mailbox="user1@example.com"/>
    </SourceIds>
    ...

    What is the correct definition of the AlternateId Format (if i using the ItemId)?

    Thanks for any help!

    Imre

    Tuesday, January 08, 2008 3:33 PM
  • You have two options - one is that you can just request the PR_ENTRYID for an item in GetItem or FindItem such as:

     

    <GetItem xmlns=".../messages" xmlns:t=".../types">
     <ItemShape>
      <t:BaseShape>IdOnly</t:BaseShape>
      <t:AdditionalProperties>
       <t:ExtendedFieldURI PropertyTag="0x0FFF" PropertyType="Binary"/>
      </t:AdditionalProperties>
     </ItemShape>
     <ItemIds>
      <t:ItemId Id="AAAe..."/>
      </ItemIds>
    </GetItem>

     

    This will give you back the base64 encoded pr_entryid for the item as well as the itemid.

     

    If you already have the ItemId, then you can use ConvertId.  Note that if you have an RTM ItemId you will need to set the Format to "EwsLegacyId" like I have below.  If it is an SP1 Id, you will need to use "EwsId" for the  Format attribute.  Note that when going from ItemId to EntryId, the mailbox doesn't matter since the mailbox identifier is not encoded into PR_ENTRYID.  So you can put garbage in there.  The reverse of course is not true (entryid -> ItemId):


     

    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                   xmlns:xsd="
    http://www.w3.org/2001/XMLSchema"
                   xmlnsTongue Tiedoap="
    http://schemas.xmlsoap.org/soap/envelope/"
                   xmlns:t="
    http://schemas.microsoft.com/exchange/services/2006/types">
    <soap:Header>
     <t:RequestServerVersion Version="Exchange2007_SP1"/>
    </soap:Header>
    <soap:Body>
    <ConvertId xmlns="
    http://schemas.microsoft.com/exchange/services/2006/messages"
               xmlns:t="
    http://schemas.microsoft.com/exchange/services/2006/types"
               DestinationFormat="EntryId">
       <SourceIds>
          <t:AlternateId Mailbox="
    foo@goo.com"                 

                           Id="AAAeA..."
                            Format="EwsLegacyId"/>
       </SourceIds>
    </ConvertId>
    </soap:Body>
    </soap:Envelope>

    Thursday, January 10, 2008 4:21 PM
  • Hi David,

    I trying to use the next message, but i receive an Internal Server Error (500). The code what i trying (in c#):

    string sMsg= ("<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"");
    sMsg = sMsg + ("xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"");
    sMsg = sMsg + ("xmlnsTongue Tiedoap=\"http://schemas.xmlsoap.org/soap/envelope/\"");
    sMsg = sMsg + ("xmlns:t=\"http://schemas.microsoft.com/exchange/services/2006/types\">");
    sMsg = sMsg + ("<soap:Header>");
    sMsg = sMsg + ("<t:RequestServerVersion Version=\"Exchange2007_SP1\"/>");
    sMsg = sMsg + ("</soap:Header>");
    sMsg = sMsg + ("<soap:Body>");
    sMsg = sMsg + ("<ConvertId xmlns=\"http://schemas.microsoft.com/exchange/services/2006/messages\"");
    sMsg = sMsg + ("xmlns:t=\"http://schemas.microsoft.com/exchange/services/2006/types\"");
    sMsg = sMsg + ("DestinationFormat=\"EntryId\">");
    sMsg = sMsg + ("<SourceIds>");
    sMsg = sMsg + ("<t:AlternateId Mailbox=\"aaa@asd.com\" Id=\"AAATAGlrb3ZhY3NAZ2VvbWFudC5jb20ARgAAAAAAEJQcuBvXb0GMq6lzS852VAcAIxR4IGnfP0SoGJp2gMHciwAAAAIJBwAAIxR4IGnfP0SoGJp2gMHciwAQL63cdgAA\" Format=\"EwsLegacyId\"/>");
    sMsg = sMsg + ("</SourceIds>");
    sMsg = sMsg + ("</ConvertId>");
    sMsg = sMsg + ("</soap:Body>");
    sMsg = sMsg + ("</soap:Envelope>");

    What is the problem with these lines?

    Thanks!

    Imre

    Monday, January 14, 2008 9:18 AM
  • And what is the correct soap action to it?

    Thanks for all!

    Imre
    Monday, January 14, 2008 3:22 PM
  • Make sure when concatenating strings that you include the necessary spaces between attributes, etc...  For instance you will end up with something like this given your above code:

     

     

    <ConvertId xmlns="...messages"xmlns:t=".../types"DestinationFormat=\"EntryId\">");

     

    There needs to be a space between the end quota and DestinationFormat for instance.

    Monday, January 14, 2008 6:04 PM
  • You don't need to add the SOAP action header.  EWS determines which action to perform based on the local name of the first element in the body.  If you really feel like adding it anyways, it will look like:

     

    http://schemas.microsoft.com/exchange/services/2006/messages/ConvertId

     

    Of course, make sure the body contents and the SOAP action agree in that case Smile

    Monday, January 14, 2008 6:06 PM
  • Hi David,

    Thanks for the reply. I modified the code, but i have the same problem... According to me it the best, if I copy the example program:

    static void Main(string[] args)
    {
    string url = "https://domain/unifiedmessaging/service.asmx";

    string a = ("<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " + "\r\n");
    a = a + ("xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " + "\r\n");
    a = a + ("xmlnsTongue Tiedoap=\"http://schemas.xmlsoap.org/soap/envelope/\" " + "\r\n");
    a = a + ("xmlns:t=\"http://schemas.microsoft.com/exchange/services/2006/types\"> " + "\r\n");
    a = a + ("<soap:Header> " + "\r\n");
    a = a + ("<t:RequestServerVersion Version=\"Exchange2007_SP1\"/> " + "\r\n");
    a = a + ("</soap:Header> " + "\r\n");
    a = a + ("<soap:Body> " + "\r\n");
    a = a + ("<ConvertId xmlns=\"http://schemas.microsoft.com/exchange/services/2006/messages\" " + "\r\n");
    a = a + ("xmlns:t=\"http://schemas.microsoft.com/exchange/services/2006/types\" " + "\r\n");
    a = a + ("DestinationFormat=\"EntryId\"> " + "\r\n");
    a = a + ("<SourceIds> " + "\r\n");
    a = a + ("<t:AlternateId Mailbox=\"user@domain.com\" Id=\"AAATAGlrb3ZhY3NAZ2VvbWFudC5jb20ARgAAAAAAEJQcuBvXb0GMq6lzS852VAcAIxR4IGnfP0SoGJp2gMHciwAAAAIJBwAAIxR4IGnfP0SoGJp2gMHciwAQL63cdgAA\" Format=\"EwsLegacyId\"/>" + "\r\n");
    a = a + ("</SourceIds> " + "\r\n");
    a = a + ("</ConvertId> " + "\r\n");
    a = a + ("</soap:Body> " + "\r\n");
    a = a + ("</soap:Envelope> " + "\r\n");
    Console.WriteLine(a);
    HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
    req.Credentials = new CredentialCache().GetCredential(new Uri(url),"Basic");
    byte[] credentialBuffer =
    new
    System.Text.UTF8Encoding().GetBytes(
    "domain\\user" + ":" +
    "password");

    req.Headers["Authorization"] =
    "Basic " +
    Convert.ToBase64String(credentialBuffer);
    string base64EncodedString = Convert.ToBase64String(credentialBuffer).ToString();
    req.Method = "POST";
    req.ContentType = "text/xml";
    req.ContentLength = a.Length;
    req.UseDefaultCredentials = false;
    Stream reqst = req.GetRequestStream(); // add form data to request stream
    byte[] b = Encoding.UTF8.GetBytes(a);
    reqst.Write(b, 0, b.Length);
    reqst.Flush();
    reqst.Close();
    HttpWebResponse res = null;
    try
    {
    res = (HttpWebResponse)req.GetResponse(); // send request, getresponse
    }
    catch (WebException wex)
    {
    Console.WriteLine(wex.Response.Headers.ToString());
    }
    }

    It's return with an "Internal Server Error". What do you think about it? (This error isn't authentication problem, not "negotiate").

    Thanks for all!

    Imre
    Monday, January 14, 2008 10:04 PM
  •  

    Two main things that I noticed in the above code.

     

    1.  You are sending your request to the UM web service rather than the EWS endpoint.  You should be using:

     

    string url = https://domain/ews/Exchange.asmx;

     

    2.  Why not just set the credentials on the request directly and allow the request to negotiate the auth mechanism rather than mess with the basic headers yourself?

     

    With those changes your code worked fine on my box.

     

    Tuesday, January 15, 2008 8:07 PM
  • Hi David,

    The first point is fully clear... Smile But the second is not. What do you think exactly? I trying to it with this line:

    req.Credentials = new NetworkCredential("user", "password", "domain");

    but in this case, i received an Internal Server Error. What is the wrong? This is the code now:

    static void Main(string[] args)
    {
    string url = "https://domain/ews/Exchange.asmx";

    string a = ("<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" ");
    a = a + ("xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" ");
    a = a + ("xmlnsTongue Tiedoap=\"http://schemas.xmlsoap.org/soap/envelope/\" ");
    a = a + ("xmlns:t=\"http://schemas.microsoft.com/exchange/services/2006/types\">" + "\n");
    a = a + ("<soap:Header>" + "\n");
    a = a + ("<t:RequestServerVersion Version=\"Exchange2007_SP1\"/>" + "\n");
    a = a + ("</soap:Header>" + "\n");
    a = a + ("<soap:Body>" + "\n");
    a = a + ("<ConvertId xmlns=\"http://schemas.microsoft.com/exchange/services/2006/messages\" ");
    a = a + ("xmlns:t=\"http://schemas.microsoft.com/exchange/services/2006/types\" ");
    a = a + ("DestinationFormat=\"EntryId\">" + "\n");
    a = a + ("<SourceIds>" + "\n");
    a = a + ("<t:AlternateId Mailbox=\"user@domain.com\" Id=\"AAATAGlrb3ZhY3NAZ2VvbWFudC5jb20ARgAAAAAAEJQcuBvXb0GMq6lzS852VAcAIxR4IGnfP0SoGJp2gMHciwAAAAIJBwAAIxR4IGnfP0SoGJp2gMHciwAQL63cdgAA\" Format=\"EwsLegacyId\"/>" + "\n");
    a = a + ("</SourceIds>" + "\n");
    a = a + ("</ConvertId>" + "\n");
    a = a + ("</soap:Body>" + "\n");
    a = a + ("</soap:Envelope>" + "\n");

    HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
    req.Credentials = new NetworkCredential("user", "password", "domain");
    req.Method = "POST";
    req.ContentType = "text/xml";
    req.ContentLength = a.Length;
    Stream reqst = req.GetRequestStream(); // add form data to request stream
    byte[] b = Encoding.UTF8.GetBytes(a);
    reqst.Write(b, 0, b.Length);
    reqst.Flush();
    reqst.Close();
    HttpWebResponse res = null;
    try
    {
    res = (HttpWebResponse)req.GetResponse(); // send request, getresponse
    }
    catch (WebException wex)
    {
    Console.WriteLine(wex.Response.Headers.ToString());
    }
    }

    Thanks for all!

    Imre


    Tuesday, January 15, 2008 10:03 PM
  •  

    What we need to do is to get the actual content of the 500 response to see what is going on.  In your catch block add the following:

     

    Code Block

    catch (WebException wex)

    {

    using (Stream f = wex.Response.GetResponseStream())

    {

    StreamReader sr = new StreamReader(f);

    string blah = sr.ReadToEnd();

    Console.WriteLine(blah);

    }

    }

     

     

    Then post back to this thread with the content of the failure.  Actually, the above is a good general purpose way to get the failure details of a web request.
    Wednesday, January 16, 2008 2:02 PM
  • Hi David,

    It was very helpful, thanks! The problem is with the SOAP Action(i think). If I adds the soap action to the header, i get it back:

    <?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlnsTongue Tiedoap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><soap:Body><soap:Fault><faultcode>soap:Client</faultcode><faultstring>Server did not recognize the value of HTTP Header SOAPAction: http://schemas.microsoft.com/exchange/services/2006/messages/ConvertId.</faultstring><detail /></soap:Fault></soap:Body></soap:Envelope>

    Without SOAP Action:

    <?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlnsTongue Tiedoap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><soap:Body><soap:Fault><faultcode>soap:Client</faultcode><faultstring>Unable to handle request without a valid action parameter. Please supply a valid soap action.</faultstring><detail /></soap:Fault></soap:Body></soap:Envelope>"

    What happens here? Tongue Tied Smile

    Thanks!

    Imre


    Wednesday, January 16, 2008 4:33 PM
  •  

    Are you sure this is an Exchange 2007 SP1 server? Smile

     

     

    Thursday, January 17, 2008 2:50 PM
  • Of Course. Smile But... Sorry!!!!!!!!!!!!!!!!! Just the UM server was updated to SP1... Big Smile What can i do now?
    Thursday, January 17, 2008 5:23 PM
  • David,

     

    I work together with Imre, that is why I continue his thread. We are working on MWI2007 application for 2 years, that extends Exchange 2007 with message waiting indication.

     

    We work together with MS teams on different forums, but the problem we ran into is really new, and I didnt find any refference. When we try to subscribe for the messages of the change of voicemail folder, we receive the following response (only 2 customers of hundreds):

    An internal server error occurred. The operation failed.

     

    The only similar error I found on the net is here:

    http://forums.microsoft.com/technet/showpost.aspx?postid=1849174&siteid=17&sb=0&d=1&at=7&ft=11&tf=0&pageid=1

     

    "<detail><e:ResponseCode xmlns:e=\"http://schemas.microsoft.com/exchange/services/2006/errors\">ErrorInternalServerError</e:ResponseCode><e:Message xmlns:e=\"http://schemas.microsoft.com/exchange/services/2006/errors\">An internal server error occurred. The operation failed.</e:Message><t:MessageXml xmlns:t=\"http://schemas.microsoft.com/exchange/services/2006/types\"><t:Value Name=\"InnerErrorMessageText\">Exchange Web Services are not currently available for this mailbox because it could not determine the Client Access Services Server to use for the mailbox.</t:Value><t:Value Name=\"InnerErrorResponseCode\">ErrorProxyServiceDiscoveryFailed</t:Value><t:Value Name=\"InnerErrorDescriptiveLinkKey\">0</t:Value></t:MessageXml></detail>"

     

    What does this mean? Thanks in advance
    Thursday, January 17, 2008 11:49 PM
  • If you are running against an RTM server, the ConvertId operation is not available, which is why it is complaining about the missing soap action.  In that case, given an EntryId, the only way to get the item via EWS is to call FindItem with a restriction on the entry id like this (replace the Value attribute of Constant with your base64 encoded PR_EntryID)

     

     

    Code Block

    <FindItem xmlns=".../messages"

              xmlns:t=".../types"

              Traversal="Shallow">

       <ItemShape>
          <t:BaseShape>Default</t:BaseShape>
       </ItemShape>
       <Restriction>
         <t:IsEqualTo>
           <t:ExtendedFieldURI PropertyTag="0x0FFF" PropertyType="Binary"/>
           <t:FieldURIOrConstant>
              <t:Constant Value="AAAAAIUnJ7s..."/>
           </t:FieldURIOrConstant>
         </t:IsEqualTo>
       </Restriction>
       <ParentFolderIds>
            <t:DistinguishedFolderId Id="inbox"/>              
       </ParentFolderIds>
    </FindItem>

     

     

    Once your EWS server is upgraded to SP1, you should be able to call ConvertId just fine.
    Sunday, January 20, 2008 12:43 PM
  • Very interesting.  We added a feature in SP1 called "proxy to best CAS" in which EWS will examine your request and if there is another active directory site that is more suited for fulfilling the request, it will "proxy" the incoming request to the other CAS box.  The logic behind this is that a single web service request is a lot cheaper than chatty RPC requests going from the CAS box to the mailbox server in another site, potentially across a slower link.

     

    So what this error is saying is that it was trying to determine the best AD site to send the request to, but the actual lookup for the server information failed.  Do you have access to the CAS box?  If so, could you look at the event log and see if there are any entried related to the failure and post them back here if so?

     

    Also, do you have multiple AD sites in your exchange installation, and does each site have a CAS box installed?

     

    Thanks!

    Sunday, January 20, 2008 12:49 PM
  • Hi David,

    Sorry for the late answer! It's working well on SP1. Thank you for the help!!! And what do you think about Robert's problem?

    Imre
    Tuesday, January 22, 2008 10:14 PM
  • See comment above on "proxy to best CAS"

     

    Wednesday, January 23, 2008 4:15 PM