是否有某種方法可以使用PowerShell連接到具有消息級用戶憑證的Web服務。PowerShell WCF消息級用戶憑證
我有一個與我連接指定的憑據如下C#程序的偉大工程,一個測試Web服務:
DEVService.ServerLinkClient webService = new DEVService.ServerLinkClient("ServerLinkEndPoint");
webService.ClientCredentials.UserName.UserName = "*****";
webService.ClientCredentials.UserName.Password = ""*****";
Web服務的配置如下:
<bindings>
<basicHttpBinding>
<binding name="ServerLinkBinding" maxBufferSize="2097152" maxReceivedMessageSize="2097152"
maxBufferPoolSize="2097152" sendTimeout="00:02:00" receiveTimeout="00:02:00">
<security mode="TransportWithMessageCredential">
<message clientCredentialType="UserName" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="APOServiceLibrary.ServerLink"
behaviorConfiguration="SecureBehaviourServerLink">
<endpoint name="ServerLinkEndPoint"
address=""
binding="basicHttpBinding"
bindingConfiguration="ServerLinkBinding"
contract="APOServiceLibrary.IServerLink">
</endpoint>
<endpoint address="mexServerLink"
binding="mexHttpsBinding"
contract="IMetadataExchange">
</endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="SecureBehaviourServerLink">
<serviceMetadata httpsGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="False"/>
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom"
customUserNamePasswordValidatorType="APOServiceLibrary.ConnectionSecurityServerLink, APOServiceLibrary"/>
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
我已經使用PowerShell連接到一個簡單的Web服務,但該服務已設置爲使用Windows身份驗證。在這種情況下,傳輸層只是基本安全的,並且消息正在等待某個用戶名和密碼。
這是我想要使用來從Web服務的數據集的腳本:
#setup the credentials to connect
$securePasswd = ConvertTo-SecureString "*******" -AsPlainText -Force
$tempCredentials = New-Object System.Management.Automation.PSCredential (""*******" ", $securePasswd)
# Connect to the web services
$web_serv = New-WebServiceProxy -uri https://127.0.0.1/ServerLink.svc -Credential $tempCredentials
# get some data
$test_data = New-Object System.Data.DataSet
$test_data = $web_serv.getDataSet()
然而,當我嘗試使用憑據連接並嘗試運行一個命令,我得到以下錯誤:
Exception calling "getDataSet" with "0" argument(s): "An error occurred when verifying security for the message."
任何幫助將是真棒!
甚至要知道是否有可能將某種消息級別的用戶名和密碼放入PowerShell連接將會很好!