在调用WCF服务时显示异常“服务器提交了协议违规.Section = ResponseStatusLine”
//Code for creating proxy public static DevicesServiceClient CreateProxy() { var proxy = new DevicesServiceClient("BasicHttpBinding_IDevicesService"); BasicHttpBinding binding = new BasicHttpBinding(); binding.Security.Mode = BasicHttpSecurityMode.None; binding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None; binding.UseDefaultWebProxy = false; binding.ProxyAddress = new Uri(string.Format("http://{0}:{1}","192.168.0.20","808")); proxy.Endpoint.Binding = binding; proxy.ClientCredentials.UserName.UserName = "Username"; proxy.ClientCredentials.UserName.Password = "Password"; }
服务器堆栈跟踪:
at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException,HttpWebRequest request,HttpAbortReason abortReason)
at ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message message,TimeSpan timeout)
at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message,TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action,Boolean oneway,
ProxyOperationRuntime operation,Object[] ins,Object[] outs,Object[] outs)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage
methodCall,ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg,IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&
msgData,Int32 type)
at DevicesService.IDevicesService.CheckNetworkConnection(String ipAddress)
我在app.config中的客户端代码
我在web.config中的服务器端代码