locked
how to make use of Service Reference generated in public interface in c# RRS feed

  • Question

  • User280098508 posted

    I add a soap api as service reference in vs 2012.It'll auto-generate Reference.cs like below

    namespace EnterpriseSoftware.abcWebService {
    
     public interface Some_Api{
         //list of generated method
    } }

    In order to make use of code from service reference.I think I have to create an instence of the class then call the methods.

    I've try fews ways to create instence,but fail to do so....

    I not used to calling methods of "public interface"

    I try these,but fail. anyone help? Thank

    EnterpriseSoftware.abcWebService.Some_api obj = new EnterpriseSoftware.abcWebService.Some_api();
    using EnterpriseSoftware.abcWebService;

    namespace EnterpriseSoftware{
    public class comeclassName{
    Some_api obj = new Some_api();
    }
    }

    Tuesday, February 25, 2014 2:59 AM

Answers

  • User-1454326058 posted

    Hi willie,

    Thanks for your post!

    The interface contains only the signatures of methods, properties, events or indexers. A class or struct that implements the interface must implement the members of the interface that are specified in the definition. So, the interface cannot be instanced directly. We should instance the class or struct that implements the interface.

    So for your requirement, you should to know which classes/structs implement that interface and instance them.

    Thanks

    Best Regards  

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, February 26, 2014 12:49 AM