這是工作示例代碼調用ResolveNames在我SoapUI生成從Exchange Server檢索WDSL後EWS:「屬性未聲明」在德爾福錯誤產生的EWS SOAP請求
<?xml version="1.0"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:typ="http://schemas.microsoft.com/exchange/services/2006/types"
xmlns:mes="http://schemas.microsoft.com/exchange/services/2006/messages">
<soapenv:Header><typ:RequestServerVersion Version="Exchange2010"/></soapenv:Header>
<soapenv:Body>
<mes:ResolveNames ReturnFullContactData="1" SearchScope="ActiveDirectoryContacts">
<mes:UnresolvedEntry>deve</mes:UnresolvedEntry>
</mes:ResolveNames>
</soapenv:Body>
</soapenv:Envelope>
這是裸德爾福XE2代碼,我使用:
procedure TFrmTestEWS.BtnConnectClick(Sender: TObject);
var
lESB : ExchangeServicePortType;
lResNames : ResolveNames;
lReqVersion : RequestServerVersion;
lResResult : ResolveNamesResponse;
lServerVer : ServerVersionInfo;
lUnresolved : String;
begin
lServerVer := ServerVersionInfo.Create;
lResNames := ResolveNames.Create;
lReqVersion := RequestServerVersion.Create;
lUnresolved := 'Deve';
with lResNames do
begin
ReturnFullContactData := true;
SearchScope := ResolveNamesSearchScopeType.ActiveDirectoryContacts; // Scoped enums is on!
ParentFolderIds := nil;
UnresolvedEntry := lUnresolved;
end;
lReqVersion.Version := ExchangeVersionType.Exchange2010;
lESB := (HTTPRIO1 as ExchangeServicePortType);
lESB.ResolveNames(lResNames,
nil, // Impersonation
nil, // MailboxCulture
lReqVersion,
lResResult,
lServerVer);
它產生:
<?xml version="1.0"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body xmlns:NS1="http://schemas.microsoft.com/exchange/services/2006/types">
<ResolveNames xmlns="http://schemas.microsoft.com/exchange/services/2006/messages" ReturnFullContactData="true" NS1:SearchScope="ActiveDirectoryContacts">
<UnresolvedEntry>deve</UnresolvedEntry>
</ResolveNames>
<MailboxCulture xsi:nil="true"/>
<ExchangeImpersonation xsi:nil="true"/>
<NS1:RequestServerVersion Version="Exchange2010"/>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
我得到的錯誤:
請求失敗模式驗證:'http://schemas.microsoft.com/exchange/services/2006/types:SearchScope'屬性未聲明。
SearchScope的是屬性,如messages.xsd定義:
<!-- ResolveNames request -->
<xs:complexType name="ResolveNamesType">
<xs:complexContent>
<xs:extension base="m:BaseRequestType">
<xs:sequence>
<xs:element name="ParentFolderIds" type="t:NonEmptyArrayOfBaseFolderIdsType" minOccurs="0"/>
<xs:element name="UnresolvedEntry" type="t:NonEmptyStringType"/>
</xs:sequence>
<xs:attribute name="ReturnFullContactData" type="xs:boolean" use="required"/>
<xs:attribute name="SearchScope" type="t:ResolveNamesSearchScopeType" default="ActiveDirectoryContacts"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:element name="ResolveNames" type="m:ResolveNamesType"/>
在types.xsd:
<!-- ResolveNames request -->
<xs:simpleType name="ResolveNamesSearchScopeType">
<xs:restriction base="xs:string">
<xs:enumeration value="ActiveDirectory"/>
<xs:enumeration value="ActiveDirectoryContacts"/>
<xs:enumeration value="Contacts"/>
<xs:enumeration value="ContactsActiveDirectory"/>
</xs:restriction>
</xs:simpleType>
我認爲NS1:SearchScope的= 「ActiveDirectoryContacts」 是不正確,但在離開NS1:out給出相同的錯誤。
也許推遲了類型和消息交易所的xmlns規範提交給SOAP-ENV中:身體是該錯誤的原因是什麼?
此外,NS1:RequestServerVersion版本=「Exchange2010」不在SOAP_ENV:標題 中,這看起來有些可疑。
我看過someGoogle results但無法使其正常工作。
基本上我的問題是:
如何在生成的代碼中移動標籤或xmlns屬性直到它工作,而無需自己構造整個SOAP?
如果這是不可能的哪種方法最好,這樣我仍然可以從導入的類型庫中獲益? (東西一樣this?)
謝謝
月