0
votes

I can get xml content of service via browser

but somehow cant add as service referance in Visual Studio same link with ?wsdl extension.

The error message in visual studio;

The document at the url http://****?wsdl was not recognized as a known document type. The error message from each known type may help you fix the problem: - Report from 'XML Schema' is 'The root element of a W3C XML Schema should be and its namespace should be 'http://www.w3.org/2001/XMLSchema'.'. - Report from 'DISCO Document' is 'Discovery document at the URL http://****?wsdl could not be found.'.

how can I fix it ?

1
http://****?wsdl exist? Open WSDL link with browser and check it. - selami

1 Answers

0
votes

Have you enabled metadata discovery in WCF?

First off you need to add a mex (Metadata exchange) endpoint like this to the service in web.config, if you are declaratively setting up your WCF service (you can do this also programatically):

<service name="myservice">
 <endpoint contract="IMetadataExchange" binding ="mexHttpBinding" address="mex" />
 <endpoing contract="SomeAssembly.SomeService" address="SomeService" binding="basicHttpBinding" ... 

Note that I will not suggest you use BasicHttpBinding as it default is not set up with security, use WsHttpBinding instead for instance.

Now also add this serviceBehavior:

<serviceBehaviors>
 <serviceMetadata httpGetEnabled="true" />

You will find this well documented and a good sample for example here: WCF Service Behaviors – How to Generate Service Metadata to simplify WCF Client Application Development

Then check again if the WSDL link works of your service. You might want to check out the installed features of IIS if is still not working, maybe your IIS config and setup is not correect.