I have two script tasks that reference a webservice. Both the script tasks are referncing to the same webservice. Once I have created the instance of the webservice and established my connection , i want to pass the same instance to the next script task as I need to make another webservice call.
To achieve that in my first task , I do the following
- Create a package level variable IPSService of the type object
- Create a webservice reference
- Add the using statement that is using ST_d4beade8c14e45c3af4e582df4c22c89.csproj.uk.co.iress.webservices; (Got the reference from the object browser)
- Create in the instance of the service in the script task
- Assign the object to Dts.Variables["User::IPSService"].Value = iPSService;
- Set the ReadWrite variables in the script properties to User::IPSService.
In Second script task , I do the following
- Set the readonly variable property of the script task to User::IPSService
- Create a webservice reference
- Add the using statement that is using ST_d4beade8c14e45c3af4e582df4c22c89.csproj.uk.co.iress.webservices; (Got the reference from the object browser)
- In the main method , IPSService iPSService1 = (IPSService)Dts.Variables["User::IPSService"].Value;
However when i run the tasks , I get the following error
Error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidCastException: Unable to cast object of type 'ST_d4beade8c14e45c3af4e582df4c22c89.csproj.uk.co.iress.webservices.IPSService' to type 'ST_d4beade8c14e45c3af4e582df4c22c89.csproj.uk.co.iress.webservices.IPSService'. at ST_d4beade8c14e45c3af4e582df4c22c89.csproj.ScriptMain.Main()
I just did a small change to avoid passing the object and recreate the object in the second script method but i get a new error Error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Web.Services.Protocols.SoapException: Invalid SDO Topic TD_ERROR.
Can anybody tell me what the problem is