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'"

最新文章

  1. SSRS 2008 R2 错误:Timeout expired. The timeout period
  2. mysql:忘记root密码
  3. Yocto开发笔记之《Makefile编写》(QQ交流群:519230208)
  4. 介绍linux下利用编译bash设置root账号共用的权限审计设置
  5. mount: unknown filesystem type &#39;LVM2_member&#39;解决方案
  6. iOS开发--SWRevealViewController
  7. [html5] (Notification) 桌面通知
  8. Java邮件开发(JavaMail)
  9. SQL*Net message from client
  10. Entrez检索实例 - NCBI
  11. coreldraw圆形裁剪
  12. oracle表空间增长异常或表空间占用过高问题分析
  13. Python爬虫之selenium各种注意报错
  14. 设置chrome浏览器背景颜色
  15. Spring-MVC运行原理
  16. [转帖]再次提醒Google Chrome用户应尽快升级浏览器到72.0.3626.121
  17. MT【297】任意四边形的一个向量性质
  18. rhadoop linear regression 问题
  19. NSKeyValueObserving.m
  20. java下载文件注意点

热门文章

  1. springboot 全局异常处理
  2. mysql 单列索引限制
  3. tarjan算法和Kosaraju算法
  4. 【LeedCode】String to integer(atoi)
  5. 自己在用的几个sublime text3插件
  6. django CXRF介绍
  7. 【转】Celery 分布式任务队列快速入门
  8. Mathematica作图
  9. 学习PHPCMS需要掌握的函数
  10. python数据转换工具Into