Reputation: 98
I've been hitting my head against the desk for days with this.
I have to make a soap call using Powershell as i am getting info from Active Directory.
Making the call is not an issue and I hit a mock service with no issue, the issue lies when I hit the real endpoint and it expects a WSSE security header...
I'm using
$wsproxy = New-WebServiceProxy -Uri $wsdl
I can find no way to set a header i have tried setting the Credentials individually but it does nothing
$wsproxy.Credentials.Username = "Username"
$wsproxy.Credentials.Password = "password"
They want the format to be
<soapenv:Header>
<wsse:Security xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:wsse="http://docs.oasisopen.xmlns:wsu="http://docs.oasisopen.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
soapenv:mustUnderstand="0">
<wsse:UsernameToken>
<wsse:Username>[user@domain.com]</wsse:Username>
<wsse:Password>[password]</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
Also tried
$cred = New-Object System.Management.Automation.PSCredential -ArgumentList @($username,(ConvertTo-SecureString -String $password -AsPlainText -Force))
$wsproxy.Credentials = [System.Net.NetworkCredential]::($username, (ConvertTo-SecureString $password -AsPlainText -force))
Upvotes: 1
Views: 887