开发者

contract from other project than interface not visible

When I add to project a wcf service I could see it under Add Service Reference. But after move interface to another project, but the same namespace and type proper reference in contract to interface - I can not see my service under Add Service Reference.

Why? I miss something in config file ?

Service Config file should be in project with interface or contract ?

edit.

First project

using System.ServiceModel;
namespace Project.ServiceModel
{
    [ServiceContract]
    public interface ITest
    {
        [OperationContract]
        void DoWork();
    }
}

Second project

using Project.ServiceModel;

namespace Project.Service
{
    public class Test : ITest
    {
        public void DoWork()
        {
        }
    }
}

And that configuration in Test class project

<system.serviceModel>
<services>
  <service name="Project.Service.Test">
    <endpoint address="http://localhost:8732/Test/" binding="wsHttpBinding"
      contract="Project.ServiceModel.ITest">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:8732/LMTService/" />
      </baseAddresses>
    </host开发者_开发知识库>
  </service>
</services>
</system.serviceModel>


Edit contract="Project.ServiceModel.ITest" to reference a fully qualified name (including assembly name, not only namespace). Like contract="Project.ServiceModel.ITest, Project.ServiceModel", given your project name is Project.ServiceModel and assembly name is set up to be the same as project name (that's usually so by default).

And maybe it is a typo, but your mex address looks incorrect. Should be http://localhost:8732/Test/mex. It will still probably work with your current configuration, but you're breaking a convention.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