创建WCF服务项目遇到的问题以及解决方法
2013-10-30 13:08
791 查看
1.“服务XXXXX有零个应用程序(非基础结构)终结点”。
产生原因:
<services>
<service name="DerivaticesClaculatorService.DerivaticesClaculatorServiceType" behaviorConfiguration="DerivaticesClaculatorService">
<host>
<baseAddresses>
<add baseAddress="http://localhost:7277/Claculator/"/>
</baseAddresses>
</host>
<endpoint address="http://localhost:7277/DerivaticesClaculatorServiceType/" binding="basicHttpBinding" contract="DerivaticesClaculatorService.IDerivativeCalculator">
</endpoint>
</service>
出现这个错误是因为service name由命名空间DerivaticesClaculatorService与提供的服务类名DerivaticesClaculatorServiceType组成,behaviorConfiguration是提供的服务类名,契约contract是命名控件DerivaticesClaculatorService和接口类IDerivativeCalculator组成.如果命名空间命或类名写错,或者写的不完全(比如只写了命名空间名字或者类名),则会出现上述错误。
解决办法:
1、按以上规则仔细核对。
2、如果实在找不到哪里写错,但程序还是报此错的话,还有一个办法:ServiceHost host = new ServiceHost(ServiceType) 改成
ServiceHost host = new ServiceHost(ServiceType,new Uri(http://localhost:7277/DerivaticesClaculatorServiceType/) ),也可以运行。
2.WCF服务发布以后,Client 端无法引用WCF服务,查看错误为“application soap+xml charset utf-8 客户端和服务绑定可能不匹配”。或者使用IE访问WCF服务地址的时候显示“当前已禁用此服务元数据的发布”。
(摘抄)按着《ASP.NET 3.5高级程序设计(第4版)》中的WCF案例一步步进行,书上说为了使初学者更好的关注WCF细节,先不使用WCF模版,但是进行到最后报出上述错误。书上写的配置是不包含<behaviors>节点的,这时Client 端无法正常连接服务,于是在网上各种找解决方法,在http://www.cnblogs.com/lanpei/archive/2009/10/29/1592218.html上找到累死问题解决方法,于是加上<behaviors>节点,此时仍然会报相同错误。因为书上的例子中没有<behaviors>节点,所以<service>节点中也不包含behaviorConfiguration属性,设置好behaviorConfiguration="CalculatorServiceBehavior",彻底没问题了。
按以上说法,我仔细核对了一下App.config文件
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service name="DerivaticesClaculatorService.DerivaticesClaculatorServiceType"
behaviorConfiguration="DerivaticesClaculatorService">
<host>
<baseAddresses>
<add baseAddress="http://localhost:7277/Claculator/"/>
</baseAddresses>
</host>
<endpoint address="http://localhost:7277/DerivaticesClaculatorServiceType/" binding="basicHttpBinding" contract="DerivaticesClaculatorService.IDerivativeCalculator">
</endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="DerivaticesClaculatorService">
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
其中的behavio段要设置好,前后要一致。
然后添加服务引用
注意服务引用的地址是baseAddress="http://localhost:7277/Claculator/",一定一定不要写成endpoint address="http://localhost:7277/DerivaticesClaculatorServiceType/“的了,这样就会报上面的错!
先暂时这么多,待补充。。。
产生原因:
<services>
<service name="DerivaticesClaculatorService.DerivaticesClaculatorServiceType" behaviorConfiguration="DerivaticesClaculatorService">
<host>
<baseAddresses>
<add baseAddress="http://localhost:7277/Claculator/"/>
</baseAddresses>
</host>
<endpoint address="http://localhost:7277/DerivaticesClaculatorServiceType/" binding="basicHttpBinding" contract="DerivaticesClaculatorService.IDerivativeCalculator">
</endpoint>
</service>
出现这个错误是因为service name由命名空间DerivaticesClaculatorService与提供的服务类名DerivaticesClaculatorServiceType组成,behaviorConfiguration是提供的服务类名,契约contract是命名控件DerivaticesClaculatorService和接口类IDerivativeCalculator组成.如果命名空间命或类名写错,或者写的不完全(比如只写了命名空间名字或者类名),则会出现上述错误。
解决办法:
1、按以上规则仔细核对。
2、如果实在找不到哪里写错,但程序还是报此错的话,还有一个办法:ServiceHost host = new ServiceHost(ServiceType) 改成
ServiceHost host = new ServiceHost(ServiceType,new Uri(http://localhost:7277/DerivaticesClaculatorServiceType/) ),也可以运行。
2.WCF服务发布以后,Client 端无法引用WCF服务,查看错误为“application soap+xml charset utf-8 客户端和服务绑定可能不匹配”。或者使用IE访问WCF服务地址的时候显示“当前已禁用此服务元数据的发布”。
(摘抄)按着《ASP.NET 3.5高级程序设计(第4版)》中的WCF案例一步步进行,书上说为了使初学者更好的关注WCF细节,先不使用WCF模版,但是进行到最后报出上述错误。书上写的配置是不包含<behaviors>节点的,这时Client 端无法正常连接服务,于是在网上各种找解决方法,在http://www.cnblogs.com/lanpei/archive/2009/10/29/1592218.html上找到累死问题解决方法,于是加上<behaviors>节点,此时仍然会报相同错误。因为书上的例子中没有<behaviors>节点,所以<service>节点中也不包含behaviorConfiguration属性,设置好behaviorConfiguration="CalculatorServiceBehavior",彻底没问题了。
按以上说法,我仔细核对了一下App.config文件
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service name="DerivaticesClaculatorService.DerivaticesClaculatorServiceType"
behaviorConfiguration="DerivaticesClaculatorService">
<host>
<baseAddresses>
<add baseAddress="http://localhost:7277/Claculator/"/>
</baseAddresses>
</host>
<endpoint address="http://localhost:7277/DerivaticesClaculatorServiceType/" binding="basicHttpBinding" contract="DerivaticesClaculatorService.IDerivativeCalculator">
</endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="DerivaticesClaculatorService">
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
其中的behavio段要设置好,前后要一致。
然后添加服务引用
注意服务引用的地址是baseAddress="http://localhost:7277/Claculator/",一定一定不要写成endpoint address="http://localhost:7277/DerivaticesClaculatorServiceType/“的了,这样就会报上面的错!
先暂时这么多,待补充。。。
相关文章推荐
- mac 使用MyEclipse时遇到无法创建web项目问题解决方法
- 创建WCF项目遇到的问题和解决办法续(二)
- rhel6.4 简单创建自己的http web 界面服务遇到的问题和解决方法
- 使用ArcGIS GP服务遇到的问题,原因以及解决方法 - 客户端API开发(Javascript/Flex/Silverlig 转载
- 项目开发遇到的问题以及解决方法
- 项目遇到的小问题以及解决方法
- 发布WCF服务到IIS遇到的问题及解决方法
- VS2008编译项目遇到的问题以及解决方法
- socket iOS 与java 后台进行socket通讯遇到的问题以及解决方法
- 记flume部署过程中遇到的问题以及解决方法(持续更新)
- eclipse maven创建一个maven web项目,以及创建过程中的报错解决方法
- UITextField遇到的一些问题以及解决方法
- SSH 项目过程中遇到的问题和解决方法汇总 struts2 spring hibernate
- 我在安装TFS 2008的时候遇到的问题以及解决方法一sharepoint 安装 打开站点 出现服务器不可用问题
- 近期学习hadoop遇到的问题以及解决方法
- 安装widows mysql 免安装版(zip) 步骤详解 以及遇到问题解决 以及忘记密码的修改方法
- SSH 项目过程中遇到的问题和解决方法汇总 struts2 spring hibernate
- 初触cocos2d-x,win32平台搭建以及创建第一个cocos2d-x项目遇到问题总结
- 在ASP.NET MVC 中宿主WCF Rest 服务的问题及解决方法