WCF Add Service Reference gotcha with Windows Server
Posted by merill | Filed under .NET
We recently switched from developing in Vista to Windows Server 2003. Someone had the bright idea that we should develop in the same environment the application is going to be hosted on. Go figure.
What that meant is that you run into wierd issues like this one. When trying to add a Service Reference to a WCF service hosted under IIS you keep getting this 'Add Service Reference Error':
Metadata contains a reference that cannot be resolved: 'http://merill/Services.Host/ClientProfile.svc?wsdl'.
The WSDL document contains links that could not be resolved.
There was an error downloading 'http://merill/Services.Host/ClientProfile.svc?xsd=xsd0'.
The underlying connection was closed: An unexpected error occurred on a receive.
Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
An existing connection was forcibly closed by the remote host
Metadata contains a reference that cannot be resolved: 'http://localhost/Services.Host/ClientProfile.svc'.
Metadata contains a reference that cannot be resolved: 'http://localhost/Services.Host/ClientProfile.svc'.
If the service is defined in the current solution, try building the solution and adding the service reference again.
The key part of this message is the reference to the downloading of the xsd. When I tried accessing the .svc url in a browser it worked fine, but trying to access the .svc?xsd=xsd0 brings up the generic 'cannot display webpage' message.
When you unleash your weapon (Process Monitor) on the csc.exe process (this is the compiler generating the xsd) you'll realise that the IIS identity IIS_WPG does not have access to the Windows\Temp folder. Give enough rights to the folder and viola problemo solved.
Happy WCF programming on Windows Server!
- Windows 7: WiFi slow to connect or Limited Connectivity
- Installing SharePoint Server 2010 on Windows 7
- Show Folder Tree in Windows 7 Explorer
January 31st, 2009 at 8:36 am
thx a lot ! it helps
February 10th, 2009 at 12:03 pm
Hey many thanks for this post, i’ve been hours trying to solve this problem, thanks again
February 20th, 2009 at 7:41 am
That was the most helpful article I have found on this issue. No way I would have thought of looking for directory permissions. Thanks.
July 14th, 2009 at 4:53 pm
Thanks a lot for the post. I had a similiar issue. Your solution resolved the issue.
August 22nd, 2009 at 9:57 am
Thankyou! This solved my problem.
November 11th, 2009 at 3:29 am
Thank you very much! I wouldn’t have come to this solution on my own!
February 3rd, 2010 at 6:25 am
[...] WCF service in IIS needs write access to windows temp directory By skuppa I migrated my WCF services to Prod windows 2003 box and started getting the following error. Error: Cannot import wsdl:portTypeDetail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporterError: Schema with target namespace 'http://www.odh.ohio.gov/ELR2/contract' could not be found After initially being perplexed at what could have gone wrong and frantically searching for resolution on google found this blog post. [...]
February 12th, 2010 at 12:40 am
Thank you! You save my time!