Using Windows PowerShell with Client Certificates
When using client certificates additional steps must be taken due to a limitation in the New-WebServiceProxy cmdlet which does not support client certificates.
- Open the XIA Configuration Server web service that you are trying to access - for example
http://localhost/xiaconfiguration/webservice/xiaconfiguration.asmx - Right click the service description link, and click save link as
- Save the WSDL document to a location accessible to the script - for example "C:\WebService\XiaConfiguration.wsdl"
- Use the following in a PowerShell script or the PowerShell Integrated Scripting Environment (ISE), replacing the highlighted text with appropriate values
Clear-Host
$xia = New-WebServiceProxy "file://C:\WebService\filename.wsdl"
$certificate = Get-ChildItem Cert:\CurrentUser\My\{THUMBPRINT}
$xia.ClientCertificates.Add($certificate)
$xia.UseDefaultCredentials = $true
$xia.Url = {URL}
Write-Host $xia.GET_AuthenticatedUserName()
NOTE: When XIA Configuration Server is upgraded the steps to generate the WSDL file must be repeated.
NOTE: The client certificate can be installed in the local machine certificate store and the script updated accordingly.