Advertisement
Guest User

SOAP Request

a guest
May 30th, 2018
363
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $CUCM = "CUCM_SERVER_URL"
  2. $WSDLPath = "PATH_TO_WSDL_FILE\AXLAPI.wsdl"
  3.  
  4. #
  5. $username = Read-Host "Username for CUCM"
  6. $password = Read-Host "Password for CUCM"  -AsSecureString #| ConvertTo-SecureString -AsPlainText
  7.  
  8. #This creates the translation from a secure string object in Powershell, to plain text for CUCM to authenticate the user.
  9. $password = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($password))
  10.  
  11. $phoneToEdit = Read-Host "What phone would you like to update? Please enter its MAC Address now"
  12. # This is where your AXL request goes
  13.  
  14. $AXL = New-WebServiceProxy -Uri $WSDLPath -Credential $username, $password
  15. $request = @"
  16. <?xml version="1.0" encoding="UTF-8"?>
  17. <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.cisco.com/AXL/API/10.0">
  18.   <soapenv:Header/>
  19.   <soapenv:Body>
  20.      <ns:getPhone sequence="?">
  21.         <name>$phoneToEdit</name>
  22.      </ns:getPhone>
  23.   </soapenv:Body>
  24. </soapenv:Envelope>
  25. "@
  26. # Required to ignore some HTTP errors
  27. [System.Net.ServicePointManager]::Expect100Continue = $false
  28.  
  29. #Authorization for HTTP
  30. $header = @{"Authorization" = "Basic " + [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($username + ":" + $password))}
  31. # Reset $result in case Invoke-WebRequest errors
  32. $result = $null
  33.  
  34.  
  35. $result = Invoke-webRequest -Uri "https://$CUCM`:8443/axl/" -Headers $header -Method 'POST' -Body $request -ContentType "text\xml" -UseBasicParsing
  36.  
  37. # Output result
  38. $result.Envelope.Body.getPhoneResponse.return.phone | Out-GridView
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement