我的第一个WCF程序出错? [英] Error with my First WCF program?

查看:65
本文介绍了我的第一个WCF程序出错?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为我的新应用程序从WCF开始,并尝试使用WCF,但是遇到错误:-(..以下是详细信息:

I am trying to start with WCF for my new App and was trying my hands with WCF but faced error :-(. Below are the details:

[ServiceContract()]



public interface IFirstWcfService



{



 [OperationContract]



 string MyOperation1(string myValue1);



 [OperationContract]



 string MyOperation2(Person personValue);



}







public class FirstWcfService : IFirstWcfService



{



 public string MyOperation1(string myValue1)



 {



 return "Hello" + myValue1;



 }



 public string MyOperation2(Person personValue)



 {



 return "Hello: " + personValue.FirstName;



 }



}







[DataContract]



public class Person



{



 string firstName;



 string lastName;







 [DataMember]



 public string FirstName



 {



 get { return firstName; }



 set { firstName = value; }



 }



 [DataMember]



 public string LastName



 {



 get { return lastName; }



 set { lastName = value; }



 }



}



推荐答案

问题是在web.config文件中,服务类和服务合同名称不完全限定.因此,假设您的类和接口的名称空间是WcfService1,请将您的配置更改为此:

The problem is that in the web.config file the service class and the service contract names are not fully qualified. So assuming the namespace for your class and interface is WcfService1, change your config to this:

< 服务 名称 = " WcfService1. FirstWcfService " 行为配置 = " returnFaults &;     < 端点 合同 = " WcfService1. IFirstWcfService " 绑定 = " wsHttpBinding &; < 端点 地址 = " mex " 合同 = " IMetadataExchange &; 绑定 = " mexHttpBinding &; </ 服务 >

<service name="WcfService1.FirstWcfService" behaviorConfiguration="returnFaults">
    <endpoint contract="WcfService1.IFirstWcfService" binding="wsHttpBinding"/>
    <endpoint address="mex" contract="IMetadataExchange" binding="mexHttpBinding"/>
</service>

,它应该可以工作.如果您还有其他问题,请告诉我.

and it should work. Let me know if you have any further questions.

谢谢

迈克尔·格林[MSFT]

Michael Green [MSFT]

 


这篇关于我的第一个WCF程序出错?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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