How to call sqap web services from C# RRS feed

  • Question

  • Hi all,

    I have create a simple prject in visual studio, then I have import new service reference from WSDL.

    Now I must call the ws from that WSDL but I'm not able to do this.

    Can we help me?

    Friday, June 12, 2015 2:24 PM


  • If your project has a service reference in it then code was generated to wrap the call.  You'll find a namespace in your project's default namespace that contains a class that backs the service.  You'll create an instance of the class and then call methods like you would any other class except that you'll want to wrap the instance in a using statement.

    For example assume that your project happens to be called ConsoleApplication1 hence that is the default namespace for the project.  You then add a service reference pointing to http://localhost/Myservice/MyService.svc.  In the Add Service Reference dialog the Namespace field will default to something like ServiceReference1 (but you can change it).  The IDE will generate a class (suffixed with Client) to back the service itself inside the namespace given earlier.  When using the class you'll prefix it with the namespace name (or simply add a using declaration).  In any event you'll need to wrap the object in a using statement so it gets cleaned up when you're done with it.

    using (var client = new ServiceReference1.MyServiceClient()) 

    Michael Taylor

    Friday, June 12, 2015 3:22 PM