none
Invalid itemID?

    Pertanyaan

  • Hi, I am using the EWS Managed API 1.1.5 with Exchange 2007 SP3.  I have the following code that seems to generate an invalid itemID because it throws an exception when I try to bind to it:

    The ExchangeService s was created like this: s = new ExchangeService(ExchangeVersion.Exchange2007_SP1);

    public static String scheduleWeekly(String stime, String duration, String subject, String description, String recEndDate,
                                                            String[] attendees, ExchangeService s)

    {
            DayOfTheWeek d = null;
            int dayOfWeek;
            try {
            Appointment appointment = new Appointment(s);
            appointment.setSubject(subject);
            appointment.setBody(MessageBody.getMessageBodyFromText(description));
            for(String attendee: attendees)
            {
                Attendee a = new Attendee(attendee);
                appointment.getRequiredAttendees().add(a);
            }
          
            SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            Date startDate = formatter.parse(stime);
            Calendar c = Calendar.getInstance();
            c.setTime(startDate);
            dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
            if(dayOfWeek == 1)
                d = DayOfTheWeek.Sunday;
            else if(dayOfWeek == 2)
                d = DayOfTheWeek.Monday;
            else if(dayOfWeek == 3)
                d = DayOfTheWeek.Tuesday;
            else if(dayOfWeek == 4)
                d = DayOfTheWeek.Wednesday;
            else if(dayOfWeek == 5)
                d = DayOfTheWeek.Thursday;
            else if(dayOfWeek == 6)
                d = DayOfTheWeek.Friday;
            else if(dayOfWeek == 7)
                d = DayOfTheWeek.Saturday;
            appointment.setRecurrence(new Recurrence.WeeklyPattern(startDate, 1, d));  
            
            c.add(Calendar.MINUTE, Integer.parseInt(duration));
            Date endDate = c.getTime();
            
            appointment.setStart(startDate);
            appointment.setEnd(endDate);
           
            Date recurrenceEndDate = formatter.parse(recEndDate);
            appointment.getRecurrence().setStartDate(startDate);
            appointment.getRecurrence().setEndDate(recurrenceEndDate);

            appointment.save();

    /*The following line throws this exception: "The request failed. No match found" */

            Appointment mtg = Appointment.bind(s, appointment.getId());

            ExtendedPropertyDefinition CleanGlobalObjectId = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.Meeting, 0x23, MapiPropertyType.Binary);

            List<Item> items = new ArrayList<Item>();
            items.add(appointment);

            PropertySet ps = new PropertySet(BasePropertySet.FirstClassProperties);
            ps.add(CleanGlobalObjectId);
            s.loadPropertiesForItems(items, ps);
            
            String uid = appointment.getICalUid();
            String itemID = appointment.getId().toString();
            return uid + ";" + itemID;
            }

            catch(Exception e) {
            System.out.println(e.getMessage());
        }
        return null;
    }

    13 Maret 2012 22:37

