locked
How to access an asmx web service in my code? RRS feed

  • Question

  • User-823196590 posted

    I have an asmx web service that I have setup in my web project in VS as Add Service Reference -> Advanced -> Add Web Reference, and then I added a "using mysvc;" reference to my C# code.  When I am writing the code and want to call a webmethod from the asmx, I thought I would be able to code it as "mysvc.somemethod()", but I am only getting .WebServiceSoap, .WebServiceSoapClient, and .WebServiceSoapChannel as options from intellisense.

    What am I doing wrong or misunderstanding?  Is there a good tutorial or reference someone can point me to?

    Thursday, July 25, 2013 4:47 PM

Answers

  • User-2001332922 posted

    He is right with just an edit. that is do like

    mysvc websvc = new mysvc();

    websvc.somemethod();

    The intellisense is showing the reference that a web reference exists in project i presume that.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 26, 2013 1:29 AM

All replies

  • User177399542 posted

    First of all you have to create an object of WebServiceSoapClient after then you would able to call methods.

    WebServiceSoapClient obj =new WebServiceSoapClient ();
    var result=obj.MethodName(); 




    Friday, July 26, 2013 12:11 AM
  • User-2001332922 posted

    He is right with just an edit. that is do like

    mysvc websvc = new mysvc();

    websvc.somemethod();

    The intellisense is showing the reference that a web reference exists in project i presume that.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 26, 2013 1:29 AM
  • User-823196590 posted

    Yes, that's it!  Thanks.

    Friday, July 26, 2013 9:27 AM