However, I read many articles to avoid "web service task" which I can understand the reasons because I did try a different web service and the "web service task" did not work.
So regardless, I would like to get a "script task" to work with the above web service link. I was able to import it as a "Service Reference" url but I am having trouble with the code to get the current time. It keeps error out with the line where it starts with "MyTest"
Also beside SSIS, can I use a SP to run the above web service?
// TODO: Add your code here
ServiceReference1.SampleWebServiceSoapClient MyTest = null;
MyTest = new ServiceReference1.SampleWebServiceSoapClient();
try
{
var result = MyTest.GetCurrentTime();
MessageBox.Show(MyTest.ToString(), "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
Dts.TaskResult = (int)ScriptResults.Success;
}
catch (Exception ex)
{
Dts.TaskResult = (int)ScriptResults.Failure;
}
what are you attempting to as end goal. is this real world scenario or just learning?
so in the real world scenario, are you trying to fetch some data from a remote url or is it internal?
A little bit more info on the error if anyone understands this:
System.InvalidOperationException: Could not find default endpoint element that references contract 'ServiceReference1.SampleWebServiceSoap' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.
at System.ServiceModel.Description.ConfigLoader.LoadChannelBehaviors(ServiceEndpoint serviceEndpoint, String configurationName)
at System.ServiceModel.ChannelFactory.ApplyConfiguration(String configurationName, Configuration configuration)
at System.ServiceModel.ChannelFactory.ApplyConfiguration(String configurationName)
at System.ServiceModel.ChannelFactory.InitializeEndpoint(String configurationName, EndpointAddress address)
at System.ServiceModel.ChannelFactory`1..ctor(String endpointConfigurationName, EndpointAddress remoteAddress)
at System.ServiceModel.ConfigurationEndpointTrait`1.CreateSimplexFactory()
at System.ServiceModel.ConfigurationEndpointTrait`1.CreateChannelFactory()
at System.ServiceModel.ClientBase`1.CreateChannelFactoryRef(EndpointTrait`1 endpointTrait)
at System.ServiceModel.ClientBase`1.InitializeChannelFactoryRef()
at System.ServiceModel.ClientBase`1..ctor()
at ST_bccd099323eb446e96e0e320c739aef1.ScriptMain.Main()