If you are using Exchange Web Services (EWS) against Exchange 2007 SP1, you may run into an issue where you are getting the ErrorNoPublicFolderServerAvailable and the error message says it’s not a proper error code. This error appears if you have set the ”Exchange2007_SP1”, your code is accessing public folder and there is no public folder on the Exchange server.
Here is an example of what you might get back when using auto-generated proxies:
Exception Type - System.InvalidOperationException
Exception Message - Instance validation error: 'ErrorNoPublicFolderServerAvailable' is not a valid value for ResponseCodeType.
See, public folders not installed by default when Exchange 2007 is installed. Service Pack 1 for Exchange 2007 added support for public access with EWS if you add the ”Exchange2007_SP1” header to your EWS call.
“messages.xsd “is used for schema validation. So, it needs to be correct in order for validation to work. As of rollup 4, these are the only "PublicFolder" errors enumerated in messages.xsd:
<xs:enumeration value="ErrorOperationNotAllowedWithPublicFolderRoot" />
So… where is ErrorNoPublicFolderServerAvailable?
Apparently the “ErrorNoPublicFolderServerAvailable” enumeration error code was left out of messages.xsd and that’s what’s causing the xml parser to say it’s not a valid error code. The solution for making it a valid error code is to put that error code into the XSD as a viable error code.
The suggested thing to do is add the ErrorNoPublicFolderServerAvailable entry to messages.xsd (usually located under "C:\Program Files\Microsoft\Exchange Server\ClientAccess\exchweb\ews") and regenerating the proxies to see if it resolves the issue with the error. The only change to message.xsd file is to add an enumeration to the schema which covers this error.
Here is what to try for the work-around:
1. Copy the services.wsdl, messages.xsd, and types.xsd files down from your CAS server onto your local machine where you're running the Visual Studio proxy generator.
2. Edit the file "messages.xsd." and add the enumeration value ErrorNoPublicFolderServerAvailable to the ResponseCodeType enumeration in that file. This means you'll add a line that looks like:
<xs:enumeration value="ErrorNoPublicFolderServerAvailable" />
3. Generate new proxy classes using the WSDL/XSD files on your local machine (instead of from the Exchange server)
Read the following for more information on the ”Exchange2007_SP1” header:
Updating Exchange Server 2007 Exchange Web Service Clients to SP1