gpt4 book ai didi

java - 无法在搜索表达式中使用电子邮件地址检索 EWS 联系人

转载 作者:行者123 更新时间:2023-12-01 12:28:17 28 4
gpt4 key购买 nike

我正在尝试构建一个搜索 XML 表达式以与 Java 中的 Exchange Web 服务一起使用。我试图实现的是我可以通过电子邮件地址搜索所有联系人。我已经浏览了他们的文档,但未能使其正常工作。这是我到目前为止所拥有的:

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连接的库

最佳答案

您无法在 EmailAddresses 属性上创建限制,因为这是一个属性集合,因此您需要在基础 3 个联系人电子邮件地址属性中使用 Or 限制,例如

      <m:Restriction>
<t:Or>
<t:IsEqualTo>
<t:IndexedFieldURI FieldURI="contacts:EmailAddress" FieldIndex="EmailAddress1" />
<t:FieldURIOrConstant>
<t:Constant Value="user@domain.com" />
</t:FieldURIOrConstant>
</t:IsEqualTo>
<t:IsEqualTo>
<t:IndexedFieldURI FieldURI="contacts:EmailAddress" FieldIndex="EmailAddress2" />
<t:FieldURIOrConstant>
<t:Constant Value="user@domain.com" />
</t:FieldURIOrConstant>
</t:IsEqualTo>
<t:IsEqualTo>
<t:IndexedFieldURI FieldURI="contacts:EmailAddress" FieldIndex="EmailAddress3" />
<t:FieldURIOrConstant>
<t:Constant Value="user@domain.com" />
</t:FieldURIOrConstant>
</t:IsEqualTo>
</t:Or>
</m:Restriction>

干杯格伦

关于java - 无法在搜索表达式中使用电子邮件地址检索 EWS 联系人,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26157352/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com