none
Problem while calling WCF Service from WindowsService. RRS feed

  • Question

  • Hi friends .......
     
    i am getting a problem while calling a method on WCF service.
    Some time this method is running properly.
    but some time it shows following exception:-
     

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

     

    In this UpdationWebService is web service name (WCF).
     
    I am not getting why it is throwing this exception,........
    sometimes it is running properly...
    , sometime it is causing Problem...
     
    please help me ......., it's urgent
    • Moved by Lisa Zhu Tuesday, December 11, 2012 1:55 AM wcf related (From:Visual C# General)
    Friday, December 7, 2012 12:03 PM

Answers

  • Hi thanks to all for their valuable replies..


      Every one suggestions, To check appconfig. was good. I checked but still it was showing same problem.  I solved it by providing Binding to httpBinding and endPointAddress to my ServiceRefrence

     as follows

      BasicHttpBinding binding = new BasicHttpBinding();
                    EndpointAddress endPointAddress = new EndpointAddress("http://LocalHos/Service1.svc");

    ServiceClient  sv = new ServiceClient(binding ,endPointAddress );

    • Marked as answer by Rai007 Tuesday, December 11, 2012 6:48 AM
    Tuesday, December 11, 2012 6:48 AM

All replies

  • Check the event log for the server hosting the wcf service to make sure there is nothing causing the web site to crash which hosts the wcf service.  I would also check the setting for the wcf service making sure it can send all the data back that was requested.  If the data is too large you will get an exception
    Saturday, December 8, 2012 7:53 PM
  • I guess the window service can not read the WCF configuration information properly which is recorded in the <system.serviceModel> section of app.config file.

    You can check this.

    Sunday, December 9, 2012 9:16 AM
  • Hi,

    Could you share your code snippets (client side calling part).


    Thanks
    Md. Marufuzzaman


    Don't forget to click [Vote] / [Good Answer] on the post(s) that helped you.
    I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.

    Sunday, December 9, 2012 12:51 PM
  • You don't say whether or not you're catching exceptions in your Windows Service, but you should. Use a try/catch when you call the WCF service if you're not already. One of the things you could do is retry calling the WCF service, after waiting a period of time. Of course, it does depend on what's causing the problem ... @Ken's suggestion to check the event log where the WCF service is hosted is a good idea.

    ~~Bonnie Berent DeWitt [C# MVP]

    geek-goddess-bonnie.blogspot.com

    Sunday, December 9, 2012 5:52 PM
    Moderator
  • Check the <client> section of your windows service's configuration file. Make sure there is a client endpoint pointing at your WCF service where the contract value is set to UpdationWebService.IService1.

    e.g.

    <endpoint address="http://localhost/UpdationWebService"

    binding="basicHttpBinding"

    contract="UpdationWebService.IService1" />


    Monday, December 10, 2012 12:05 PM
  • Hi Rai,

    Please check have you configure the endpoint in the client side. In your case if windows service is a client which consuming the WCF service call, then set the endpoint information in "App.config" file of windows service.

    For more info

    http://msdn.microsoft.com/en-us/library/windows/desktop/bb756928.aspx

    Hope this solve your issue.



    Thanks in Advance Suresh M
    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful"

    Monday, December 10, 2012 12:57 PM
  • Hi Rai007,

    From your description, I ‘d like to move this post to  the most related forum.

    There are more  experts in this aspect, so you will get  better support and  may have more luck getting answers.

    Thanks for your understanding.

    Regards,


    Lisa Zhu [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, December 11, 2012 1:55 AM
  • Hi thanks to all for their valuable replies..


      Every one suggestions, To check appconfig. was good. I checked but still it was showing same problem.  I solved it by providing Binding to httpBinding and endPointAddress to my ServiceRefrence

     as follows

      BasicHttpBinding binding = new BasicHttpBinding();
                    EndpointAddress endPointAddress = new EndpointAddress("http://LocalHos/Service1.svc");

    ServiceClient  sv = new ServiceClient(binding ,endPointAddress );

    • Marked as answer by Rai007 Tuesday, December 11, 2012 6:48 AM
    Tuesday, December 11, 2012 6:48 AM
  • I'm glad you solved your problem, but I don't understand why this was an intermittent issue? You said sometimes it worked and sometimes it didn't. If you didn't have the correct configuration how could it have worked sometimes?


    ~~Bonnie Berent DeWitt [C# MVP]

    geek-goddess-bonnie.blogspot.com

    Tuesday, December 11, 2012 3:20 PM
    Moderator