WCF Test Client : Failed to add a service. Service metadata may not be accessible. Make sure your service is running and exposing metadata

妖精的绣舞 提交于 2019-12-22 08:39:46

问题


I am currently trying to get the sync framework sample working: sample

The solution compiles with out any error or warning.

But when I hit F5 the WCF Test Client launches and throws the following error.

Local\Temp\Test Client Projects\10.0\5b6aab8a-6629-4a12-87c2-e9e75ba9c1e4\Client.cs(379,13) : error CS0246: The type or namespace name 'schema' could not be found (are you missing a using directive or an assembly reference?)

Below is the code from Client.cs that the above error is referencing

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("svcutil", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.datacontract.org/2004/07/Microsoft.Synchronization")]
public partial class SyncIdFormatGroup
{
    private schema schemaField;
    private System.Xml.XmlElement anyField;

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Namespace="http://www.w3.org/2001/XMLSchema", Order=0)]
    public schema schema
    {
        get { return this.schemaField; }
        set { this.schemaField = value; }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlAnyElementAttribute(Order=1)]
    public System.Xml.XmlElement Any
    {
        get { return this.anyField; }
        set { this.anyField = value; }
    }
}

It would be great if some one could help me with the problem.


回答1:


Found the solution Ok, after spending lot of time I cracked it. For some reason if I run the sample as console app it just works fine. But the moment I use WCFTestClient I was getting errors. If I remove the [ServiceKnownType(typeof(SyncIdFormatGroup))] from the contract it works in WCFTestClient. Hope that helps someone.




回答2:


Have you enabled a mex (metadata exchange) endpoint in your service?

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



回答3:


Read the note at the end of the page: Note: If you use Visual Studio 2010 to compile these samples, you will first need to remove references to the Sync Framework assemblies and then re-add the assembly references to the projects. Otherwise, you will see "type or namespace name could not be found" compilation errors. http://code.msdn.microsoft.com/Database-Sync-SQL-Server-7e88adab#content or http://code.msdn.microsoft.com/Database-SyncSQL-Server-e97d1208



来源:https://stackoverflow.com/questions/7889115/wcf-test-client-failed-to-add-a-service-service-metadata-may-not-be-accessibl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!