Semua Balasan

  • Does anyone know why the above code produces an invalid item id?  The code works fine with Exchange 2010.  Could it be that I am using Exchange 2007 SP3 and not SP1?  Thanks in advance.
    14 Maret 2012 23:07
  • I was reading this thread: http://social.technet.microsoft.com/Forums/en-US/exchangesvrdevelopment/thread/2fc22375-8c3c-4dfb-a72d-156088615696 and thought, could it be that I need to change my itemID format?  But when creating my exchangeService object I am specifying SP1  so I shouldn't need to convert the itemID format right?  I tried changing my itemID format from EWSIdLegacy to EWSId and EWSId to StoreId and kept getting an "Id is malformed" exception.  Here is some more info on the IdFormat enumeration:

    http://msdn.microsoft.com/en-us/library/microsoft.exchange.webservices.data.idformat%28v=exchg.80%29.aspx

    Could you shed some light on this Glen Scales?

    Has anybody had a problem binding to an Exchange 2007 SP_1 or higher meeting with the EWS Managed API using Java?  Thanks in advance.

    18 Maret 2012 23:09
  • PythonCoder5,

    I don't think that the Id format is an issue. I think you'd get an "Id is malformed" type of response if that was the issue.

    Can you check the value of appointment.id.uniqueId property after appointment.save()? Is it null? I wonder if the ItemId is returned in 2007. I vaguely remember something along these lines.

    If the uniqueId is not null, can you show us the XML sent/returned by appointment.save() and Appointment.bind? 

    With regards,


    Michael | Microsoft Exchange SDK

    The Exchange Development Forum Guide has useful information for using the Exchange Development Forum.

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

    19 Maret 2012 18:36
    Moderator
  • Hi Michael, I found that appointment.getId().toString() and appointment.getId().getUniqueId() return the same thing.  Both return an itemID.  I have posted the xml trace in my most recent post in this thread:

    http://social.technet.microsoft.com/Forums/en-US/exchangesvrdevelopment/thread/09883d57-e2a2-4db6-8800-9b9d251d6231

    Thanks!

    21 Maret 2012 0:08
  • Any update on this Michael?  I am able to get an itemID, I just can't use it to bind to a meeting in Exchange 2007, only Exchange 2010.
    22 Maret 2012 4:00
  • If you run the code against Exchange 2010 but use the Exchange2007_SP1 request version on your ExchangeService object, will you get the same results?

    The appointment.save() should send a CreateItem request and return a CreateItem response. Can you show me the XML for both the request and the response (when sending to an 2007 server)?

    The Appointment.bind should send a GetItem request and return a GetItem response. Can you show me the XML for both the request and the response (when sending to an 2007 server)?

    Just as a point of best practice, it is best to not use the FirstClassProperty set unless you are really using all the properties, which you may be doing. Request individual properties that you are using in your application.

    With regards, 


    Michael | Microsoft Exchange SDK

    The Exchange Development Forum Guide has useful information for using the Exchange Development Forum.

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

    22 Maret 2012 16:23
    Moderator
  • Here are the xml requests and responses, the first part is for the save and the second part is for the response:

    run:

    SAVE REQUEST:

    <Trace Tag="EwsRequest" Tid="1" Time="2012-03-22 18:06:46Z">
    <?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:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"><soap:Header><t:RequestServerVersion Version="Exchange2007_SP1"></t:RequestServerVersion></soap:Header><soap:Body>
    <m:CreateItem MessageDisposition="SaveOnly" SendMeetingInvitations="SendToAllAndSaveCopy">
    <m:Items><t:CalendarItem><t:Subject>Mainer</t:Subject><t:Body BodyType="HTML">daily meeting</t:Body>
    <t:Start>2012-03-27T12:00:00Z</t:Start><t:End>2012-03-27T12:10:00Z</t:End><t:RequiredAttendees><t:Attendee>
    <t:Mailbox><t:EmailAddress>inviteeEmail@domain</t:EmailAddress></t:Mailbox></t:Attendee></t:RequiredAttendees>
    <t:Recurrence><t:DailyRecurrence><t:Interval>1</t:Interval></t:DailyRecurrence>
    <t:EndDateRecurrence><t:StartDate>2012-03-27</t:StartDate><t:EndDate>2012-03-30</t:EndDate></t:EndDateRecurrence>
    </t:Recurrence></t:CalendarItem></m:Items></m:CreateItem></soap:Body></soap:Envelope>
    </Trace>

    SAVE RESPONSE:

    Mar 22, 2012 11:06:46 AM org.apache.commons.httpclient.auth.AuthChallengeProcessor selectAuthScheme
    INFO: NTLM authentication scheme selected
    <Trace Tag="EwsResponse" Tid="1" Time="2012-03-22 18:06:46Z">
    <?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="3" MajorBuildNumber="83" MinorBuildNumber="4" Version="Exchange2007_SP1" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" />
    </soap:Header>
    <soap:Body>
    <m:CreateItemResponse xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"><m:ResponseMessages><m:CreateItemResponseMessage ResponseClass="Success">
    <m:ResponseCode>NoError</m:ResponseCode><m:Items><t:CalendarItem>
    <t:ItemId Id="AAMkADQ0OWMyODNlLWUyNzMtNGUxOS1iYWZlLWJjMDMyMzJlZDQwMgBGAAAAAADrEDxnQHMCQ6zeDwEmFgrcBwCifLxxw9XoQ7sEmGjdGolBAAABzCc1AACifLxxw9XoQ7sEmGjdGolBAAWhGywyAAA=" ChangeKey="DwAAABYAAACifLxxw9XoQ7sEmGjdGolBAAWhHOJC" />
    </t:CalendarItem></m:Items></m:CreateItemResponseMessage></m:ResponseMessages></m:CreateItemResponse></soap:Body></soap:Envelope>
    </Trace>

    Appointment.getId(): AAMkADQ0OWMyODNlLWUyNzMtNGUxOS1iYWZlLWJjMDMyMzJlZDQwMgBGAAAAAADrEDxnQHMCQ6zeDwEmFgrcBwCifLxxw9XoQ7sEmGjdGolBAAABzCc1AACifLxxw9XoQ7sEmGjdGolBAAWhGywyAAA=
    Appointment.getId().getUniqueId(): AAMkADQ0OWMyODNlLWUyNzMtNGUxOS1iYWZlLWJjMDMyMzJlZDQwMgBGAAAAAADrEDxnQHMCQ6zeDwEmFgrcBwCifLxxw9XoQ7sEmGjdGolBAAABzCc1AACifLxxw9XoQ7sEmGjdGolBAAWhGywyAAA=
    THE ID AND THE UNIQUEID ARE THE SAME

    BIND REQUEST:

    <Trace Tag="EwsRequest" Tid="1" Time="2012-03-22 18:06:47Z">
    <?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:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"><soap:Header>
    <t:RequestServerVersion Version="Exchange2007_SP1">
    </t:RequestServerVersion></soap:Header><soap:Body>
    <m:GetItem><m:ItemShape><t:BaseShape>AllProperties</t:BaseShape></m:ItemShape>
    <m:ItemIds><t:ItemId Id="AAMkADQ0OWMyODNlLWUyNzMtNGUxOS1iYWZlLWJjMDMyMzJlZDQwMgBGAAAAAADrEDxnQHMCQ6zeDwEmFgrcBwCifLxxw9XoQ7sEmGjdGolBAAABzCc1AACifLxxw9XoQ7sEmGjdGolBAAWhGywyAAA=">
    </t:ItemId></m:ItemIds></m:GetItem></soap:Body></soap:Envelope>
    </Trace>

    BIND RESPONSE:

    <Trace Tag="EwsResponse" Tid="1" Time="2012-03-22 18:06:47Z">
    <?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="3" MajorBuildNumber="83" MinorBuildNumber="4" Version="Exchange2007_SP1" 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:CalendarItem>
    <t:ItemId Id="AAMkADQ0OWMyODNlLWUyNzMtNGUxOS1iYWZlLWJjMDMyMzJlZDQwMgBGAAAAAADrEDxnQHMCQ6zeDwEmFgrcBwCifLxxw9XoQ7sEmGjdGolBAAABzCc1AACifLxxw9XoQ7sEmGjdGolBAAWhGywyAAA=" ChangeKey="DwAAABYAAACifLxxw9XoQ7sEmGjdGolBAAWhHOJC" />
    <t:ParentFolderId Id="AAMkADQ0OWMyODNlLWUyNzMtNGUxOS1iYWZlLWJjMDMyMzJlZDQwMgAuAAAAAADrEDxnQHMCQ6zeDwEmFgrcAQCifLxxw9XoQ7sEmGjdGolBAAABzCc1AAA=" ChangeKey="AQAAAA==" />
    <t:ItemClass>IPM.Appointment</t:ItemClass><t:Subject>Mainer</t:Subject><t:Sensitivity>Normal</t:Sensitivity><t:Body BodyType="HTML">&lt;html&gt;
    &lt;head&gt;
    &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt;
    &lt;/head&gt;
    &lt;body&gt;
    daily meeting
    &lt;/body&gt;
    &lt;/html&gt;
    </t:Body><t:DateTimeReceived>2012-03-22T18:05:53Z</t:DateTimeReceived><t:Size>1654</t:Size><t:Importance>Normal</t:Importance>
    <t:IsSubmitted>false</t:IsSubmitted><t:IsDraft>false</t:IsDraft><t:IsFromMe>false</t:IsFromMe><t:IsResend>false</t:IsResend>
    <t:IsUnmodified>false</t:IsUnmodified><t:DateTimeSent>2012-03-22T18:05:53Z</t:DateTimeSent><t:DateTimeCreated>2012-03-22T18:05:53Z
    </t:DateTimeCreated><t:ResponseObjects><t:CancelCalendarItem /><t:ForwardItem /></t:ResponseObjects>
    <t:ReminderDueBy>2012-03-27T12:00:00Z</t:ReminderDueBy><t:ReminderIsSet>true</t:ReminderIsSet>
    <t:ReminderMinutesBeforeStart>15</t:ReminderMinutesBeforeStart><t:DisplayCc /><t:DisplayTo>inviteeEmail@domain
    </t:DisplayTo><t:HasAttachments>false</t:HasAttachments><t:Culture>en-US</t:Culture><t:EffectiveRights><t:CreateAssociated>false
    </t:CreateAssociated><t:CreateContents>false</t:CreateContents><t:CreateHierarchy>false</t:CreateHierarchy><t:Delete>true</t:Delete>
    <t:Modify>true</t:Modify><t:Read>true</t:Read></t:EffectiveRights><t:LastModifiedName>drym07 autotest001</t:LastModifiedName>
    <t:LastModifiedTime>2012-03-22T18:05:53Z</t:LastModifiedTime>
    <t:UID>040000008200E00074C5B7101A82E008000000002D12E06B5608CD0100000000000000001000000033AF43A6F55D9D43AB9778579AFA10D2</t:UID>
    <t:DateTimeStamp>2012-03-22T18:05:53Z</t:DateTimeStamp><t:Start>2012-03-27T12:00:00Z</t:Start><t:End>2012-03-27T12:10:00Z</t:End>
    <t:IsAllDayEvent>false</t:IsAllDayEvent><t:LegacyFreeBusyStatus>Busy</t:LegacyFreeBusyStatus><t:IsMeeting>true</t:IsMeeting>
    <t:IsCancelled>false</t:IsCancelled><t:IsRecurring>false</t:IsRecurring><t:MeetingRequestWasSent>true</t:MeetingRequestWasSent>
    <t:CalendarItemType>RecurringMaster</t:CalendarItemType><t:MyResponseType>Organizer</t:MyResponseType><t:Organizer><t:Mailbox>
    <t:Name>drym07 autotest001</t:Name><t:EmailAddress>schedulerEmail@domain</t:EmailAddress><t:RoutingType>SMTP
    </t:RoutingType></t:Mailbox></t:Organizer><t:RequiredAttendees><t:Attendee><t:Mailbox><t:Name>inviteeEmail@domain</t:Name>
    <t:EmailAddress>inviteeEmail@domain</t:EmailAddress><t:RoutingType>SMTP</t:RoutingType></t:Mailbox>
    <t:ResponseType>Unknown</t:ResponseType></t:Attendee></t:RequiredAttendees><t:ConflictingMeetingCount>0</t:ConflictingMeetingCount>
    <t:AdjacentMeetingCount>0</t:AdjacentMeetingCount><t:Duration>PT10M</t:Duration><t:TimeZone>Greenwich Standard Time</t:TimeZone>
    <t:AppointmentSequenceNumber>0</t:AppointmentSequenceNumber><t:AppointmentState>1</t:AppointmentState><t:Recurrence>
    <t:DailyRecurrence><t:Interval>1</t:Interval></t:DailyRecurrence><t:EndDateRecurrence><t:StartDate>2012-03-27Z</t:StartDate>
    <t:EndDate>2012-03-30Z</t:EndDate></t:EndDateRecurrence></t:Recurrence><t:FirstOccurrence>
    <t:ItemId Id="AAMkADQ0OWMyODNlLWUyNzMtNGUxOS1iYWZlLWJjMDMyMzJlZDQwMgFRAAiIztn+XFfYAEYAAAAA6xA8Z0BzAkOs3g8BJhYK3AcAony8ccPV6EO7BJho3RqJQQAAAcwnNQAAony8ccPV6EO7BJho3RqJQQAFoRssMgAAEA==" ChangeKey="DwAAABYAAACifLxxw9XoQ7sEmGjdGolBAAWhHOJC" />
    <t:Start>2012-03-27T12:00:00Z</t:Start><t:End>2012-03-27T12:10:00Z</t:End><t:OriginalStart>2012-03-27T12:00:00Z
    </t:OriginalStart></t:FirstOccurrence><t:LastOccurrence><t:ItemId Id="AAMkADQ0OWMyODNlLWUyNzMtNGUxOS1iYWZlLWJjMDMyMzJlZDQwMgFRAAiIztxZ25UYAEYAAAAA6xA8Z0BzAkOs3g8BJhYK3AcAony8ccPV6EO7BJho3RqJQQAAAcwnNQAAony8ccPV6EO7BJho3RqJQQAFoRssMgAAEA==" ChangeKey="DwAAABYAAACifLxxw9XoQ7sEmGjdGolBAAWhHOJC" />
    <t:Start>2012-03-30T12:00:00Z</t:Start><t:End>2012-03-30T12:10:00Z</t:End><t:OriginalStart>2012-03-30T12:00:00Z</t:OriginalStart>
    </t:LastOccurrence><t:MeetingTimeZone TimeZoneName="Greenwich Standard Time"><t:BaseOffset>PT0M</t:BaseOffset></t:MeetingTimeZone>
    </t:CalendarItem></m:Items></m:GetItemResponseMessage></m:ResponseMessages></m:GetItemResponse></soap:Body></soap:Envelope>
    </Trace>

    false
    The request failed. No match found
    null

    22 Maret 2012 19:14
  • So, I assume this was the result of a query against an Exchange 2010 server. What is the XML for the scenario when you target Exchange 2007?

    EDIT:

    This is against Exchange 2007. I don't see an error here in the XML. What exception is thrown?


    Michael | Microsoft Exchange SDK

    The Exchange Development Forum Guide has useful information for using the Exchange Development Forum.

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.


    22 Maret 2012 20:13
    Moderator
  • Yes, this is against Exchange 2007 SP3 server.  When you try to bind to the newly created meeting with the itemID, the exception "The request failed.  No match found" is thrown.
    22 Maret 2012 20:29
  • This looks like it might be a client bug. You provided the exception message, what is the name of the exception? I'm going to bring this up to API owner.


    Michael | Microsoft Exchange SDK

    The Exchange Development Forum Guide has useful information for using the Exchange Development Forum.

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

    22 Maret 2012 20:38
    Moderator
  • Sorry Michael, what do you mean by a "client bug", and what do you mean by the "name of the exception"? 

    By the way, since you are gracious enough to bring this up to the API owner, you may as well also mention that one must comment out lines 249, 250, and 256 in Appointment.java in order to create appointments with Exchange 2007.  This was wisely pointed out by user "prentice" in another forum.

    • Diedit oleh PythonCoder5 22 Maret 2012 21:17 pointing out another bug
    22 Maret 2012 20:45
  • It appears like it might be a bug in the EWS Java API. The name of the exception, something like ServiceResponseException.

    Michael | Microsoft Exchange SDK

    The Exchange Development Forum Guide has useful information for using the Exchange Development Forum.

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

    22 Maret 2012 22:17
    Moderator
  • How do I find the name of the exception?  When I catch the exception I printed out "the_exception.getCause()" and it said it was java.lang.IllegalStateException--Is this what you're looking for?  Let me know if you need any other details when you talk to the API owner.  Thanks!
    22 Maret 2012 22:28
  • Hi Michael, did you hear back from the API owner yet?  Thanks.
    28 Maret 2012 22:47
  • Hello PythonCoder5,

    The API owner has forwarded on the scenario to get more information. I haven't heard back yet. One thing you can do is use the source code to figure out whether this is a bug. I expect it is.

    With regards, 


    Michael | Microsoft Exchange SDK

    The Exchange Development Forum Guide has useful information for using the Exchange Development Forum.

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

    03 April 2012 22:08
    Moderator