Пожалуйста, помогите с этой проблемой.Я получаю выше этого исключения - HTTP-запрос был запрещен со схемой аутентификации клиента «Аноним» при попытке доступа к сервису со стороны клиента.Я перепробовал все упомянутое на предыдущих форумах, и у меня все еще есть проблема.Я пытался реализовать службу WCF через https.
Служба WCF размещалась на IIS и
Я добавил сертификат в хранилище
На клиенте мы получаем сертификат и pwd от пользователя и присваиваем его в коде
Ниже приведены мои web.config и фрагменты кода клиента.-
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" >
<serviceActivations></serviceActivations>
</serviceHostingEnvironment>
<diagnostics>
<messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtServiceLevel="false"
logMessagesAtTransportLevel="true" maxSizeOfMessageToLog="50000000" />
<endToEndTracing activityTracing="true" messageFlowTracing="true" />
</diagnostics>
<services>
<!--This section is optional with the new configuration model
introduced in .NET Framework 4.-->
<service name="Oz.HL7.NIXPDQV3.NIXManager_PortTypeClient" behaviorConfiguration="NIX_Behavior_HTTPS">
<host>
<baseAddresses>
<add baseAddress="https://localhost:10787/" />
</baseAddresses>
</host>
<endpoint address="" binding="wsHttpBinding" contract="INIXManager_PortType" bindingConfiguration="WSHttpsBinding_INIXManager"
bindingNamespace="urn:ihe:iti:NIXv3:2007" />
<endpoint address="mex" binding="mexHttpsBinding" bindingConfiguration="mexHttpsBinding" name="mex" contract="IMetadataExchange" />
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="WSHttpsBinding_INIXManager" closeTimeout="00:10:00"
openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10: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:10:00"
enabled="false" />
<security mode="Transport">
<transport clientCredentialType="Certificate" />
</security>
</binding>
<binding name="WSHttpBinding_INIXManager" 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="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false"/>
<security mode="None">
<transport clientCredentialType="Windows" proxyCredentialType="None" realm="">
<extendedProtectionPolicy policyEnforcement="Never"/>
</transport>
<message clientCredentialType="Windows" negotiateServiceCredential="true" establishSecurityContext="true"/>
</security>
</binding>
</wsHttpBinding>
<mexHttpBinding>
<binding name="mexBinding" />
</mexHttpBinding>
<mexHttpsBinding>
<binding name="mexHttpsBinding" />
</mexHttpsBinding>
</bindings>
<client>
<!--<endpoint address="http://localhost:10787/NIXManager.svc" binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_INIXManager" contract="INIXManager_PortType"
name="NIXManager_Binding_HTTP" />-->
<endpoint address="https://localhost:10787/NIXManager.svc" binding="wsHttpBinding"
bindingConfiguration="WSHttpsBinding_INIXManager" contract="INIXManager_PortType"
name="NIXManager_Binding_HTTPS" />
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
<behaviors>
<serviceBehaviors>
<behavior name="NIX_Behavior_HTTP">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="false"/>
<serviceDebug httpHelpPageEnabled="true" includeExceptionDetailInFaults="true" />
</behavior>
<behavior name="NIX_Behavior_HTTPS">
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="true"/>
<serviceDebug httpHelpPageEnabled="false" includeExceptionDetailInFaults="true" />
</behavior>
<behavior name="NIX_Behavior_HTTPS-old">
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="true"/>
<serviceDebug httpHelpPageEnabled="false" includeExceptionDetailInFaults="true" />
<serviceCredentials>
<clientCertificate>
<authentication mapClientCertificateToWindowsAccount="true" />
</clientCertificate>
<serviceCertificate findValue="084509de9a36684453edaebbc52bfd26f504f065" storeLocation="LocalMachine" storeName="My" x509FindType="FindByThumbprint"/>
</serviceCredentials>
</behavior>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
Код клиентской стороны для вызова службы -
//wcf service proxy
NIXManager_PortTypeClient client;
//Get certificate details from the UI (setting)
AppSetting setting = settings.CurrentSetting;
bool IsSecure = setting.V3SettingsObject.Secure;
if (IsSecure)
{
client = new NIXManager_PortTypeClient("NIX_Binding_HTTPS");
X509Certificate2 certificate = new X509Certificate2(setting.V3SettingsObject.CertificatePath, setting.V3SettingsObject.CertificatePassword);
client.ClientCredentials.ClientCertificate.Certificate = certificate;
//Validate Certificate
System.Net.ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(ValidateServerCertificate);
}
else
{
client = new NIXManager_PortTypeClient("NIX_Binding_HTTP");
}
client.Endpoint.Address = new System.ServiceModel.EndpointAddress(setting.V3SettingsObject.URL);
Я боролся с этим уже несколько дней.Пожалуйста, дайте мне знать, что еще мне нужно сделать.Любой вид ввода будет принята с благодарностью.Спасибо!