Search code examples
wixcustom-actionwix3.5

Calling a web service from WIX


Hi I need to be able to call a web service from a WIX installer and I'm having a few issues.

I realise I need to add a custom action which will communicate with the service:

 [CustomAction]
    public static ActionResult Activate(Session session)
    {
        ActionResult result = ActionResult.Success;
        try
        {
            session.Log("Begin Activate");

            Debugger.Launch();

            //session["ACTIVATIONSERVICEURL"] = "http://localhost/ActivationService/V1/ActivationService.svc";
            //session["ACTIVATIONUSERNAME"] = "james";
            //session["ACTIVATIONPASSWORD"] = "Password123";

            //string endpoint = session["ACTIVATIONSERVICEURL"];
            //string username = session["ACTIVATIONUSERNAME"];
            //string password = session["ACTIVATIONPASSWORD"];

            //using (ActivationServiceClient client = new ActivationServiceClient("ASC", endpoint))
            //{
            //    client.ClientCredentials.UserName.UserName = username;
            //    client.ClientCredentials.UserName.Password = password;

            //    Guid userToken = client.Activate();
            //    session["USERTOKEN"] = userToken.ToString();
            //}

            session.Log("Finishing Activate");
        }
        catch (Exception ex)
        {
            session.Log("Exception caught: {0}", ex);
            result = ActionResult.Failure;
        }

        return result;
    }

I've managed to call this action but I'm having issues with a dialog "A DLL is required for this installation to complete". It looks to be calling the service under InstallFinalize.

 <!-- Custom action for calling remote web service-->
    <CustomAction Id="CallActivationService"
          BinaryKey="ActivationServiceCustomAction"
          DllEntry="Activate"
          Return="check" />

   <Binary Id="ActivationServiceCustomAction"
        SourceFile="$(var.SolutionDir)\Application\ExternalAssemblies\MyCompany.Application.ActivationService.CA.dll" />

<Custom Action="CallActivationService" Before="InstallFinalize">Not Installed OR Installed</Custom>

The log just returns value 3:

MSI (s) (54:D0) [12:26:29:726]: Doing action: CallActivationService
Action 12:26:29: CallActivationService. 
Action start 12:26:29: CallActivationService.
MSI (s) (54:D0) [12:26:29:726]: Creating MSIHANDLE (32) of type 790542 for thread 1232
MSI (s) (54:4C) [12:26:29:726]: Invoking remote custom action. DLL:     C:\WINDOWS\Installer\MSI1BE8.tmp, Entrypoint: Activate
MSI (s) (54:4C) [12:26:29:773]: Closing MSIHANDLE (32) of type 790542 for thread 1232
MSI (s) (54:D0) [12:26:29:773]: Note: 1: 1723 2: CallActivationService 3: Activate 4:     C:\WINDOWS\Installer\MSI1BE8.tmp 
Error 1723. There is a problem with this Windows Installer package. A DLL required for     this install to complete could not be run. Contact your support personnel or package vendor.     Action CallActivationService, entry: Activate, library: C:\WINDOWS\Installer\MSI1BE8.tmp 
MSI (s) (54:D0) [12:26:56:679]: Product: My AppClient Application -- Error 1723. There     is a problem with this Windows Installer package. A DLL required for this install to     complete could not be run. Contact your support personnel or package vendor. Action     CallActivationService, entry: Activate, library: C:\WINDOWS\Installer\MSI1BE8.tmp 
Action ended 12:26:56: CallActivationService. Return value 3.
Action ended 12:26:56: INSTALL. Return value 3.

Cheers, J


Solution

  • Figured it out. Issue was to do with using blocks around the proxy hiding the binding protocal exception the service was throwing (after other setup issues).