Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
WCF绑定不匹配_Wcf - Fatal编程技术网

WCF绑定不匹配

WCF绑定不匹配,wcf,Wcf,我的WCF绑定将不匹配。我正在使用下面的源代码 static class Utilities { internal static MessageVersion MessageVersion { get { return MessageVersion.Soap12WSAddressing10; } } } public class LiveChatServiceHost : ServiceHost { public LiveChatServiceH

我的WCF绑定将不匹配。我正在使用下面的源代码

static class Utilities
{
    internal static MessageVersion MessageVersion
    {
        get { return MessageVersion.Soap12WSAddressing10; }
    }
}

public class LiveChatServiceHost : ServiceHost
{
    public LiveChatServiceHost(params System.Uri[] addresses)
    {
        base.InitializeDescription(typeof(LiveChatService), new UriSchemeKeyedCollection(addresses));
    }

    protected override void InitializeRuntime()
    {
        string pollTimeout = ConfigurationManager.AppSettings["PollTimeout"];
        string inactivityTimeout = ConfigurationManager.AppSettings["InactivityTimeout"];

        PollingDuplexBindingElement pdbe = new PollingDuplexBindingElement()
        {
            ServerPollTimeout = TimeSpan.Parse(pollTimeout),
            InactivityTimeout = TimeSpan.Parse(inactivityTimeout)
        };

        AddServiceEndpoint
        (
            typeof(ILiveChatService),
            new CustomBinding(pdbe,
                   new TextMessageEncodingBindingElement(Utilities.MessageVersion, System.Text.Encoding.UTF8),
                   new HttpTransportBindingElement()),
                   ""
        );

        base.InitializeRuntime();
    }
}
如果我看到WCF日志,那么

异常树:

System.ServiceModel.ProtocolException,System.ServiceModel, 版本=4.0.0.0,区域性=中性,PublicKeyToken=b77a5c561934e089

例外信息:

异常类型:System.ServiceModel.ProtocolException, System.ServiceModel,版本=4.0.0.0,区域性=中性, PublicKeyToken=b77a5c561934e089消息:内容类型 application/soap+msbin1已发送到一个服务,该服务需要 application/soap+xml;字符集=utf-8。客户端和服务绑定 可能不匹配。堆栈跟踪:
System.ServiceModel.Channel.HttpInput.ThrowHttpProtocolException(字符串 消息、HttpStatusCode状态代码、字符串状态描述) System.ServiceModel.Channels.HttpInput.ValidateContentType() System.ServiceModel.Channel.HttpInput.ParseIncomingMessage(异常& 请求(例外) System.ServiceModel.Channels.HttpRequestContext.CreateMessage() System.ServiceModel.Channel.HttpChannelListener.HttpContextReceived(HttpRequestContext 上下文、操作(回调) System.ServiceModel.Activation.HostedHttpTransportManager.HttpContextReceived(HostedHTTPPrequestAsyncResult 结果) System.ServiceModel.Activation.HostedHttpRequestAsyncResult.HandlerRequest() System.ServiceModel.Activation.HostedHttpRequestAsyncResult.BeginRequest() System.ServiceModel.Activation.HostedHttpRequestAsyncResult.OnBeginRequest(对象 (州) System.Runtime.IOThreadScheduler.ScheduledOrlApped.IOCallback(UInt32 错误代码,UInt32个字节,NativeOverlapped*NativeOverlapped) System.Runtime.Fx.IOCompletionThunk.UnhandledExceptionFrame(UInt32 错误,UInt32字节读取,NativeOverlapped*NativeOverlapped) System.Threading.\u IOCompletionCallback.PerformiCompletionCallback(UInt32 错误代码,UInt32个字节,本机重叠*pOVERLAP)

Web.Config

<system.serviceModel> 
   <behaviors> 
      <serviceBehaviors> 
         <behavior name=""> 
            <serviceMetadata httpGetEnabled="true" /> 
            <serviceDebug includeExceptionDetailInFaults="false" /> 
         </behavior> 
      </serviceBehaviors> 
   </behaviors> 
   <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
</system.serviceModel>


如何在帖子中显示配置?我无法添加web.config。此外,我没有客户端配置。我直接使用Wcf服务视图标记获取===