WCF--提示:"未找到终结点。"
刚开始调用WCF的时候一直报错...
““System.ServiceModel.EndpointNotFoundException”类型的异常在 mscorlib.dll 中发生,但未在用户代码中进行处理”
“其他信息: 没有终结点在侦听可以接受消息的 http://xx.xx.xx.xx:端口//Service1.svc。这通常是由于不正确的地址或者 SOAP 操作导致的。如果存在此情况,请参见 InnerException 以了解详细信息。”
点开详细信息:“InnerException:{"远程服务器返回错误: (404) 未找到。"}”
浏览器打开http://xx.xx.xx.xx:端口//Service1.svc/IService1/GetInfoByID
页面显示:“”未找到终结点。”
由此可见,是服务的问题了...
吾本以为简单的一个问题,搜一下,答案便可出矣...哀哉悲哉...折腾过来折腾过去,没毛线进展...
只好自己一步一个脚印来深入研究之,正好学习下...
了解的过程修改过来修改过去...
最终···得出一个结论...
不是IIS的问题就是web.config文件的配置问题...
最后一狠心...
将web.config全部删了...
抄来了一个完好的例子
原文地址:http://www.cnblogs.com/wujy/p/3386993.html
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="webHttp">
<webHttp helpEnabled="true"/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="MapConfigBehavior">
<!-- 为避免泄漏元数据信息,请在部署前将以下值设置为 false 并删除上面的元数据终结点 -->
<serviceMetadata httpGetEnabled="true"/>
<!-- 要接收故障异常详细信息以进行调试,请将以下值设置为 true。在部署前设置为 false 以避免泄漏异常信息 -->
<serviceDebug includeExceptionDetailInFaults="true"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<webHttpBinding>
<binding name="webHttpBindConfig" receiveTimeout="00:30:00" sendTimeout="00:30:00" maxReceivedMessageSize="104857600">
<readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647"/>
<security mode="None"></security>
</binding>
</webHttpBinding>
</bindings>
<services>
<service name="ServiceBll.UserBll" behaviorConfiguration="MapConfigBehavior">
<endpoint binding="webHttpBinding" contract="IServiceInterface.IUser" bindingConfiguration="webHttpBindConfig" behaviorConfiguration="webHttp"/>
</service>
</services>
</system.serviceModel>
</configuration>
...莫名其妙的好了...
现在是后台"添加服务引用"之后是可以调用服务了...
下一步还要解决.要前台ajax可以调用的方法...
支持 Ajax(只能算是一个折中的解决方案...No Pre)
web.config配置
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
</appSettings>
<system.webServer>
<handlers>
<remove name="WebDAV" />
</handlers>
<modules runAllManagedModulesForAllRequests="true" >
<remove name="WebDAVModule" />
</modules>
<directoryBrowse enabled="true"/>
<!--跨域..-->
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
<!--Content-Type,-->
<add name="Access-Control-Allow-Headers" value="Origin, X-Requested-With, Content-Type, Accept" />
<add name="Access-Control-Allow-Methods" value="GET,POST,PUT, DELETE, OPTIONS" />
</customHeaders>
</httpProtocol>
<security>
<requestFiltering>
<requestLimits maxQueryString="2147483640" maxUrl="2097151" maxAllowedContentLength="2097151"/>
</requestFiltering>
</security>
</system.webServer>
<system.web>
<customErrors mode="Off"/>
<compilation debug="true" targetFramework="4.0" />
<httpRuntime maxRequestLength="2147483647" maxUrlLength="2097151"/>
</system.web>
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="webHttp">
<enableWebScript/>
<!--2016年8月18日11:11:24-->
<webHttp helpEnabled="true"/>
</behavior>
<!--<behavior name="webBehavior">
<webHttp helpEnabled="true"/>
-->
<!--<enableWebScript />-->
<!--
</behavior>-->
</endpointBehaviors>
<serviceBehaviors>
<behavior name="MapConfigBehavior">
<!-- 为避免泄漏元数据信息,请在部署前将以下值设置为 false 并删除上面的元数据终结点 -->
<serviceMetadata httpGetEnabled="true"/>
<!-- 要接收故障异常详细信息以进行调试,请将以下值设置为 true。在部署前设置为 false 以避免泄漏异常信息 -->
<serviceDebug includeExceptionDetailInFaults="true"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<bindings>
<webHttpBinding>
<binding name="webHttpBindConfig" receiveTimeout="00:30:00" sendTimeout="00:30:00" maxReceivedMessageSize="2147483647" crossDomainScriptAccessEnabled="true">
<readerQuotas maxStringContentLength="2147483647" maxBytesPerRead="2147483647" maxArrayLength="2147483647" maxDepth="2147483647" maxNameTableCharCount="2147483647"/>
<security mode="None">
</security>
</binding>
</webHttpBinding>
</bindings>
<services>
<service name="PreAlert_WcfService.Service1" behaviorConfiguration="MapConfigBehavior">
<endpoint address="" binding="webHttpBinding" contract="PreAlert_WcfService.IService1" bindingConfiguration="webHttpBindConfig" behaviorConfiguration="webHttp"/>
<!--<endpoint address="" binding="webHttpBinding" contract="PreAlert_WcfService.IService1" bindingConfiguration="webHttpBindConfig" behaviorConfiguration="webHttp"/>-->
</service>
</services>
</system.serviceModel>
<connectionStrings>
<add name="xxxxDBEntities" connectionString="metadata=res://*/EFModel.csdl|res://*/EFModel.ssdl|res://*/EFModel.msl;provider=System.Data.SqlClient;provider connection string="data source=x.x.x.x;initial catalog=xxxxDB;persist security info=True;user id=xxxx;password=xxxx;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
<add name="SqlConnectionString" connectionString="Data Source=.;Initial Catalog=xxxx;Integrated Security=True;MultipleActiveResultSets=True;Application Name=EntityFramework" />
</connectionStrings>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
IService.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using System.IO;
using System.Runtime.Serialization.Json; namespace xxxx_WcfService
{
// 注意: 使用“重构”菜单上的“重命名”命令,可以同时更改代码和配置文件中的接口名“IService1”。
/// <summary>
/// 契约接口
/// </summary>
//[ServiceContract(Namespace = "")]
[ServiceContract(Namespace = "PreAlertService")]
public interface IService1
{ #region T_Menu(菜单栏的权限控制)
[OperationContract]
[WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)]
string T_TabName_Add(string jsonParames);
}
}
Service.svc.cs
using Common;
using DoMain;
using fastJSON;
using JS.Framework.Utility;
using Service.ServiceImp;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Net;
using System.Reflection;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;
using System.Text;
using System.Web;
/*
* 服务命名规范:表名_操作{例如:TabName_Action}
*/
namespace xxxx_WcfService
{
/// <summary>
/// WCF服务
/// </summary>
// 注意: 使用“重构”菜单上的“重命名”命令,可以同时更改代码、svc 和配置文件中的类名“Service1”。
// 注意: 为了启动 WCF 测试客户端以测试此服务,请在解决方案资源管理器中选择 Service1.svc 或 Service1.svc.cs,然后开始调试。
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
//[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
[JavascriptCallbackBehavior(UrlParameterName = "jsoncallback")]
//[ServiceBehavior(AddressFilterMode = AddressFilterMode.Any)]
public class Service1 : IService1
{
/// <summary>
/// 增加xx信息
/// </summary>
/// <param name="jsonParames">{ "xxxx":"xxxxID"}</param>
/// <returns></returns>
public string T_TabName_Add(string jsonParames)
{
#region Ajax...
if (jsonParames == null && HttpContext.Current.Request.QueryString["jsonParames"] != null)
jsonParames = HttpContext.Current.Request.QueryString["jsonParames"];
else if (jsonParames == null && HttpContext.Current.Request.QueryString["jsonParames"] == null)
return JSON.Instance.ToJSON("{\"ret\":\"0\",\"msg\":\"参数为空.\"}");
#endregion }
Service.svc
<%@ ServiceHost Language="C#" Debug="true" Service="xxxx_WcfService.Service1" CodeBehind="Service.svc.cs" %>
WCF--提示:"未找到终结点。"的更多相关文章
- oracle select into 的时候提示未找到数据
); begin '; --在select into 后面添加exception 错误处理机制 exception when no_data_found then version:= 'hhh '; ...
- oracle 安装提示未找到文件安装
安装oracle 过程中提示未找到文件 E:\app\xxj\product\11.2.0\dbhome_1\owb\external\oc4j_applications\applications\W ...
- Ubuntu、Windows输入命令appium-doctor提示未找到命令
输入命令:appium-doctor时,一直报错,提示“未找到命令”,但是输入命令:appium -v能够正确输出我安装版本,这是怎么回事呢? 原来appiu-doctor在1.5.3版本之后没有了需 ...
- VS Code 提示‘未找到Git。请安装Git,或在“git.path”设置中配置’
一.情况说明 1.描述 从Git上克隆出代码,用vscode打开项目提示“未找到Git.请安装Git,或在“git.path”设置中配置” 2.截图 二.报错原因 .没有安装Git .没有设置Git路 ...
- 安装的SQL Server2008 R2版的连接不到本地数据,提示未找到或无法访问服务器。----复制自百度知道
安装的SQL Server2008 R2版的连接不到本地数据,提示未找到或无法访问服务器.使用Windows身份验证 2012-09-17 00:23hj168926 | 分类:数据库DB | 浏览3 ...
- CentOS 7 使用unzip解压zip文件提示未找到命令的解决方法
故障现象: 解决方法: 如果你使用unzip命令解压.zip文件,提示未找到命令,可能是你没有安装unzip软件,下面是安装方法 [root@localhost www]# yum install - ...
- VS2012 提示未找到与约束 ContractName 匹配的倒出
问题描述: 今天由于开发需要,我安装了一下 Vs 2015 按照之后 打开原来的项目 vs2012 打开,点击类文件提示错误 未找到与约束 ContractName 匹配的倒出 解决办法: 1 去微 ...
- Javah提示未找到 ..的类文件
D:\我的文档\workspace\PrepareForExam\src>javah -classpath D:\我的文档\workspace\ PrepareForExam\src\com\e ...
- Matlab2014a 提示未找到支持的编译器或 SDK的解决方法
最近在写论文,用到了matlab版本的libsvm,在混合编译的时候遇到的一点小问题. 我电脑上装的是matlab2014a,window7 64位 >> mbuild -setup 错误 ...
随机推荐
- NuGet多个项目依赖的公共组件如何打包
会有这样一种情况:在同一个解决方案下面,类库A是独立的,类库B是依赖于类库A的:类似这样: 所以在使用类库B时必须引入类库A的东西,这时如果作为nuget包打包发布,有如下的解决思路: 1.在整个解决 ...
- 洛谷P1889 士兵站队
题目描述 在一个划分成网格的操场上, n个士兵散乱地站在网格点上.由整数 坐标 (x,y) 表示.士兵们可以沿网格边上.下左右移动一步,但在同时刻任一网格点上只能有名士兵.按照军官的命令,们要整齐地列 ...
- TCP/IP详解 笔记十四
TCP/IP协议(二) 连接的建立与终止 tcpdump -S输出TCP报文的格式 格式: 源>目的:标志 (标志就是tcp头部).标识首字符意义如下: 例如:telnet 某服务的输出(包括 ...
- shell处理mysql增、删、改、查
引言 这几天做一个任务,比对两个数据表中的数据,昨天用PHP写了一个版本,但考虑到有的机器没有php或者php没有编译mysql扩展,就无法使用mysql系列的函数,脚本就无效了,今天写个sh ...
- 分布式ID生成器
最近会写一篇分布式的ID生成器的文章,先占位.借鉴Mongodb的ObjectId的生成: 4byte时间戳 + 3byte机器标识 + 2byte PID + 3byte自增id 简单代码: imp ...
- HDU 1166 敌兵布阵(线段树模板题)
题目链接: 传送门 敌兵布阵 Time Limit: 2000MS Memory Limit: 32768 K Description C国的死对头A国这段时间正在进行军事演习,所以C国间谍头 ...
- java连接数据源-读取tomcat数据源配置
读取数据源配置,获取连接 1.配置数据源 D:\apache-tomcat-7.0.70\conf\context.xml <Resource name="jdbc/news" ...
- 【Alpha版本】 第六天 11.14
一.站立式会议照片: 二.项目燃尽图: 三.项目进展: 成 员 昨天完成任务 今天完成任务 明天要做任务 问题困难 心得体会 胡泽善 完成管理员的三大界面框架.完成管理主界面 完成我要招聘的招聘详情显 ...
- CentOS 6 日期 时间,时区,设置修改及时间同步
一.时区 显示时区 date --help 获取帮助 date -R date +%z 上面两个命令都可 [root@localhost ~]# date -R; date +%z Fri, 19 O ...
- 如何使用alt键+数字键盘上的数字键打出特殊符号
如何使用alt键+数字键盘上的数字键打出特殊符号 有时当我需要画示意图说明一个问题,但是苦于没有合适的符号,因此,这篇博文将简单介绍一些特殊的符号方便自己以及大家使用. 实现原理很简单:所有的字符(包 ...