刚开始调用WCF的时候一直报错...

““System.ServiceModel.EndpointNotFoundException”类型的异常在 mscorlib.dll 中发生,但未在用户代码中进行处理”

“其他信息: 没有终结点在侦听可以接受消息的 http://xx.xx.xx.xx:端口//Service1.svc。这通常是由于不正确的地址或者 SOAP 操作导致的。如果存在此情况,请参见 InnerException 以了解详细信息。”

点开详细信息:“InnerException:{"远程服务器返回错误: (404) 未找到。"}”

  1. 浏览器打开http://xx.xx.xx.xx:端口//Service1.svc/IService1/GetInfoByID
  2. 页面显示:“”未找到终结点。”

由此可见,是服务的问题了...

吾本以为简单的一个问题,搜一下,答案便可出矣...哀哉悲哉...折腾过来折腾过去,没毛线进展...

只好自己一步一个脚印来深入研究之,正好学习下...

  1. 了解的过程修改过来修改过去...

最终···得出一个结论...

不是IIS的问题就是web.config文件的配置问题...

最后一狠心...

将web.config全部删了...

抄来了一个完好的例子

原文地址:http://www.cnblogs.com/wujy/p/3386993.html

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <configuration>
  3. <system.web>
  4. <compilation debug="true" targetFramework="4.0" />
  5. </system.web>
  6. <system.serviceModel>
  7. <behaviors>
  8. <endpointBehaviors>
  9. <behavior name="webHttp">
  10. <webHttp helpEnabled="true"/>
  11. </behavior>
  12. </endpointBehaviors>
  13. <serviceBehaviors>
  14. <behavior name="MapConfigBehavior">
  15. <!-- 为避免泄漏元数据信息,请在部署前将以下值设置为 false 并删除上面的元数据终结点 -->
  16. <serviceMetadata httpGetEnabled="true"/>
  17. <!-- 要接收故障异常详细信息以进行调试,请将以下值设置为 true。在部署前设置为 false 以避免泄漏异常信息 -->
  18. <serviceDebug includeExceptionDetailInFaults="true"/>
  19. <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
  20. </behavior>
  21. </serviceBehaviors>
  22. </behaviors>
  23. <bindings>
  24. <webHttpBinding>
  25. <binding name="webHttpBindConfig" receiveTimeout="00:30:00" sendTimeout="00:30:00" maxReceivedMessageSize="104857600">
  26. <readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647"/>
  27. <security mode="None"></security>
  28. </binding>
  29. </webHttpBinding>
  30. </bindings>
  31. <services>
  32. <service name="ServiceBll.UserBll" behaviorConfiguration="MapConfigBehavior">
  33. <endpoint binding="webHttpBinding" contract="IServiceInterface.IUser" bindingConfiguration="webHttpBindConfig" behaviorConfiguration="webHttp"/>
  34. </service>
  35. </services>
  36. </system.serviceModel>
  37. </configuration>

...莫名其妙的好了...

现在是后台"添加服务引用"之后是可以调用服务了...

下一步还要解决.要前台ajax可以调用的方法...

支持 Ajax(只能算是一个折中的解决方案...No Pre)

