WCF问题

时间:2011-01-03 08:41:08

标签: wcf

嘿,这是我的班级代码

    namespace WcfServicepractice
   {
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class WebDataService1 : IMyclass
    {
        public int add(int a, int b)
        {
            return a + b;
        }
        public int multi(int a, int b)
        {
            return a * b;
        }
    }
}

这是我的界面代码,

namespace WcfServicepractice
{

    [ServiceContract]
    public interface  IMyclass
    {
        [OperationContract]
        int add(int a,int b);

        [OperationContract]
        int multi(int a, int b);
    }


}

这是我的服务的web.config

 <behavior name="WcfServicepractice.WebDataService1Behavior">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="false" />
 </behavior>

<service name="WcfServicepractice.WebDataService1" behaviorConfiguration="WcfServicepractice.WebDataService1Behavior" >
   <endpoint address="" binding="wsHttpBinding" contract="WcfServicepractice.IMyclass" >
     <identity>
          <dns value="localhost" />
     </identity>
   </endpoint>
   <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>

当我运行代码时,我收到此错误

  

无法找到网页

有人可以帮忙吗?

谢谢..

1 个答案:

答案 0 :(得分:0)

从您的错误中我假设您正在尝试在IIS中托管服务(在这种情况下可能使用Cassini服务器)

您的项目中是否有svc文件? 你在浏览什么地址?

您应该浏览以下内容:http://localhost:someport/service.svc