wcf 访问返回时报错。
服务端配置
<system.web>
<compilation debug="true" targetFramework="4.0" />
<membership defaultProvider="HCCMMembershipProvider">
<providers>
<add name="HCCMMembershipProvider" type="HCCM.Security.HCCMMembershipProvider,HCCM.Security" />
</providers>
</membership>
</system.web>
<system.serviceModel>
<diagnostics wmiProviderEnabled="true">
<messageLogging logMalformedMessages="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" />
</diagnostics>
<bindings>
<basicHttpBinding>
<binding name="LargeDataTransferServicesBinding" maxReceivedMessageSize="2147483647" messageEncoding="Mtom" transferMode="Streamed" sendTimeout="00:10:00">
<readerQuotas maxArrayLength="2147483647" />
</binding>
</basicHttpBinding>
<wsHttpBinding>
<binding name="DefaultWSHttpBinding" maxBufferPoolSize="2147483647" sendTimeout="00:30:00" receiveTimeout="00:30:00" closeTimeout="00:30:00" openTimeout="00:30:00" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="Message">
<message clientCredentialType="UserName" establishSecurityContext="true" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="serviceBehavior" name="HCCM.Service.HCCMManagementService">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="DefaultWSHttpBinding"
contract="HCCM.Common.Service.Base.IHCCMManagementService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="UploadWcfService.UpLoadServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
<behavior name="serviceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
<serviceCredentials>
<serviceCertificate findValue="HCCM" storeLocation="LocalMachine"
storeName="My" x509FindType="FindBySubjectName" />
<userNameAuthentication userNamePasswordValidationMode="MembershipProvider"
membershipProviderName="HCCMMembershipProvider" />
</serviceCredentials>
<serviceAuthorization principalPermissionMode="Custom">
<authorizationPolicies>
<add policyType="HCCM.Security.HCCMAuthorizationPolicy,HCCM.Security" />
</authorizationPolicies>
</serviceAuthorization>
<serviceSecurityAudit auditLogLocation="Application"
serviceAuthorizationAuditLevel="Failure" messageAuthenticationAuditLevel="Failure" />
</behavior>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647"
messageEncoding="Mtom" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
<wsHttpBinding>
<binding name="DefaultWSHttpBinding" closeTimeout="00:30:00"
openTimeout="00:30:00" receiveTimeout="00:30:00" sendTimeout="00:30:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<reliableSession ordered="true" inactivityTimeout="00:30:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:1055/HCCM.Service/HCCMManagementService.svc"
binding="wsHttpBinding" bindingConfiguration="DefaultWSHttpBinding"
contract="HCCM.Common.Service.Base.IHCCMManagementService"
name="WSHttpBinding_IHCCMManagementService"
behaviorConfiguration="hccmClientEndpointBehavior">
<identity>
<dns value="HCCM"/>
</identity>
</endpoint>
<endpoint address="http://localhost/HQ.Service/FileUploadService.svc"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IUploadSvc"
contract="HCCM.Common.Service.Base.IFileUploadService"
name="WSHttpBinding_IFileUploadService">
</endpoint>
</client>
<behaviors>
<endpointBehaviors>
<behavior name="hccmClientEndpointBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
<clientCredentials>
<serviceCertificate>
<authentication certificateValidationMode="Custom" customCertificateValidatorType="HCCM.Client.Common.Utils.KF509CertificateValidator, HCCM.Client.Common"/>
</serviceCertificate>
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
at System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead)
InnerException: System.Net.Sockets.SocketException
Message=远程主机强迫关闭了一个现有的连接。
Source=System
ErrorCode=10054
NativeErrorCode=10054
StackTrace:
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
InnerException:
[最优解释]
http://www.cnblogs.com/shenba/
[其他解释]
自己解决了。。3Q