WCF publish error: metadata contains a link that cannot be resolved:

I have a WCF web service that I am trying to publish to IIS. I can view wsdl fine, but I can’t add a service in Visual Studio 2010 using the "Add Service Link" menu. I get the following error:

Metadata contains a reference that cannot be resolved: 'http://localhost:4567/Service.svc?wsdl'. The WSDL document contains links that could not be resolved. There was an error downloading 'http://localhost:4567/Service.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:4567/Service.svc'. Content Type application/soap+xml; charset=utf-8 was not supported by service http://localhost:4567/Service.svc. The client and service bindings may be mismatched. The remote server returned an error: (415) Cannot process the message because the content type 'application/soap+xml; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'.. If the service is defined in the current solution, try building the solution and adding the service reference again. 

I work fine locally, but not published to IIS.

Does anyone know what causes this problem? Here is my web.config, I'm new to WCF, maybe I missed something, thanks:

 <?xml version="1.0"?> <configuration> <system.web> <compilation debug="true" targetFramework="4.0" /> </system.web> <system.serviceModel> <behaviors> <serviceBehaviors> <behavior> <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --> <serviceMetadata httpGetEnabled="true"/> <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --> <serviceDebug includeExceptionDetailInFaults="true"/> </behavior> </serviceBehaviors> </behaviors> <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> </system.serviceModel> <system.webServer> <modules runAllManagedModulesForAllRequests="true"/> </system.webServer> <connectionStrings> </connectionStrings> </configuration> 
+4
source share
8 answers

I sincerely wish Microsoft to provide better diagnostics in order to provide us with more focused WCF configuration error information, either at build time or at run time. I don’t care which one, but he spent so much time developing over the years, this is unrealistic.

 </rant> 

For me, this is a ridiculously common cause of error:

 <endpoint address="mexTcp" binding="mexTcpBinding" contract="IMetadataExchange"/> 

Must be:

 <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/> 

Two hours of confusion about trying to enable Net.Tcp for something that could easily be distinguished in the IDE. Two hours!!!

+4
source

Since this is one of the first messages google detects for this error, I want to participate with my solution:

I got a similar error when changing the code on a well-functioning system, but the help update on my development system failed. The link is inside the silverlight project and is linked to WCF integrated into the surrounding site (standard configuration, I assume).

My error message entered

β€œWCF metadata contains a link that cannot be resolved:β€œ Some ridiculous way. ”The content type is text / html; charset = utf-8 of the response message does not match the content type of the binding (application / soap + xml; charset = utf-8).

My website uses the authorization roles in which the problem / solution was based. To update the help desk, I had to allow all users:

 <?xml version="1.0"?> <configuration> <system.web> <!--<authorization> <allow users="*"/> </authorization>--> <authorization> <deny users="?"/> <allow roles="role-1,role-2"/> <deny users="*"/> </authorization> </system.web> </configuration> 
+3
source

See the answer here on the MSDN forum

When you define net tcp, you need to make sure that you are using the IMetadataExchange contract defined in the endpoint contract. The service behavior for this should also contain the <serviceMetadata /> . From what I understood, this is pretty boilerplate code for your configuration if you want to host and generate proxys / discovery in VS.

 <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" /> 
+2
source

I basically got the same error message when trying to update a service link from one of our test servers. Exact text (remote IP addresses, etc.):

 There was an error downloading 'http://xxx.xxx.xxx.xxx/xxxxxxxWSNew/Service.svc/_vti_bin/ListData.svc/$metadata'. The request failed with HTTP status 400: Bad Request. Metadata contains a reference that cannot be resolved: 'http://xxx.xxx.xxx.xxx/xxxxxxxWSNew/Service.svc'. Content Type application/soap+xml; charset=utf-8 was not supported by service http://xxx.xxx.xxx.xxx/xxxxxxxWSNew/Service.svc. The client and service bindings may be mismatched. The remote server returned an error: (415) Cannot process the message because the content type 'application/soap+xml; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'.. 

This seemed unbelievable to me, so I used Fiddler to find out what actual responses were returning from the server when VS tried to create a proxy server from metadata. It turns out that the metadata pointed VS to the host name that the server identifies itself as - for example, wwww.server.com. The corresponding host file entry has been added and the proxy server has been generated successfully.

0
source

I had this problem when one of my DataMember objects had a constructor. I am not sure if these were parameters for the constructor or something inside it. But I managed to solve it by making the constructor a static method, which returned the new type that it had previously created for.

0
source

I can view wsdl fine, but I can not add a service in Visual Studio 2010 through the Add Service Reference menu

Try using the WSDL tool, open the Visual Studio command prompt:

 wsdl.exe /out:c:\temp\WebService.cs /order www.webadress.com?wsdl 
0
source

Adding to the list of things that cause error 415, in my case, I forgot to add the [DataContract] and [DataMember] to the class that the service used.

0
source

In my case, it was the missing empty constructor for one of the classes returned by the service. after adding the error has been deleted.

  public ClassName() {} 
0
source

Source: https://habr.com/ru/post/1493152/


All Articles