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. twitter api取出的日期格式化

    import pickle import datetime crate_time_list=[] twitter_id_list=[] twitter_url_list=[] twitter_text ...

  2. xdebug参数说明

    ;;;;;;;;;;;;;;;;;;;;;;;;; Basic Features; xdebug基本功能,如堆栈跟踪,递归错误安全输出,时间内存跟踪等;;;;;;;;;;;;;;;;;;;;;;;;; ...

  3. jQuery获取标签中的元素

    获取双标签之间的内容 在JavaScript中,获取双标签之间的内容是这样的: <!DOCTYPE html> <html lang="en"> <h ...

  4. 轻量级批量管理工具pssh

    pssh工具 pssh工具是个轻量级的批量管理工具,相比同类型的开源工具 Ansible,Saltstack,他比较轻量级,需要对管理的主机做秘钥认证 Ansible是可以做秘钥认证,也可以通过配置文 ...

  5. hdu 1410(直线与矩形相交)

    Intersection Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 13528   Accepted: 3521 Des ...

  6. 如何在qt中使用中文输入法

    参考: http://blog.csdn.net/u013812682/article/details/52101088 dpkg -L fcitx-frontend-qt5 到qt安装目录里find ...

  7. AC日记——[JSOI2008]火星人prefix bzoj 1014

    1014 思路: 平衡树+二分答案+hash: 好了懂了吧. 代码: #include <cstdio> #include <cstring> #include <ios ...

  8. 【转】Python模块subprocess

    subprocess 早期的Python版本中,我们主要是通过os.system().os.popen().read()等函数.commands模块来执行命令行指令的,从Python 2.4开始官方文 ...

  9. 微信token

    <?php define("TOKEN", "lmaster"); function checkSignature() { //从GET参数中读取三个字段 ...

  10. HDU 1039.Easier Done Than Said?-条件判断字符串

    Easier Done Than Said? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/O ...