客户端和服务端都在本机上运行
产生异常的名称:MessageSecurityException 产生异常的时间:2012-11-22 15:22:00 产生异常的描述:从另一方收到未进行安全处理或安全处理不正确的错误。有关错误代码和详细信息,请参见内部 FaultException。 产生异常应用程序或对象的名称:mscorlib 当前异常发生调用到的堆栈信息: Server stack trace: 在 System.ServiceModel.Channels.SecurityChannelFactory`1.SecurityRequestChannel.ProcessReply(Message reply, SecurityProtocolCorrelationState correlationState, TimeSpan timeout) 在 System.ServiceModel.Channels.SecurityChannelFactory`1.SecurityRequestChannel.Request(Message message, TimeSpan timeout) 在 System.ServiceModel.Security.SecuritySessionSecurityTokenProvider.DoOperation(SecuritySessionOperation operation, EndpointAddress target, Uri via, SecurityToken currentToken, TimeSpan timeout) 在 System.ServiceModel.Security.SecuritySessionSecurityTokenProvider.GetTokenCore(TimeSpan timeout) 在 System.IdentityModel.Selectors.SecurityTokenProvider.GetToken(TimeSpan timeout) 在 System.ServiceModel.Security.SecuritySessionClientSettings`1.ClientSecuritySessionChannel.OnOpen(TimeSpan timeout) 在 System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) 在 System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout) 在 System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) 在 System.ServiceModel.Channels.ServiceChannel.CallOpenOnce.System.ServiceModel.Channels.ServiceChannel.ICallOnce.Call(ServiceChannel channel, TimeSpan timeout) 在 System.ServiceModel.Channels.ServiceChannel.CallOnceManager.CallOnce(TimeSpan timeout, CallOnceManager cascade) 在 System.ServiceModel.Channels.ServiceChannel.EnsureOpened(TimeSpan timeout) 在 System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) 在 System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) 在 System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message) Exception rethrown at [0]: 在 System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) 在 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) 在 ConsoleApplication1.ServiceReference1.IMainContract.createTable(String xmlNText) 在 ConsoleApplication1.ServiceReference1.MainContractClient.createTable(String xmlNText) 位置 D:\Projects\DataBaseConnect\ConsoleApplication1\Service References\ServiceReference1\Reference.cs:行号 83 在 ConsoleApplication1.Form1.button1_Click(Object sender, EventArgs e) 位置 D:\Projects\DataBaseConnect\ConsoleApplication1\Form1.cs:行号 64 引发当前异常的方法: Void HandleReturnMessage(System.Runtime.Remoting.Messaging.IMessage, System.Runtime.Remoting.Messaging.IMessage) 产生异常的名称:FaultException 产生异常的时间:2012-11-22 15:22:00 产生异常的描述:验证消息的安全性时发生错误。 产生异常应用程序或对象的名称: 当前异常发生调用到的堆栈信息:
<?xml version="1.0" encoding="utf-8" ?> <configuration> <system.serviceModel> <bindings> <wsHttpBinding> <binding name="WSHttpBinding_IMainContract" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false"> <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" /> <security mode="Message"> <transport clientCredentialType="Windows" proxyCredentialType="None" realm="" /> <message clientCredentialType="UserName" negotiateServiceCredential="true" /> </security> </binding> </wsHttpBinding> </bindings> <client> <endpoint address="http://192.168.1.34/wcf/MainService.svc/basic" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IMainContract" contract="ServiceReference1.IMainContract" name="WSHttpBinding_IMainContract"> <identity> <certificate encodedValue="AwAAAAEAAAAUAAAAFrpoiG1epowMZ9OywAKFebGSN0sgAAAAAQAAAPgBAAAwggH0MIIBYaADAgECAhBTMi0aFOZwhk7ExrxD9qKzMAkGBSsOAwIdBQAwFjEUMBIGA1UEAxMLTWFpblNlcnZpY2UwHhcNMTIxMTIwMDEzNjIyWhcNMzkxMjMxMjM1OTU5WjAWMRQwEgYDVQQDEwtNYWluU2VydmljZTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAoQqKZNO1Rjj/Nmt7V7m+puIEqm9iU8yttAEtfhh/P118tw/3Y2PHO3Mcqe1Z6HNAzbLk4Xa8EerPtoJydVXFCJcOYCerGBpCMUJqm4XS6XEe1vqSaS0E6l/kH45Q2mvESwchDba01L/SPHGdnCM5ZIX3Qm1EzU1j36vuePHKAPECAwEAAaNLMEkwRwYDVR0BBEAwPoAQUSK3ypedzPjgRvXZQz5xaaEYMBYxFDASBgNVBAMTC01haW5TZXJ2aWNlghBTMi0aFOZwhk7ExrxD9qKzMAkGBSsOAwIdBQADgYEAW0XPBsE3NPibfaoVVzFo5EBUxt1ZMD8RlZMCaFM1YFfaF2hP/6JEhUgRDd1Tc5wxyaXJB1CSGwSPLqEsrsrY1rT1toJcHXQvyNTxT0V4VD+GE3aASFDVRZWqKLByt+HQ0VhiczysZwYowKpKt87GSm5VX2HBXeZjVE7k8pXjNKI=" /> </identity> </endpoint> </client> </system.serviceModel> </configuration>
<?xml version="1.0" encoding="utf-8"?> <configuration> <system.web> <compilation debug="true" targetFramework="4.0" /> </system.web> <system.serviceModel> <bindings > <wsHttpBinding > <binding name="NoneSecurity" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" useDefaultWebProxy="false"> <readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647" /> <!--使用密码进行身份验证--> <security mode="Message"> <message clientCredentialType="UserName" /> <transport clientCredentialType="Basic" proxyCredentialType="None" realm=""/> </security> </binding> </wsHttpBinding> </bindings> <services> <service name="ProjectServices.MainService"> <endpoint address="basic" binding="wsHttpBinding" bindingConfiguration="NoneSecurity" contract="ProjectContracts.IMainContract" /> <!--endpoint address="mex" binding="mexHttpBinding" contract="ProjectContracts.IMainContract"/> <endpoint address="mex" binding="mexTcpBinding" contract="ProjectContracts.IMainContract"/> <endpoint address="mex" binding="mexNamedPipeBinding" contract="ProjectContracts.IMainContract" /--> <host> <baseAddresses> <add baseAddress="http://192.168.1.34:8081/"/> <!--add baseAddress="http://192.168.1.34:8082/"/> <add baseAddress="net.tcp://192.168.1.34:8083/"/> <add baseAddress="net.pipe://192.168.1.34:8084/"/--> </baseAddresses> </host> </service> </services> <behaviors> <serviceBehaviors> <behavior> <!-- 为避免泄漏元数据信息,请在部署前将以下值设置为 false 并删除上面的元数据终结点 --> <serviceMetadata httpGetEnabled="true"/> <!-- 要接收故障异常详细信息以进行调试,请将以下值设置为 true。在部署前设置为 false 以避免泄漏异常信息 --> <serviceDebug includeExceptionDetailInFaults="true"/> <serviceCredentials> <issuedTokenAuthentication allowUntrustedRsaIssuers="true"></issuedTokenAuthentication> <clientCertificate> <authentication certificateValidationMode="None"/> </clientCertificate> <!--需要将证书ManiService 导入到受信任区,导入密码123456789--> <serviceCertificate findValue="MainService" storeName="My" storeLocation="LocalMachine" x509FindType="FindByIssuerName"/> <userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="ProjectServices.MyValidation,ProjectServices"/> </serviceCredentials> <!--服务允许最大并发会话数量--> <serviceThrottling maxConcurrentCalls="100" maxConcurrentInstances="100" maxConcurrentSessions="100" /> <!--1.AuditLogLocation枚举。其中Application和Security分别代表应用程序日志和安全日志。 如果选择Default,则最终日志被写入的位置决定于当前的操作系统 2.MessageAuthenticationAuditLevel和ServiceAuthorizationAuditLevel两个属性分别代表针对认证和授权审核的级别。 所谓审核的级别在这里指的应该在审核事件(认证和授权)在成功或者失败的情况下进行日志记录。审核级别通过具有如下定义 的AuditLevel枚举表示。Success和Failure代表分别针对认证/授权成功和失败进行审核日志。SuccessOrFailure则意味着 不管认证/授权是成功还是失败,都会进行审核日志。None为默认值,表示不进行审核日记记录。 3.布尔类型的SuppressAuditFailure属性表示审核日志失败是否会影响应用本身--> <serviceSecurityAudit auditLogLocation="Application" messageAuthenticationAuditLevel="SuccessOrFailure" serviceAuthorizationAuditLevel="SuccessOrFailure" suppressAuditFailure="true"/> <!--自定义进行服务授权--> <serviceAuthorization principalPermissionMode="Custom" serviceAuthorizationManagerType="ProjectServices.SimpleServiceAuthorizationManager,ProjectServices"> <authorizationPolicies> <add policyType="ProjectServices.SimpleAuthorizationPolicy,ProjectServices"/> </authorizationPolicies> </serviceAuthorization> </behavior> </serviceBehaviors> </behaviors> <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> </system.serviceModel> <system.webServer> <modules runAllManagedModulesForAllRequests="true"/> </system.webServer> </configuration>
要是能google的到 我就不来这里问了!