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

一般是地址写错了,此处的重点在InnerException,发现是连不上"127.0.0.1:8084",所以我的WCF服务端有问题

正确写法如下(控制台作为宿主):

            //创建宿主的基地址
Uri baseAddress = new Uri("http://localhost:8084/Service1.svc"); //创建宿主
using (ServiceHost host = new ServiceHost(typeof(Service1), baseAddress))
{
//向宿主中添加终结点
//host.AddServiceEndpoint(typeof(IService1), new WSHttpBinding() ,"");
System.ServiceModel.Channels.Binding httpbinding = new BasicHttpBinding(); host.AddServiceEndpoint(typeof(IService1), httpbinding, ""); //将HttpGetEnabled属性设置为true
ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
smb.HttpGetEnabled = true; //将行为添加到Behaviors中
host.Description.Behaviors.Add(smb); //打开宿主
host.Open();
Console.WriteLine("WCF中的HTTP监听已启动....");
Console.ReadLine();
//host.Close();
}

2、"服务 http://localhost:8082/Service1.svc 不支持内容类型 text/xml; charset=utf-8。客户端和服务绑定可能不匹配。"

根据上面那句搜的解决方法都不行,重点还是在InnerException里,说希望类型是'text/xml; charset=utf-8',此时异常的类型是'application/soap+xml; charset=utf-8'

远程服务器返回错误: (415) Cannot process the message because the content type 'text/xml; charset=utf-8' was not the expected type 'application/soap+xml; charset=utf-8'.。

//写WSHttpBinding报错
host.AddServiceEndpoint(typeof(IService1), new WSHttpBinding() ,""); //当前场景正确调用方式
System.ServiceModel.Channels.Binding basicHttpBinding = new BasicHttpBinding();
host.AddServiceEndpoint(typeof(IService1), basicHttpBinding , "");

此工厂上启用了手动寻址,因此发送的所有消息都必须进行预寻址

需要有   webBehavior

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.serviceModel>
<bindings> <webHttpBinding>
<binding name="ServiceReference" />
</webHttpBinding>
</bindings> <behaviors>
<endpointBehaviors>
<behavior name="webBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors> <client> <endpoint address="http://XXX.XXX.XXX.XXX:8085/Service.svc?wsdl"
binding="webHttpBinding" bindingConfiguration="GYSFC_ServiceReference" behaviorConfiguration="webBehavior"
contract="ServiceReference.IService" name="ServiceReference" /> </client>
</system.serviceModel>
</configuration>

约定“IService”的操作“ResetPWD”指定要序列化多个请求正文参数,但没有任何包装元素。如果没有包装元素,至多可序列化一个正文参数。请删除多余的正文参数,或将 WebGetAttribute/WebInvokeAttribute 的 BodyStyle 属性设置为 Wrapped。

参考:

解决"415 Cannot process the message because the content type 'application/x-www-form-urlencoded' was not the expected type 'text/xml; charset=utf-8'"

