0
我正在嘗試構建搜索XML表達式以與Java中的Exchange Web服務一起使用。我試圖實現的是,我可以通過他們的電子郵件地址搜索所有聯繫人。我已經瀏覽了他們的文檔,但沒有得到它的工作。這是我到目前爲止有:無法在搜索表達式中使用電子郵件地址檢索EWS聯繫人
String searchXmlStr ="<Restriction>"
+ "<t:IsEqualTo>"
+ "<t:FieldURI FieldURI=\"contacts:EmailAddresses\"/>"
+ "<t:EmailAddresses>"
+ "<Entry Key=\""+ emailAddress +"\"/>"
+ "</t:EmailAddresses>"
+ "</t:IsEqualTo>"
+"</Restriction>";
當我編譯並運行這段代碼,我得到:
ERROR [jec.utils.AppLogger] status: 500
ERROR [jec.utils.AppLogger] <?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-US">The request failed schema validation: The element 'IsEqualTo' in namespace 'http://schemas.microsoft.com/exchange/services/2006/types' has invalid child element 'EmailAddresses' in namespace 'http://schemas.microsoft.com/exchange/services/2006/types'. List of possible elements expected: 'FieldURIOrConstant' in namespace 'http://schemas.microsoft.com/exchange/services/2006/types'.</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>572</t:LinePosition><t:Violation>The element 'IsEqualTo' in namespace 'http://schemas.microsoft.com/exchange/services/2006/types' has invalid child element 'EmailAddresses' in namespace 'http://schemas.microsoft.com/exchange/services/2006/types'. List of possible elements expected: 'FieldURIOrConstant' in namespace 'http://schemas.microsoft.com/exchange/services/2006/types'.</t:Violation></t:MessageXml></detail></s:Fault></s:Body></s:Envelope>
ERROR [jec.utils.AppLogger] <?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-US">The request failed schema validation: The element 'IsEqualTo' in namespace 'http://schemas.microsoft.com/exchange/services/2006/types' has invalid child element 'EmailAddresses' in namespace 'http://schemas.microsoft.com/exchange/services/2006/types'. List of possible elements expected: 'FieldURIOrConstant' in namespace 'http://schemas.microsoft.com/exchange/services/2006/types'.</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>572</t:LinePosition><t:Violation>The element 'IsEqualTo' in namespace 'http://schemas.microsoft.com/exchange/services/2006/types' has invalid child element 'EmailAddresses' in namespace 'http://schemas.microsoft.com/exchange/services/2006/types'. List of possible elements expected: 'FieldURIOrConstant' in namespace 'http://schemas.microsoft.com/exchange/services/2006/types'.</t:Violation></t:MessageXml></detail></s:Fault></s:Body></s:Envelope>
jec.ExchangeGeneralException: <?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-US">The request failed schema validation: The element 'IsEqualTo' in namespace 'http://schemas.microsoft.com/exchange/services/2006/types' has invalid child element 'EmailAddresses' in namespace 'http://schemas.microsoft.com/exchange/services/2006/types'. List of possible elements expected: 'FieldURIOrConstant' in namespace 'http://schemas.microsoft.com/exchange/services/2006/types'.</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>572</t:LinePosition><t:Violation>The element 'IsEqualTo' in namespace 'http://schemas.microsoft.com/exchange/services/2006/types' has invalid child element 'EmailAddresses' in namespace 'http://schemas.microsoft.com/exchange/services/2006/types'. List of possible elements expected: 'FieldURIOrConstant' in namespace 'http://schemas.microsoft.com/exchange/services/2006/types'.</t:Violation></t:MessageXml></detail></s:Fault></s:Body></s:Envelope>
at jec.a.a.a.for(Unknown Source)
at jec.EWSConnector.getContacts(Unknown Source)
at betas.Main.getContactByEmail(Main.java:197)
at betas.Main.main(Main.java:36)
jec.ExchangeGeneralException: <?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-US">The request failed schema validation: The element 'IsEqualTo' in namespace 'http://schemas.microsoft.com/exchange/services/2006/types' has invalid child element 'EmailAddresses' in namespace 'http://schemas.microsoft.com/exchange/services/2006/types'. List of possible elements expected: 'FieldURIOrConstant' in namespace 'http://schemas.microsoft.com/exchange/services/2006/types'.</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>572</t:LinePosition><t:Violation>The element 'IsEqualTo' in namespace 'http://schemas.microsoft.com/exchange/services/2006/types' has invalid child element 'EmailAddresses' in namespace 'http://schemas.microsoft.com/exchange/services/2006/types'. List of possible elements expected: 'FieldURIOrConstant' in namespace 'http://schemas.microsoft.com/exchange/services/2006/types'.</t:Violation></t:MessageXml></detail></s:Fault></s:Body></s:Envelope>
at jec.a.a.a.for(Unknown Source)
at jec.EWSConnector.getContacts(Unknown Source)
at betas.Main.getContactByEmail(Main.java:197)
at betas.Main.main(Main.java:36)
編輯
爲了完整起見,我使用this庫來連接EWS
我認爲這是搜索聯繫人右一個非常簡單的和經常使用的方法是什麼?有人能指出我的錯誤嗎? – RazorAlliance192 2014-10-02 09:11:53