web.config配置

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <configuration>
  3. <appSettings>
  4. </appSettings>
  5. <system.webServer>
  6. <handlers>
  7. <remove name="WebDAV" />
  8. </handlers>
  9. <modules runAllManagedModulesForAllRequests="true" >
  10. <remove name="WebDAVModule" />
  11. </modules>
  12. <directoryBrowse enabled="true"/>
  13. <!--跨域..-->
  14. <httpProtocol>
  15. <customHeaders>
  16. <add name="Access-Control-Allow-Origin" value="*" />
  17. <!--Content-Type,-->
  18. <add name="Access-Control-Allow-Headers" value="Origin, X-Requested-With, Content-Type, Accept" />
  19. <add name="Access-Control-Allow-Methods" value="GET,POST,PUT, DELETE, OPTIONS" />
  20. </customHeaders>
  21. </httpProtocol>
  22. <security>
  23. <requestFiltering>
  24. <requestLimits maxQueryString="2147483640" maxUrl="2097151" maxAllowedContentLength="2097151"/>
  25. </requestFiltering>
  26. </security>
  27. </system.webServer>
  28. <system.web>
  29. <customErrors mode="Off"/>
  30. <compilation debug="true" targetFramework="4.0" />
  31. <httpRuntime maxRequestLength="2147483647" maxUrlLength="2097151"/>
  32. </system.web>
  33. <system.serviceModel>
  34. <behaviors>
  35. <endpointBehaviors>
  36. <behavior name="webHttp">
  37. <enableWebScript/>
  38. <!--2016年8月18日11:11:24-->
  39. <webHttp helpEnabled="true"/>
  40. </behavior>
  41. <!--<behavior name="webBehavior">
  42. <webHttp helpEnabled="true"/>
  43. -->
  44. <!--<enableWebScript />-->
  45. <!--
  46. </behavior>-->
  47. </endpointBehaviors>
  48. <serviceBehaviors>
  49. <behavior name="MapConfigBehavior">
  50. <!-- 为避免泄漏元数据信息,请在部署前将以下值设置为 false 并删除上面的元数据终结点 -->
  51. <serviceMetadata httpGetEnabled="true"/>
  52. <!-- 要接收故障异常详细信息以进行调试,请将以下值设置为 true。在部署前设置为 false 以避免泄漏异常信息 -->
  53. <serviceDebug includeExceptionDetailInFaults="true"/>
  54. <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
  55. </behavior>
  56. </serviceBehaviors>
  57. </behaviors>
  58. <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  59. <bindings>
  60. <webHttpBinding>
  61. <binding name="webHttpBindConfig" receiveTimeout="00:30:00" sendTimeout="00:30:00" maxReceivedMessageSize="2147483647" crossDomainScriptAccessEnabled="true">
  62. <readerQuotas maxStringContentLength="2147483647" maxBytesPerRead="2147483647" maxArrayLength="2147483647" maxDepth="2147483647" maxNameTableCharCount="2147483647"/>
  63. <security mode="None">
  64. </security>
  65. </binding>
  66. </webHttpBinding>
  67. </bindings>
  68. <services>
  69. <service name="PreAlert_WcfService.Service1" behaviorConfiguration="MapConfigBehavior">
  70. <endpoint address="" binding="webHttpBinding" contract="PreAlert_WcfService.IService1" bindingConfiguration="webHttpBindConfig" behaviorConfiguration="webHttp"/>
  71. <!--<endpoint address="" binding="webHttpBinding" contract="PreAlert_WcfService.IService1" bindingConfiguration="webHttpBindConfig" behaviorConfiguration="webHttp"/>-->
  72. </service>
  73. </services>
  74. </system.serviceModel>
  75. <connectionStrings>
  76. <add name="xxxxDBEntities" connectionString="metadata=res://*/EFModel.csdl|res://*/EFModel.ssdl|res://*/EFModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=x.x.x.x;initial catalog=xxxxDB;persist security info=True;user id=xxxx;password=xxxx;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
  77. <add name="SqlConnectionString" connectionString="Data Source=.;Initial Catalog=xxxx;Integrated Security=True;MultipleActiveResultSets=True;Application Name=EntityFramework" />
  78. </connectionStrings>
  79. <runtime>
  80. <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  81. <dependentAssembly>
  82. <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" />
  83. <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
  84. </dependentAssembly>
  85. </assemblyBinding>
  86. </runtime>
  87. </configuration>

