none
EWS/Services.wsdl does not contain a definition for ConnectingSID.ItemElementName in Exchange 2013 RRS feed

  • Question

  • We're using EWS (unmanaged) in a .NET app to access Exchange Server.  After moving from 2010 to a server with Exchange 2013 and updating the web reference, I get error messages stating ConnectingSIDType does not contain a definition for ItemElementName or PrimarySmtpAddress. 

    If I point the ExchangeServiceBinding object url to the new server, but do NOT update the web reference to the new server, everything still works.   How do we fix this issue?  The 2010 Exchange server will go away within a few days.

    Monday, January 5, 2015 7:44 PM

Answers

  • With the 2013 version, try this instead:

    ExchangeImpersonationType impersonation = new ExchangeImpersonationType();
    ConnectingSIDType connectingSid = new ConnectingSIDType();
    PrimarySmtpAddressType userAddress = new PrimarySmtpAddressType();
    userAddress.Value = userAccount;
    connectingSid.Item = userAddress;
    impersonation.ConnectingSID = connectingSid;
    Basically now instead of manually setting the name of the element to use, you set the Item property to the appropriate type.
    • Marked as answer by DawnHunt Tuesday, January 6, 2015 4:33 PM
    Tuesday, January 6, 2015 4:01 PM
    Moderator

All replies

  • Do you get this error when actually sending a request to the Exchange server, or is this an error at compile time?
    Monday, January 5, 2015 8:11 PM
    Moderator
  • This is a compile time error
    Monday, January 5, 2015 8:24 PM
  • Interesting. I don't reproduce this error, but I don't have a project where the web reference was originally created against 2010. In any event, you should be fine to just leave it as it is since it works. It will just use the 2010 version of the schema (which 2013 supports).

    Otherwise, I would try completely removing the web reference and re-adding it. I would make a copy of your project first and try it from the copy, in case you have a problem generating a new reference from the 2013 server.

    For reference, here's what my ConnectingSidType class looks like after adding a web reference to 2013:

    public partial class ConnectingSIDType {
        
        private object itemField;
        
        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute("PrimarySmtpAddress", typeof(PrimarySmtpAddressType))]
        [System.Xml.Serialization.XmlElementAttribute("PrincipalName", typeof(PrincipalNameType))]
        [System.Xml.Serialization.XmlElementAttribute("SID", typeof(SIDType))]
        [System.Xml.Serialization.XmlElementAttribute("SmtpAddress", typeof(SmtpAddressType))]
        public object Item {
            get {
                return this.itemField;
            }
            set {
                this.itemField = value;
            }
        }
    }

    Monday, January 5, 2015 9:33 PM
    Moderator
  • This is the 2010 version

        public partial class ConnectingSIDType {
            
            private string itemField;
            
            private ItemChoiceType itemElementNameField;
            
            /// <remarks/>
            [System.Xml.Serialization.XmlElementAttribute("PrimarySmtpAddress", typeof(string))]
            [System.Xml.Serialization.XmlElementAttribute("PrincipalName", typeof(string))]
            [System.Xml.Serialization.XmlElementAttribute("SID", typeof(string))]
            [System.Xml.Serialization.XmlElementAttribute("SmtpAddress", typeof(string))]
            [System.Xml.Serialization.XmlChoiceIdentifierAttribute("ItemElementName")]
            public string Item {
                get {
                    return this.itemField;
                }
                set {
                    this.itemField = value;
                }
            }
            
            /// <remarks/>
            [System.Xml.Serialization.XmlIgnoreAttribute()]
            public ItemChoiceType ItemElementName {
                get {
                    return this.itemElementNameField;
                }
                set {
                    this.itemElementNameField = value;
                }
            }
        }


    2013 version

         public partial class ConnectingSIDType {
            
            private object itemField;
            
            /// <remarks/>
            [System.Xml.Serialization.XmlElementAttribute("PrimarySmtpAddress", typeof(PrimarySmtpAddressType))]
            [System.Xml.Serialization.XmlElementAttribute("PrincipalName", typeof(PrincipalNameType))]
            [System.Xml.Serialization.XmlElementAttribute("SID", typeof(SIDType))]
            [System.Xml.Serialization.XmlElementAttribute("SmtpAddress", typeof(SmtpAddressType))]
            public object Item {
                get {
                    return this.itemField;
                }
                set {
                    this.itemField = value;
                }
            }
        }

    And here is the impersonation code

                   ExchangeImpersonationType impersonate = new ExchangeImpersonationType();
    
                    impersonate.ConnectingSID = new ConnectingSIDType();
                    impersonate.ConnectingSID.Item = _email;
                    impersonate.ConnectingSID.ItemElementName = ItemChoiceType.PrimarySmtpAddress;
                    this.ExchangeService.ExchangeImpersonation = impersonate;
    
    ConnectingSID.ItemElementName doesn't exist in the 2013 version.   Is there a different way to do impersonation without going to the managed API?
     
    Tuesday, January 6, 2015 3:01 PM
  • With the 2013 version, try this instead:

    ExchangeImpersonationType impersonation = new ExchangeImpersonationType();
    ConnectingSIDType connectingSid = new ConnectingSIDType();
    PrimarySmtpAddressType userAddress = new PrimarySmtpAddressType();
    userAddress.Value = userAccount;
    connectingSid.Item = userAddress;
    impersonation.ConnectingSID = connectingSid;
    Basically now instead of manually setting the name of the element to use, you set the Item property to the appropriate type.
    • Marked as answer by DawnHunt Tuesday, January 6, 2015 4:33 PM
    Tuesday, January 6, 2015 4:01 PM
    Moderator
  • Thank you!  This is exactly what I needed
    Tuesday, January 6, 2015 4:33 PM