![](/img/trans.png)
[英]How Can I resolve WS2007HttpBinding WCF Service Binding in .NET Core Client Application
[英]WCF error calling Ws2007HttpBinding
我正在嘗試從WCF ws2007HttpBinding服務獲取數據,但是每次運行它時都會遇到以下錯誤:
Content Type application/soap+xml; charset=utf-8 was not supported by service
http://localhost/GoldInSacks.MutualFunds.local/MutualFunds.svc. The client
and service bindings may be mismatched.
InnerException讀取以下內容:
The remote server returned an error: (415) Cannot process the message because
the content type 'application/soap+xml; charset=utf-8' was not the expected
type 'text/xml; charset=utf-8'..
web.config的system.ServiceModel部分如下所示:
<system.serviceModel>
<services>
<service name="GoldInSacks.MutualFunds">
<endpoint address=""
binding="ws2007HttpBinding"
contract="GoldInSacks.MutualFunds.Local.IMutualFunds" />
</service>
</services>
<bindings>
<ws2007HttpBinding>
<binding>
<security mode="None" />
</binding>
</ws2007HttpBinding>
</bindings>
</system.serviceModel>
當前正在控制台應用程序中運行的客戶端代碼如下所示:
EndpointAddress address =
new EndpointAddress("http://localhost/MutualFunds.local/MutualFunds.svc");
var binding = new WS2007HttpBinding();
binding.Security.Mode = SecurityMode.None;
ChannelFactory<IMutualFundsChannel> channelFactory =
new ChannelFactory<IMutualFundsChannel>(binding, address);
IMutualFundsChannel channel = channelFactory.CreateChannel();
var mf = channel.GetMutualFundsByCustomer(1);
channel.Close();
foreach (var m in mf)
{
System.Console.WriteLine(m.Name);
}
System.Console.ReadLine();
調用GetMutualFundsByCustomer時發生錯誤。
我也嘗試過wsHttpBinding,但它給出了相同的錯誤。
有人知道如何進行這項工作嗎?
(對於這個問題的簡短性,我深表歉意,但是已經晚了,我需要睡覺)。
您是否在客戶端和服務端使用相同的SOAP版本? 也許相關? http://social.msdn.microsoft.com/Forums/zh-CN/wcf/thread/f29cd9c8-3c89-43d2-92ae-d2a270ab86b9/
干杯-喬克
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.