简体   繁体   中英

Process not working when called from a web service VB.NET

I'm writing a program that moves docs from one app to another in ApplicationXtender (AX). The AX full-featured client already has such a program (Migration Wizard) that can handle the task, so I created a function that launches it using Process.Start() and supplying the arguments necessary to automate it. When I call the function from a console app or windows form app, the Migration Wizard works perfectly. But the process must be initiated by an event in a web-based workflow project, so I wrote a web service that contains the same function, and then I use an invoke web service control in the workflow to start it. When I consume the function from the web service, the process doesn't complete. I can see it hanging in the task manager. I'm pretty sure it has to do with the user settings in IIS, but I'm not familiar enough with IIS to make any significant difference. I've configured the anonymous authentication's user identity in IIS to launch with a specific user with full rights to AX, and set the DefaultAppPool to run as Local System, but neither worked. I'm thinking I may need to impersonate the user, but I don't know how to do that. Any suggestions?

For reference, here is my code:

Consume Service Code-

Sub Main()

    Dim dbName As String
    Dim appName As String
    Dim preSalesNum As String

    Console.WriteLine("Database: ")
    dbName = Console.ReadLine
    Console.WriteLine("")

    Console.WriteLine("Application")
    appName = Console.ReadLine
    Console.WriteLine("")

    Console.WriteLine("Pre-Sales Number:")
    preSalesNum = Console.ReadLine
    Console.WriteLine("")

    MoveDocs.MoveDocs(dbName, appName, preSalesNum)

End Sub

MoveDocs Function (inside of a separate class)-

Public Shared Function MoveDocs(ByVal dbName As String, ByVal appName As String,
  ByVal preSalesNum As String) As String

    Try
        Dim sourceApp As String

        If appName = "PRE_SALES_PROJECTS" Then
            sourceApp = "PROJECTS"
        Else
            sourceApp = "LOOSE-FURNITURE"
        End If

        Dim argsString As String = "/SD " & dbName & " /SU username /SP password /SA 
          " & appName & " /DD " & dbName & " /DU username /DP password /DA " &  
          sourceApp & " /S " & """" & preSalesNum & """" & " /A"

        Dim procProp As New System.Diagnostics.ProcessStartInfo
        With procProp
            .FileName = "C:\Program Files (x86)\XtenderSolutions\Content
            Management\MigrateWiz32.exe"
            .Arguments = argsString
        End With

        Dim proc As System.Diagnostics.Process = 
          System.Diagnostics.Process.Start(procProp)

        Return argsString

    Catch ex As Exception
        Return ex.ToString()
    End Try

End Function

The MoveDocs() function in the service.asmx file is identical to the one above, minus the 'shared' modifier in the declaration. The app works, the web service doesn't.

ProcessStartInfo has properties for username, password and domain. There's more info on MSDN - http://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.password.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM