WCF服务端点中的异常 [英] Exception in WCF service endpoint

查看:75
本文介绍了WCF服务端点中的异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始使用WCF服务应用程序,我得到一个异常,我试图解决它,但它显示在端点地址中的异常,下面是我的代码配置fie,请他找出异常



I just started with WCF Service application where i am getting an exception i tried to resolve it but it shows there as an exception in endpoint address the below is my code with config fie, kindly he me to figure out the exception

<system.serviceModel>
   <services>
     <service name="CompanyService.CompanyService" behaviorConfiguration="mexbehaviour">
       <endpoint address="/CompanyService" binding="basicHttpBinding"  contract="CompanyService.ICompanyPubicService"></endpoint>
       <endpoint address="/CompanyService" binding="netTcpBinding"  contract="CompanyService.IComanyConfidentialService"></endpoint>
       <host>
         <baseAddresses>
           <add baseAddress="http://localhost:8080/"/>
           <add baseAddress="net.tcp://localhost:8090/"/>
         </baseAddresses>
       </host>
     </service>
   </services>
   <behaviors>
     <serviceBehaviors>
       <behavior name="mexbehaviour">
         <serviceMetadata httpGetEnabled="true"/>
       </behavior>
     </serviceBehaviors>
   </behaviors>
 </system.serviceModel>







namespace CompanyService
{
    public class CompanyServie:ICompanyPubicService,IComanyConfidentialService
    {
        public string GetPublicInformation()
        {
            return "Public Information via HTTP";
        }

        public string GetConfidentialInformation()
        {
            return "Confidential Information via TCP";
        }
    }
}







namespace CompanyService
{
    [ServiceContract]
    public interface ICompanyPubicService
    {
        [OperationContract]
        string GetPublicInformation();
    }
    [ServiceContract]
    public interface IComanyConfidentialService
    {
        [OperationContract]
        string GetConfidentialInformation();
    }
}





以下是发生错误

System.ServiceModel.dll



附加信息:服务'CompanyService.CompanyServie'没有应用程序(非基础结构)端点。这可能是因为没有为您的应用程序找到配置文件,或者因为在配置文件中找不到与服务名称匹配的服务元素,或者因为在服务元素中没有定义端点。



如果有这个例外的处理程序,程序可以安全地继续。



below is an error occurring
System.ServiceModel.dll

Additional information: Service 'CompanyService.CompanyServie' has zero application (non-infrastructure) endpoints. This might be because no configuration file was found for your application, or because no service element matching the service name could be found in the configuration file, or because no endpoints were defined in the service element.

If there is a handler for this exception, the program may be safely continued.

推荐答案

你似乎在类定义中有一个拼写错误在您的源代码中,在以下行中:



You seem to have a typo in the class definition in your source code, in the following line:

public class CompanyServie:ICompanyPubicService,IComanyConfidentialService





类名拼写与配置文件不同:





The class name is spelled differently from your config file:

<service name="CompanyService.CompanyService" behaviorConfiguration="mexbehaviour">





这很可能是异常的原因。



This is most likely the cause of the exception.


这篇关于WCF服务端点中的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