Last post Jul 18, 2007 03:46 PM by realbart
Jul 31, 2006 05:05 PM|bensonjin|LINK
Moving from PHP to ASP. Is it ever hard?! been struggling with C# for almost 3 weeks by now, still have hundreds questions... here is one that I need to figure out soon.
Basically, I am writing a page that will list all contacts under a public folder in Exchange 2003. below is the query, in C#:
strQuery = "<?xml version=\"1.0\"?>"
+ "<D:searchrequest xmlns:D=\"DAV:\"><D:sql>"
+ "SELECT "
+ ",\"urn:schemas:contacts:telephoneNumber\" "
+ "FROM \"" + strRootURI + "\" "
+ "WHERE \"DAV:ishidden\" = false AND \"DAV:isfolder\" = false "
+ "ORDER BY \"urn:schemas:contacts:cn\" ASC"
// then I use following line to retrive info.
DisplayNameNodes = ResponseXmlDoc.GetElementsByTagName("a:displayname");
// here is the problem:
DisplayNameNodes = ResponseXmlDoc.GetElementsByTagName("prefix_of_urn:schemas:contacts:o");
so what on earth is the prefix letter of urn:schemas:contacts? I have been searching on the net, with no luck at all.
Any help or hints would be greatly appreciated!
Aug 08, 2006 12:40 PM|airwalker08|LINK
If I may clarify, your question relates more directly to Exchange WebDAV rather than C#.
Are you receiving an error of some sort? It's difficult to tell from your post precisely what peice of information that you need. Do you receive any sort of error when you post the request or does it return the proper WebDAV response? The "prefix letter"
is merely an alias that is defined within the reponse's top-level node. Your response will have something like
Problem is, you can't expect it to always be the same letter. The WebDAV engine basically begins with the letter "a" for the first namespace in the output, then uses the letter "b" for the next namespace and so on until all namespaces are aliased.
I am also a relative newbie to using WebDAV, but here is what I did to overcome this... I wrote a parsing function that first reads the top level node containing all of the alias definitions. The process then locates every instace of every alias and completely
removes it from the response text (note that it removes the alias rather than replaces it, thus leaving only the field name in each node). Once all aliases are completely removed, the resulting text is actually properly formed XML. You can then use the intrinsic
.net XML classes to read the XML and extract whatever info you need.
Hope that helps!!
Aug 11, 2006 10:22 AM|bensonjin|LINK
thank you for your reply. I will try the same.
Jul 18, 2007 03:46 PM|realbart|LINK
There is an easy solution:
Put a textlabel TextLabel1 on your page and insert te command
TextLabel1.Text = DisplayNameNodes.innerXml
(i'm not too sure about Capitals but you get the idea)
If you run your app en view source, you can see the exact name of each field