0 Replies Latest reply on Nov 23, 2016 10:10 AM by Jean-Marc Emond

    Use Powershell for SOAP calls to BSA

    Jean-Marc Emond

      Hi,

       

      Has anyone used powershell to make SOAP calls to BSA 8.7?

       

      I've written some code for the authentication piece that works but when I try to load the RestRequestService WSDL powershell is producing the following error:

      *** START of ERROR *****

      New-WebServiceProxy : Exception has been thrown by the target of an invocation.

      At line:1 char:10

      + $proxy = New-WebServiceProxy -Uri C:\wsdl\RESTRequestService_1.wsdl - ...

      +          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

          + CategoryInfo          : NotSpecified: (:) [New-WebServiceProxy], TargetInvocationException

          + FullyQualifiedErrorId : System.Reflection.TargetInvocationException,Microsoft.PowerShell.Commands.NewWebServiceP

         roxy

       

      **** End of ERROR *****

       

      *** Powershell Code ****

       

      #/// Start of Code….

      [System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}

      $UserName ="ENTER_USERNAME@domain.local"

      $Password="ENTER_PASSWORD"

      $BSARole = "BLAdmins"

      $AuthType = "ADK_PASSWORD"

      [string]$sessionID = ""

       

      #*****  Working Login Service******

      $url = "https://APPSERVER.LOCAL:9843/services/LoginService?wsdl"

      $Proxy = New-WebServiceProxy -Uri $url -Namespace WebServiceProxy -Class Authentication

      $LoginResponse = $Proxy.loginUsingUserCredential($username, $password, $AuthType,[ref]$sessionID)

      ### I now have a sessionID and can pass this to the getXML header as part of the REST Request Service.

      #*****  End of Login Service ****

       

      #///  Code to access SOAP Rest services

      $url = "https://APPSERVER.LOCAL/services/RESTRequestService?wsdl"

      $Proxy = New-WebServiceProxy -Uri $url

      #/// End of code that doesn’t work….

       

       

      I would or rather used RESTful webservices and not used WSDL files at all but I couldn't find a way to not include the username and password as part of the URL.  I realize that the parameters as part of the URL would be encrypted but it's not good security practice to do that. 

       

      If I use SOAP UI, it works fine.

       

      Thanks