У меня запущена служба WCF, использующая аутентификацию UserNameOverTransport.Это конфигурация в web.config
:
<service name="ReportService" behaviorConfiguration="ReportServiceBehaviors">
<endpoint address="UsernameMixed" binding="customBinding" bindingConfiguration="BasicHttpBinding_ReportService_UsernameMixed" contract="IReportService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
со следующей привязкой и поведением:
<customBinding>
<binding name="BasicHttpBinding_ReportService_UsernameMixed">
<security authenticationMode="UserNameOverTransport" allowInsecureTransport="false" />
<textMessageEncoding messageVersion="Soap11" writeEncoding="utf-8" />
<httpTransport transferMode="Buffered" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" />
</binding>
</customBinding>
<serviceBehaviors>
<behavior name="ReportServiceBehaviors">
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<!-- Enable WIF-Configuration -->
<serviceCredentials useIdentityConfiguration="true" />
<serviceAuthorization principalPermissionMode="Always" />
</behavior>
</serviceBehaviors>
Я пытаюсь вызвать службу в сценарии Powershell:
$uri = 'https://myserver/ReportService?wsdl'
$password = ConvertTo-SecureString "s3cr3t" -AsPlainText -Force
$credentials = New-Object System.Management.Automation.PSCredential ("foobar", $password)
$proxy = New-WebServiceProxy -Uri $uri -Credential $credentials -Namespace PsReportService
$model = New-Object PsReportService.UserReportModel
$result = $proxy.GetUserReport($model)
Я получаю следующее сообщение об ошибке:
Ausnahme beim Aufrufen von "GetUserReport" mit 1 Argument(en): "An error occurred when verifying security for the message."
In Zeile:6 Zeichen:1
+ $result = $proxy.GetUserReport($model)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : SoapHeaderException
Обновление Исправлены некоторые опечатки (спасибо @rAJ)