Thursday 17 November 2011

There was a problem loading the XSD documents provided: a reference to a schema element with name X and namespace Y could not be resolved because the element definition could not be found in the schema for targetNamespace Z.

Posting this one mostly as a reminder for myself:

I was working on extending some existing WCF service in development, while an older version already deployed to production. Let's say our production site is
www.borismod.com
and my local machine name is borism
When I tried to create a local proxy of the web service I got the following error:

(all the ULRs and namespaces are fictive)

>svcutil http://www.borismod.com/RealGeekyURL/mex

Attempting to download metadata from 'http://www.borismod.com/RealGeekyURL/mex' using WS-Metadata Exchange or DISCO.
Error: Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporter
Error: There was a problem loading the XSD documents provided: a reference to a schema element with name 'DoSomeCrazyGeekyStuff' and namespace 'http://borismod.blogspot.com/' could not be resolved because the element definition could not be found in the schema for targetNamespace 'http://www.borismod.com/'. Please check the XSD docu
ments provided and try again.
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://www.borismod.com/']/wsdl:portType[@name='ISomeRealGeekService']

Problem:
The actual problem is that there are references from the WSDL to some internal classes. The references point to the production site. The new added classes were missing in production.

Solution:
Point in host file to the local machine, actually adding the following line in hosts file:
127.0.0.1 www.borismod.com