locked
consume web service in Asp.net MVC RRS feed

  • Question

  • I have a problem when calling web Services in ASP.net MVC , I do the following

    add the web service by add service reference to solution, and I include the service.cs file to the solution also, but when I try to create object in home controller , I have the following error

    Could not find default endpoint element that references contract 'Service' 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.

    can any one help me please

    thanks

    • Moved by Jason Dot Wang Wednesday, April 24, 2013 6:20 AM This thread is about ASP.NET
    Tuesday, April 23, 2013 2:39 AM

Answers

  • Hi Rana_Husni,

      Welcome to MSDN Forum Support.

      You are more likely to get more efficient responses to ASP.NET issues at http://forums.asp.net where you can contact ASP.NET experts.


    Jason Wang [MSFT]
    MSDN Community Support | Feedback to us

    • Proposed as answer by Just Karl Wednesday, January 15, 2014 3:32 PM
    • Marked as answer by Just Karl Thursday, January 23, 2014 11:02 PM
    Wednesday, April 24, 2013 6:20 AM

All replies

  • On 4/22/2013 10:39 PM, Rana_Husni wrote:

    I have a problem when calling web Services in ASP.net MVC , I do the following

    add the web service by add service reference to solution, and I include the service.cs file to the solution also, but when I try to create object in home controller , I have the following error

    Could not find default endpoint element that references contract 'Service' 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.

    can any one help me please

    I'll assume this is a WCF Web service, since you are mentioning end-points. You need to make that distinction, because there is a legacy Web service signified by an ASMX, and then there is a WCF Web service signified by a SVC.

    And what are you talking about in regards to you added the "srvice.cs" file to the solution?

    And what's in the Web.config for the client, and what is in the Web.config for the service, show the code.

    Tuesday, April 23, 2013 3:29 AM
  • Hi,

    Have you added web reference to your client project? If you have added it correctly then your service should be visible under references. It should look something like this. Look at the image below.

    Once you have added your service you can reference it like :

    mylittleService.Service myServiceobj = new WebserviceConsumer.mylittleService.Service();
    myServiceobj .MyHelloWorld("Hi");

    Tuesday, April 23, 2013 3:40 AM
  • Thanks a lot for your response

    I tried to include image to my reply but I can't until admin verify my account I want to tell you what I did


    I run  svcutil.exe utility to generate the code files that will be later used in client consumer application., so I add MobileService.CS to the solution 

    I add the code found in output.config file in web.config ( I tried both files in solution and in view but the error still shown )

    So where is the problem

    Can you tell me please


    • Edited by RProgrammer Tuesday, April 23, 2013 7:18 PM
    Tuesday, April 23, 2013 3:14 PM
  • Thanks a lot for your response

    I tried to include image to my reply but I can't until admin verify my account I want to tell you what I did


    I run  svcutil.exe utility to generate the code files that will be later used in client consumer application., so I add MobileService.CS to the solution 

    I add the code found in output.config file in web.config ( I tried both files in solution and in view but the error still shown )

    So where is the problem

    Can you tell me please


    • Edited by RProgrammer Tuesday, April 23, 2013 7:18 PM
    Tuesday, April 23, 2013 3:15 PM
  • Hi Rana,

    did you include the endpoint definitions from the config file to the web.config of your client application ? Can you try that.


    Tuesday, April 23, 2013 5:42 PM
  • yes I tried , I tried in both files web.config the belong to the solution and web.config that under view 

    so where is the problem?

    Tuesday, April 23, 2013 7:41 PM
  • Please post ASP.NET questions in the ASP.NET forums (http://forums.asp.net).  Thanks.
    Tuesday, April 23, 2013 10:29 PM
  • I posted my question and I wait reply, thank you very much
    Wednesday, April 24, 2013 1:27 AM
  • this is the image of my solution 
    Wednesday, April 24, 2013 3:08 AM
  • Hi Rana,

    Try this link Explains How to Consume Services

    Thanks


    Arjun

    Wednesday, April 24, 2013 5:06 AM
  • Hi Rana_Husni,

      Welcome to MSDN Forum Support.

      You are more likely to get more efficient responses to ASP.NET issues at http://forums.asp.net where you can contact ASP.NET experts.


    Jason Wang [MSFT]
    MSDN Community Support | Feedback to us

    • Proposed as answer by Just Karl Wednesday, January 15, 2014 3:32 PM
    • Marked as answer by Just Karl Thursday, January 23, 2014 11:02 PM
    Wednesday, April 24, 2013 6:20 AM
  • Hello,

    Specifically, this should be asked in the ASP.Net MVC forum on forums.asp.net.

    Karl


    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer.
    My Blog: Unlock PowerShell
    My Book: Windows PowerShell 2.0 Bible
    My E-mail: -join ('6F6C646B61726C40686F746D61696C2E636F6D'-split'(?<=\G.{2})'|%{if($_){[char][int]"0x$_"}})

    Wednesday, January 15, 2014 3:34 PM