Note that there are some explanatory texts on larger screens.

plurals
  1. PO"Attribute is not declared" error in Delphi generated EWS SOAP request
    primarykey
    data
    text
    <p>This is working sample code calling ResolveNames in <a href="http://msdn.microsoft.com/en-us/library/bb204119%28EXCHG.80%29.aspx" rel="nofollow noreferrer">EWS</a> that I generated with <a href="http://www.soapui.org" rel="nofollow noreferrer">SoapUI</a> after retrieving the WDSL from Exchange Server:</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;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"&gt; &lt;soapenv:Header&gt;&lt;typ:RequestServerVersion Version="Exchange2010"/&gt;&lt;/soapenv:Header&gt; &lt;soapenv:Body&gt; &lt;mes:ResolveNames ReturnFullContactData="1" SearchScope="ActiveDirectoryContacts"&gt; &lt;mes:UnresolvedEntry&gt;deve&lt;/mes:UnresolvedEntry&gt; &lt;/mes:ResolveNames&gt; &lt;/soapenv:Body&gt; &lt;/soapenv:Envelope&gt; </code></pre> <p>This is the bare Delphi XE2 code that I use:</p> <pre><code>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); </code></pre> <p>It generates:</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;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"&gt; &lt;SOAP-ENV:Body xmlns:NS1="http://schemas.microsoft.com/exchange/services/2006/types"&gt; &lt;ResolveNames xmlns="http://schemas.microsoft.com/exchange/services/2006/messages" ReturnFullContactData="true" NS1:SearchScope="ActiveDirectoryContacts"&gt; &lt;UnresolvedEntry&gt;deve&lt;/UnresolvedEntry&gt; &lt;/ResolveNames&gt; &lt;MailboxCulture xsi:nil="true"/&gt; &lt;ExchangeImpersonation xsi:nil="true"/&gt; &lt;NS1:RequestServerVersion Version="Exchange2010"/&gt; &lt;/SOAP-ENV:Body&gt; &lt;/SOAP-ENV:Envelope&gt; </code></pre> <p>The error I get:<br /><br> The request failed schema validation: The '<a href="http://schemas.microsoft.com/exchange/services/2006/types:SearchScope" rel="nofollow noreferrer">http://schemas.microsoft.com/exchange/services/2006/types:SearchScope</a>' attribute is not declared.</p> <p>SearchScope is an attribute as defined in messages.xsd:</p> <pre><code>&lt;!-- ResolveNames request --&gt; &lt;xs:complexType name="ResolveNamesType"&gt; &lt;xs:complexContent&gt; &lt;xs:extension base="m:BaseRequestType"&gt; &lt;xs:sequence&gt; &lt;xs:element name="ParentFolderIds" type="t:NonEmptyArrayOfBaseFolderIdsType" minOccurs="0"/&gt; &lt;xs:element name="UnresolvedEntry" type="t:NonEmptyStringType"/&gt; &lt;/xs:sequence&gt; &lt;xs:attribute name="ReturnFullContactData" type="xs:boolean" use="required"/&gt; &lt;xs:attribute name="SearchScope" type="t:ResolveNamesSearchScopeType" default="ActiveDirectoryContacts"/&gt; &lt;/xs:extension&gt; &lt;/xs:complexContent&gt; &lt;/xs:complexType&gt; &lt;xs:element name="ResolveNames" type="m:ResolveNamesType"/&gt; </code></pre> <p>with in types.xsd:</p> <pre><code>&lt;!-- ResolveNames request --&gt; &lt;xs:simpleType name="ResolveNamesSearchScopeType"&gt; &lt;xs:restriction base="xs:string"&gt; &lt;xs:enumeration value="ActiveDirectory"/&gt; &lt;xs:enumeration value="ActiveDirectoryContacts"/&gt; &lt;xs:enumeration value="Contacts"/&gt; &lt;xs:enumeration value="ContactsActiveDirectory"/&gt; &lt;/xs:restriction&gt; &lt;/xs:simpleType&gt; </code></pre> <p>I thought that NS1:SearchScope="ActiveDirectoryContacts" is incorrect but leaving the NS1: out gives the same error.<br/> Maybe postponing the Exchange xmlns specs for types and messages to within the SOAP-ENV:Body is the reason for the error?<br/> Also, the NS1:RequestServerVersion Version="Exchange2010" not being in the SOAP_ENV:Header looks suspect.</p> <p>I have looked at <a href="https://stackoverflow.com/questions/12176625/ews-the-required-attribute-traversal-is-missing">some</a> <a href="http://www.delphigroups.info/2/5/344800.html" rel="nofollow noreferrer">Google results</a> but could not get it to work.</p> <p>Basically my question is:<br /> How can I move around the tags or xmlns attributes in the generated code until it works, without having to construct the entire SOAP myself?<br/> And if that is not possible what approach is best so that I can still benefit from the imported type library? (Stuff like <a href="https://stackoverflow.com/questions/1327151/soap-request-with-attribute">this</a>?)</p> <p>Thanks<br/> Jan</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload