【发布时间】:2016-04-10 23:16:23
【问题描述】:
我正在尝试开发 WCF 服务,但是我一个接一个地遇到了几个错误 WCFTestClient 正在弹出,我整天都在尝试解决它们,查看几个教程并阅读这里的帖子,但是我想不通找出它发生的原因,我做错了什么以及如何解决它。
但首先,环境,我在 Visual Studio 2013 的开发过程中,调试,在 IIS 或其他任何地方都没有托管。现在它看起来像这样:
Models: EntityFramework 模型,没什么大不了的,只是一个用于实验的表,它来自我在开发 PC 上的本地数据库。
WebService: WCF Web 服务,我整天都在尝试开发,但现在没有成功。
IPersonService 类代码是这样的:
[ServiceContract]
public interface IPersonService
{
[OperationContract]
List<tblUsers> GetPersons();
}
在 PersonService.svc 中的代码是这样的:
public class PersonService : IPersonService
{
public List<tblUsers> GetPersons()
{
using (var db = new PersonsEntities())
{
return db.tblUsers.ToList();
}
}
}
神奇的配置,我在这里找到的各种帖子整天都在困惑:
<bindings>
<basicHttpBinding>
<binding name="BindingConfig" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" closeTimeout="01:50:00" openTimeout="01:50:00" sendTimeout="01:50:00" receiveTimeout="01:50:00" >
<readerQuotas maxDepth="128" maxStringContentLength="8388608" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="PersonSvcBehavior">
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceMetadata httpGetEnabled="true" />
<dataContractSerializer ignoreExtensionDataObject="false" maxItemsInObjectGraph="2147483646" />
</behavior>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="PersonSvcBehavior" name="WebService.PersonService">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="BindingConfig"
name="PersonSvcBasicHttpBinding" contract="WebService.IPersonService" />
<endpoint address="mex" binding="mexHttpBinding" bindingConfiguration="BindingConfig"
name="PersonSvcMexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:1569/webservice" />
</baseAddresses>
</host>
</service>
</services>
【问题讨论】:
标签: c# entity-framework web-services wcf