我的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被发送到期望application / soap xml的服务;字符集= UTF-8 . 客户端和服务绑定可能不匹配 . 堆栈跟踪:System.ServiceModel.Channels.HttpInput.ThrowHttpProtocolException(String message,HttpStatusCode statusCode,String statusDescription)System.ServiceModel.Channels.HttpInput.ValidateContentType()System.ServiceModel.Channels.HttpInput.ParseIncomingMessage(Exception&requestException)System.ServiceModel . Channels.HttpRequestContext.CreateMessage()System.ServiceModel.Channels.HttpChannelListener.HttpContextReceived(HttpRequestContext context,Action callback)System.ServiceModel.Activation.HostedHttpTransportManager.HttpContextReceived(HostedHttpRequestAsyncResult result)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.IOCompletionThu nk.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>