<?xml version="1.0"?> <configuration> <connectionStrings> <add name="NorthwindConnectionString" connectionString="Data Source=.;Initial Catalog=Northwind;User ID=sa;Password=123" providerName="System.Data.SqlClient"/> </connectionStrings> <system.web> <compilation debug="true" targetFramework="4.0"> <assemblies> <add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/></assemblies></compilation> </system.web> <system.serviceModel> <services> <service name="ProductsService" behaviorConfiguration="ServiceBehavior"> <!--Service Endpoints--> <endpoint address="" binding="wsHttpBinding" contract="IProductsService"/> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> </service> </services> <behaviors> <serviceBehaviors> <behavior> <!-- 为避免泄漏元数据信息,请在部署前将以下值设置为 false 并删除上面的元数据终结点 --> <serviceMetadata httpGetEnabled="true"/> <!-- 要接收故障异常详细信息以进行调试,请将以下值设置为 true。在部署前设置为 false 以避免泄漏异常信息--> <serviceDebug includeExceptionDetailInFaults="false"/> </behavior> </serviceBehaviors> </behaviors> <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/> </system.serviceModel> <system.webServer> <modules runAllManagedModulesForAllRequests="true"/> </system.webServer> </configuration>仔细研读代码,原来需要在<behavior>节点添加属性:name="ServiceBehavior"。修改完成后,在浏览器中查看,得到正确的Web服务。
应用程序中的服务器错误,没有名称为“ServiceBehavior”的服务行为
原文地址:http://blog.csdn.net/crazygolf/article/details/41206333