IService.cs

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Runtime.Serialization;
  5. using System.ServiceModel;
  6. using System.ServiceModel.Web;
  7. using System.Text;
  8. using System.IO;
  9. using System.Runtime.Serialization.Json;
  10.  
  11. namespace xxxx_WcfService
  12. {
  13. // 注意: 使用“重构”菜单上的“重命名”命令,可以同时更改代码和配置文件中的接口名“IService1”。
  14. /// <summary>
  15. /// 契约接口
  16. /// </summary>
  17. //[ServiceContract(Namespace = "")]
  18. [ServiceContract(Namespace = "PreAlertService")]
  19. public interface IService1
  20. {
  21.  
  22. #region T_Menu(菜单栏的权限控制)
  23. [OperationContract]
  24. [WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)]
  25. string T_TabName_Add(string jsonParames);
  26. }
  27. }

Service.svc.cs

  1. using Common;
  2. using DoMain;
  3. using fastJSON;
  4. using JS.Framework.Utility;
  5. using Service.ServiceImp;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Data;
  9. using System.Data.Entity;
  10. using System.Data.Entity.Infrastructure;
  11. using System.Drawing;
  12. using System.Drawing.Imaging;
  13. using System.IO;
  14. using System.Linq;
  15. using System.Net;
  16. using System.Reflection;
  17. using System.ServiceModel.Activation;
  18. using System.ServiceModel.Web;
  19. using System.Text;
  20. using System.Web;
  21. /*
  22. * 服务命名规范:表名_操作{例如:TabName_Action}
  23. */
  24. namespace xxxx_WcfService
  25. {
  26. /// <summary>
  27. /// WCF服务
  28. /// </summary>
  29. // 注意: 使用“重构”菜单上的“重命名”命令,可以同时更改代码、svc 和配置文件中的类名“Service1”。
  30. // 注意: 为了启动 WCF 测试客户端以测试此服务,请在解决方案资源管理器中选择 Service1.svc 或 Service1.svc.cs,然后开始调试。
  31. [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
  32. //[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
  33. [JavascriptCallbackBehavior(UrlParameterName = "jsoncallback")]
  34. //[ServiceBehavior(AddressFilterMode = AddressFilterMode.Any)]
  35. public class Service1 : IService1
  36. {
  37. /// <summary>
  38. /// 增加xx信息
  39. /// </summary>
  40. /// <param name="jsonParames">{ "xxxx":"xxxxID"}</param>
  41. /// <returns></returns>
  42. public string T_TabName_Add(string jsonParames)
  43. {
  44. #region Ajax...
  45. if (jsonParames == null && HttpContext.Current.Request.QueryString["jsonParames"] != null)
  46. jsonParames = HttpContext.Current.Request.QueryString["jsonParames"];
  47. else if (jsonParames == null && HttpContext.Current.Request.QueryString["jsonParames"] == null)
  48. return JSON.Instance.ToJSON("{\"ret\":\"0\",\"msg\":\"参数为空.\"}");
  49. #endregion
  50.  
  51. }

Service.svc

  1. <%@ ServiceHost Language="C#" Debug="true" Service="xxxx_WcfService.Service1" CodeBehind="Service.svc.cs" %>

WCF--提示:"未找到终结点。"的更多相关文章

  1. oracle select into 的时候提示未找到数据

    ); begin '; --在select into 后面添加exception 错误处理机制 exception when no_data_found then version:= 'hhh '; ...

  2. oracle 安装提示未找到文件安装

    安装oracle 过程中提示未找到文件 E:\app\xxj\product\11.2.0\dbhome_1\owb\external\oc4j_applications\applications\W ...

  3. Ubuntu、Windows输入命令appium-doctor提示未找到命令

    输入命令:appium-doctor时,一直报错,提示“未找到命令”,但是输入命令:appium -v能够正确输出我安装版本,这是怎么回事呢? 原来appiu-doctor在1.5.3版本之后没有了需 ...

  4. VS Code 提示‘未找到Git。请安装Git,或在“git.path”设置中配置’

    一.情况说明 1.描述 从Git上克隆出代码,用vscode打开项目提示“未找到Git.请安装Git,或在“git.path”设置中配置” 2.截图 二.报错原因 .没有安装Git .没有设置Git路 ...

  5. 安装的SQL Server2008 R2版的连接不到本地数据,提示未找到或无法访问服务器。----复制自百度知道

    安装的SQL Server2008 R2版的连接不到本地数据,提示未找到或无法访问服务器.使用Windows身份验证 2012-09-17 00:23hj168926 | 分类:数据库DB | 浏览3 ...

  6. CentOS 7 使用unzip解压zip文件提示未找到命令的解决方法

    故障现象: 解决方法: 如果你使用unzip命令解压.zip文件,提示未找到命令,可能是你没有安装unzip软件,下面是安装方法 [root@localhost www]# yum install - ...

  7. VS2012 提示未找到与约束 ContractName 匹配的倒出

    问题描述: 今天由于开发需要,我安装了一下 Vs 2015 按照之后 打开原来的项目 vs2012 打开,点击类文件提示错误 未找到与约束 ContractName 匹配的倒出 解决办法: 1  去微 ...

  8. Javah提示未找到 ..的类文件

    D:\我的文档\workspace\PrepareForExam\src>javah -classpath D:\我的文档\workspace\ PrepareForExam\src\com\e ...

  9. Matlab2014a 提示未找到支持的编译器或 SDK的解决方法

    最近在写论文,用到了matlab版本的libsvm,在混合编译的时候遇到的一点小问题. 我电脑上装的是matlab2014a,window7 64位 >> mbuild -setup 错误 ...

随机推荐

  1. 洛谷P1629 邮递员送信

    题目描述 有一个邮递员要送东西,邮局在节点1.他总共要送N-1样东西,其目的地分别是2~N.由于这个城市的交通比较繁忙,因此所有的道路都是单行的,共有M条道路,通过每条道路需要一定的时间.这个邮递员每 ...

  2. (译)你应该知道的jQuery小技巧

    帮助提高你jQuery应用的简单小技巧 回到顶部按钮 图片预加载 判断图片是否加载完 自动修补破损图像 Hover切换class类 禁用输入 停止正在加载的链接 toggle fade/slide 简 ...

  3. CF 405B Domino Effect(想法题)

    题目链接: 传送门 Domino Effect time limit per test:1 second     memory limit per test:256 megabytes Descrip ...

  4. python获取知乎日报另存为txt文件

    前言 拿来练手的,比较简单(且有bug),欢迎交流~ 功能介绍 抓取当日的知乎日报的内容,并将每篇博文另存为一个txt文件,集中放在一个文件夹下,文件夹名字为当日时间. 使用的库 re,Beautif ...

  5. 【Beta版本】冲刺-Day3

    队伍:606notconnected 会议时间:12月11日 目录 一.行与思 二.站立式会议图片 三.燃尽图 四.代码Check-in 一.行与思 张斯巍(433) 今日进展:学习了很多androi ...

  6. iOS - 全屏滑动

    取经地址 1.使用关联 关联是指把两个对象相互关联起来,使得其中的一个对象作为另一个对象的一部分. 使用关联,是基于关键字的,因此,我们可以为任意对象增加任意多的关联,但是关键字是唯一的.关联可以保证 ...

  7. POJMatrix(二维树状数组)

    Matrix Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 22058   Accepted: 8219 Descripti ...

  8. centos 6 安装

    centos 6 安装步骤  说明: 1.install or upgrade an existing system安装或升级现有系统 2.install system with basic vide ...

  9. IOS 中的CoreImage框架(framework)

    http://www.cnblogs.com/try2do-neo/p/3601546.html coreimage framework 组成 apple 已经帮我们把image的处理分类好,来看看它 ...

  10. Eclipse导入项目:No projects are found to import

    1 http://www.ztyhome.com/android-import-error/(网址不稳定详细内容如下:) 2如果发现导入工程(impot)的时候,出现”No projects are ...