Unable to generate a WCF proxy using svcutil but retrieving the wsdl works?

Tags van Technorati: ,

The other day at a client project, we wanted to generate a proxy using svcutil as we’d done many times before.

However, the svcutil kept throwing strange error messages. Amongst them were:

  • Other mime type expected, expected application/soap+msbin1 but got application/soap+xml (HTTP error 415)
  • Could not import namespace <xyz>

As it turned out, the problem was the following: Everything seemed to work because going to the .svc URL and adding ?wsdl produced the desired output.

However, this wsdl does some schema imports, by referencing the svc URL, but this time using ?xsd=xsd0 , ?xsd=xsd1 etc. The strange thing was that these references produced errors (also when referenced by URL via Internet Explorer). This was also the reason that svcutil started throwing errors…

After some more investigation, the culprit became clear. In order to generated the xsd output, the WCF service executes some code generation and dynamically compiles this. (Discovered using the procesmon sysinternals tool). In order to be able to do that, the current Identity (in this case the AppPool Identity of our virtual directory) needs to have the &quot;List Folder / Read Data&quot; permission, which it does not normally have.

All these problems do not occur if you are running your website under the Network Service account, because account in fact does have these rights.

So in the end the trick is to add the additional right on the c:windowstemp folder for your App Pool Identity to solve the problem.

Interestingly, if you look at the default rights using IIS7 and Vista, there is a default right assigned to the IIS_IUSERS group on the c:windowstemp directory. Can you guess the additional permission 🙂 ? Probably MS has run into the same problem and fixed it in Vista and hopefully also in Windows Server 2008. In this case, making your App Pool Identity a member of the IIS_IUSERS group should be sufficient.

[15-2-2008: Fixed typo]