WCF报错的更多相关文章

  1. 关于WCF报错之调用方未由服务器进行身份验证

    在我们部署好WCF服务以后,调用WCF服务会出现”调用方未由服务器进行身份验证”的错误.这个错误是怎么造成的呢? 通常我们在创建WCF后,用本机调试,一切正常,没有任何问题.其实用本机测试的时候,服务 ...

  2. 项目中重新引用WCF报错

    今天在一个项目里,重新更新WCF引用的时候,居然报错了,提示根本找不到那个WCF接口,我赶紧跑去新建了一个空项目,试着用相同的地址引用一下,发现是可以的,完全ok 既然是虚惊一场,那就得想办法把这个W ...

  3. 客服端调用自定义宿主的WCF报错"没有终结点在侦听可以接受消息的http://localhost:8085/mex。这通常是由于不正确的地址或者 SOAP 操作导致的错误"的解决方案。

    没有终结点在侦听可以接受消息的http://localhost:8085/mex.这通常是由于不正确的地址或者 SOAP 操作导致的错误. 这个错误是由于没有启动元数据交换终结点(MEX)导致的.在宿 ...

  4. IIS运行WCF服务报错

    试图加载格式不正确的程序   image 解决方法   image HTTP 错误 500.19   image 解决方法在控制面板————>程序————>启用或关闭windows功能—— ...

  5. EF相关报错

    EF7无法找寻依赖问题解决方案 现象:使用EF7的过程中,任何"dnx . XXX"的都会报错,提示"cannot resolve dependencies for ta ...

  6. Eclipse导入SpringBoot项目pom.xml第一行报错Unknown error

    1.网上搜的都说是将SpringBoot2.1.5版本降级到SpringBoot2.1.4版本,感觉这治标不治本啊,以后想升级不是玩完了. 错误如下所示: 参考:https://ask.csdn.ne ...

  7. 踩坑记录--接口调用,传参DataTable报错

    问题描述 服务端提供接口,接口参数包含DataTable类型,客户端调用显示请求报错,Postman调用显示Could not get response 解决 原因 接口实现基于wcf,而wcf参数类 ...

  8. Windows 7上执行Cake 报错原因是Powershell 版本问题

    在Windows 7 SP1 电脑上执行Cake的的例子 http://cakebuild.net/docs/tutorials/getting-started ,运行./Build.ps1 报下面的 ...

  9. 关于VS2015 ASP.NET MVC添加控制器的时候报错

    调试环境:VS2015 数据库Mysql  WIN10 在调试过程中出现类似下两图的同学们,注意啦. 其实也是在学习的过程中遇到这个问题的,找了很多资料都没有正面的解决添加控制器的时候报错的问题,还是 ...

随机推荐

  1. String、ANSIString、PChar及TBytes之间的转换 BytesOf move stringof

    一.string转为ansistring 1.直接赋值 (有警告)2.ansistring()类型强制转换.(无警告) 二.ansistring 转为string 1.直接赋值 (有警告)2.stri ...

  2. 《Java编程思想》笔记 第三章 操作符

    1.操作符种类: 运算顺序1-7 一元操作符(单目操作符)  - 负号, + 正号,--递减,++递增 算术操作符 + - *  /  % 移位操作符  <<左移(低位补0),>&g ...

  3. Eclipse svn代码提交冲突

    Eclipse svn代码提交冲突(转) 1.Synchronize视图下查看代码冲突 1.Incoming Mode 全部update,更新到本地2.Outgoing Mode 全部commit,提 ...

  4. elasticSearch script api

    Package org.elasticsearch.script Support for running user provided scripts (in the request, in clust ...

  5. 成都项目中因为MYSQL与SSDB备分时间不一致,导致主键产生器错误解决一例

    -- JFinal错误提示 Duplicate entry '1791361-1823391' for key 'PRIMARY' -- 1.查看SSDB的主键生成器值ssdb 127.0.0.1:8 ...

  6. hdu5829

    多校训练8,有官方题解 主要之前没写过ntt,感觉不是很懂原根 先贴一份当模板吧 #include<iostream> #include<cstdio> #include< ...

  7. AC日记——Dynamic Problem Scoring codeforces 807d

    Dynamic Problem Scoring 思路: 水题: 代码: #include <cstdio> #include <cstring> #include <io ...

  8. Codeforces 608 B. Hamming Distance Sum-前缀和

      B. Hamming Distance Sum   time limit per test 2 seconds memory limit per test 256 megabytes input ...

  9. 前端学习blog

    有一些js写的小游戏,很有趣  http://oldj.net

  10. 0103 最短Hamilton路径【状压DP】

    0103 最短Hamilton路径 0x00「基本算法」例题 描述 给定一张 n(n≤20) 个点的带权无向图,点从 0~n-1 标号,求起点 0 到终点 n-1 的最短Hamilton路径. Ham ...