MyNameIsLinuxx
MyNameIsLinuxx

Reputation: 73

PowerShell New-WebServiceProxy doesn't fetch all methods

Im coding a PS script to check the state of a windows service and want to call a specific web service method in certain cases:

$wsdl = "https://webservice-page/wsdl.php?user"
$webserviceUser = "user"
$webservicePassword = "password"
$userId = 1337

$credential = [System.Management.Automation.PSCredential]::new($webserviceUser, (ConvertTo-SecureString $webservicePassword -AsPlainText -Force))

$serviceName = "defragsvc"

$service = Get-Service | Where-Object { $_.Name -eq $serviceName }

write-host "Service Status is" $service.status

 if ($service.status -eq "Stopped")
 {
    $warning = "Service inactive - user with ID " + $userId + " gets notified"
    Write-Warning $warning

    $client = New-WebServiceProxy -Uri $wsdl -Credential $credential

    $output = $client.authenticate($wsdl, $webserviceUser, $webservicePassword)

    echo $output
 }

 if ($service.status -eq "Running")
 {
    echo "OK"
 }

When i fire the script PS throws an error saying the client contains no "authenticte" method, and in fact the IntelliSense doesn't show me all of the existing methods, only a few and they seem randomly selected because i can't see any technical difference in the definition.

Also for every shown method, the IntelliSense duplicates them with "Begin" and "End" at the beginning (see picture) enter image description here

Soo.. I am very much confused by now.. anyone ever had these kind of problem? Or maybe provide a workaround idea.

I can confirm that the webservices do work fine using PHP SoapClient and __soapCall methods. These scripts are used every day, almost every minute.

Upvotes: 1

Views: 428

Answers (1)

Josto
Josto

Reputation: 243

Late answer with no doubt, but maybe can help to someone...

The proxy object is created from the WSDL and, in my case, the WSDL was not updated (some methods were available on Web Service but not declared on WSDL). Other clients had access to the methods because in these cases the proxy was a persistent object and was created when the WSDL was correct (seems that someone put an "older" WSDL there in recent times). I was able to extract an updated wsdl from the other clients and provide as file to New-WebServiceProxy

Upvotes: 0

Related Questions