调用webservice:不支持内容类型 text/xml; charset=utf-16LE,怎么解决?

Leon370Leon 2014-07-20 06:33:23
调用webservice报错:服务 http://192.168.2.101:6003/LisCenterService 不支持内容类型 text/xml; charset=utf-8。客户端和服务绑定可能不匹配。
代码如下,什么地方有问题,缺少什么,直接用配置文件没问题
public string ss()
{
BasicHttpBinding bind = new BasicHttpBinding();
bind.Name = "WSHttpBinding_ILisCenterContract";
bind.MaxReceivedMessageSize = int.MaxValue;
bind.MaxBufferPoolSize = int.MaxValue;
bind.MessageEncoding = WSMessageEncoding.Text;
bind.TextEncoding = System.Text.Encoding.UTF8;
bind.MaxBufferSize = int.MaxValue;
bind.ReaderQuotas.MaxStringContentLength = int.MaxValue;
Uri baseAddress = new Uri("http://192.168.2.101:6003/LisCenterService");

EndpointAddress ea = new EndpointAddress(baseAddress);

WJZYYLJJK.LJZXJK.LisCenterContractClient Ljjk = new WJZYYLJJK.LJZXJK.LisCenterContractClient(bind,ea);
string s = Ljjk.DownAssayItemFromCenter();
return s;
}

app.config如下
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_ILisCenterContract" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="100"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="100" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="None">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://192.168.2.101:6003/LisCenterService"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_ILisCenterContract"
contract="LJZXJK.ILisCenterContract" name="WSHttpBinding_ILisCenterContract" />
</client>
</system.serviceModel>
</configuration>
...全文
473 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
TheWonderMan 2016-12-29
  • 打赏
  • 举报
回复
在页面上右击更新对应的服务过后,即可解决问题 配置WCF端的服务的时候,注意对SOAP验证的用户名和密码的验证, 然后basicHttpBinding和serviceBehaviors的配置,避免在更新的时候,节点重复。

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