SOAP(y) Powershell fun w/ BT Diamond's IPAM (Part 1)

PreReq:
  1. API Access
  2. Powershell 2.0 +
    1. I'm using 3.0 now.  I assume these examples work in 2.0 as well, but I'm too lazy to test.
This was a bit of an interesting exercise for me since I've mostly only ever used cmdlets.  I'm still using cmdlets, but calling SOAP based web services to gather information.

Here is what I've been experimenting with:
#Credentials are needed when working w/ a secure web service.
$Creds = Get-Credential

#I was able to find the correct API address by clicking the help link on the login page.  They seem to have a different web service per API instruction type.  In this case, I just want to 'get' address information thusly demonstrated below.
$IPControlGetService = New-WebServiceProxy "https://myIPControlServerNameorIP/inc-ws/services/Gets?wsdl" -Credential $creds

#This is where it gets interesting, from here I can essentially browse what properties and methods are available to me by calling the $IPControlGetService variable.
#This provides me a list of properties and methods I can call against this SOAP service.
$IPControlGetService | get-member

Roadblocks:
The downside, I was unable to successfully receive a valid xml response from IPControl that Powershell's New-WebServiceProxy cmdlet liked.  Error:
Exception calling "getDeviceByHostname" with "1" argument(s): "There is an error in XML document (1, 2947)."

Long story short, it appears to be related to the xml return 'style' being 'RPC' rather than 'Document', but I cannot say for certain.  I only noticed this while using SOAPUI to see the returned xml and noticing the 'style' property compared to that of Dell's web service.

To be continued in Part 2...Using SOAPUI and Powershell's Invoke-WebRequest cmdlet...

No comments: