Connecting a WebService through a workflow RRS feed

  • Question

  • Hi All,

    I created a custom workflow that executes a PowerShell script to query a WebService.

    This script perfectly manually run as the workflow account. I mean: if I open a PS prompt as the workflow account and then I execute the script, the connection is made without any problem. This doesn't happen if the script is run during the execution of the workflow and I suppose that there's some issue related to the credentials.

    Here's what I did:

    1) First of all I used the "Export-PSCredential" function found at: http://halr9000.com/article/531 to create an XML file that stores the secured password of the workflow account. The function has been executed as the workflow account, so that the account itself created the XML file

    2) The script code is this


    $Password_path = "C:\WFAccount_ReadWrite\cred.xml"
    $import = Import-Clixml $Password_path
    $Username = $import.Username
    $SecurePass = $import.EncryptedPassword | ConvertTo-SecureString
    $Credential = New-Object System.Management.Automation.PSCredential $Username, $SecurePass
    $URIValue = "http://my.iis.server/WServices/MyTestWService.svc?wsdl" 
    $WebPortal = New-WebServiceProxy -uri $URIValue -Credential $Credential

    When executed during the WF, the script fails at the last two lines


    Thanks for any help!

    • Edited by Aktarus076 Friday, November 25, 2011 3:23 PM
    Friday, November 25, 2011 3:14 PM

All replies

  • Use try-catch block and save error message to file.
    http://www.scsmsolutions.com/ freemanru (at) gmail (dot) com
    Monday, November 28, 2011 7:27 AM
  • Well...After having captured some network trace I realised that the workflow execution doesn't execute the HTTP POST command to call the method "enableUser()", but just only the first part of the network communication: 3-way handshake and the HTTP GET command to retrieve the WDSL.

    This sounds a little bit strange to me...Why everything is fine only when manually executed? Is there some particular locking or restriction in terms of networking execution during a powershell script launch in a workflow?? :(

    Monday, November 28, 2011 8:08 PM