SQLTeam.com | Weblogs | Forums

Web Services (Script Task and Stored Procedure)


#1

I was successful in testing this web service using a "web service task".

http://secure.smartbearsoftware.com/samples/testcomplete14/webservices/Service.asmx
http://secure.smartbearsoftware.com/samples/testcomplete14/webservices/Service.asmx?WSDL

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;
        }

#2

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?


#3

This is a learning attempt to get a real world scenario to work. Will try to connect to a remote URL just like the above.

I am trying to get and set data into a table/flat file.


#4

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()

#5

Still stuck on this and really need help on this.

I am only stuck on the C# part for the Script Task. Someone one here must of have done this before.

Anyway, back to this and if I find the breakthrough, will post back on here for others.


#6

I would recommend you ask on a .c# forum as this is not a SQL issue