WCF绑定不匹配

时间:2011-12-29 08:09:13

标签: wcf

我的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,     Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089

  
     

异常信息:

     

异常类型:System.ServiceModel.ProtocolException,   System.ServiceModel,Version = 4.0.0.0,Culture = neutral,   PublicKeyToken = b77a5c561934e089消息:内容类型   application / soap + msbin1被发送到期待的服务   应用/肥皂+ xml的;字符集= UTF-8。客户端和服务绑定   可能不匹配。堆栈跟踪:
  System.ServiceModel.Channels.HttpInput.ThrowHttpProtocolException(字符串   消息,HttpStatusCode statusCode,String statusDescription)   System.ServiceModel.Channels.HttpInput.ValidateContentType()   System.ServiceModel.Channels.HttpInput.ParseIncomingMessage(例外&安培;   requestException)   System.ServiceModel.Channels.HttpRequestContext.CreateMessage()   System.ServiceModel.Channels.HttpChannelListener.HttpContextReceived(HttpRequestContext   上下文,动作回调)   System.ServiceModel.Activation.HostedHttpTransportManager.HttpContextReceived(HostedHttpRequestAsyncResult   结果)   System.ServiceModel.Activation.HostedHttpRequestAsyncResult.HandleRequest()   System.ServiceModel.Activation.HostedHttpRequestAsyncResult.BeginRequest()   System.ServiceModel.Activation.HostedHttpRequestAsyncResult.OnBeginRequest(对象   州)   System.Runtime.IOThreadScheduler.ScheduledOverlapped.IOCallback(UInt32的   errorCode,UInt32 numBytes,NativeOverlapped * nativeOverlapped)   System.Runtime.Fx.IOCompletionThunk.UnhandledExceptionFrame(UInt32的   错误,UInt32 bytesRead,NativeOverlapped * nativeOverlapped)   System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32的   errorCode,UInt32 numBytes,NativeOverlapped * pOVERLAP)

Web.Config

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

0 个答案:

没有答案