none
Web Service - configuration file issue RRS feed

  • Question

  • Hi All,

    I setup a web service and wrote a class library to create new object for the webservice function: i.e.

     SapSer.WMSClient client = new SapSer.WMSClient("basicHTTP");

    But while execution the above line gives the following error:

    "Could not find endpoint element with name 'basicHTTP' and contract 'SapSer.WMS' 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 name could be found in the client element."

    But actually i have the app.config file in the same project.......

    Regard's


    M.Azeem

    Wednesday, June 7, 2017 5:57 AM

Answers

  • Hi M.Azeem,

    Has your issue been resolved?

    I agree with CoolDadTx that class library does not have config which causes your issue.

    If you want such a library which could be used in different projects, I would suggest you configure WCF Client in code instead of app.config.

    Here is a simple demo:

    //Specify the binding to be used for the client.
                BasicHttpBinding binding = new BasicHttpBinding();
    
                //Specify the address to be used for the client.
                EndpointAddress address = 
                   new EndpointAddress("http://localhost/servicemodelsamples/service.svc");
                
    
                // Create a client that is configured with this address and binding.
                CalculatorClient client = new CalculatorClient(binding, address);

    You could refer below link for more information.

    # How to: Specify a Client Binding in Code

    https://docs.microsoft.com/en-us/dotnet/framework/wcf/how-to-specify-a-client-binding-in-code

    Best Regards,

    Edward


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, June 9, 2017 1:46 AM

All replies

  • App.configs are only used at VS debug mode. Whatever is consuming the web service must have the endpoint information in it so   .Net can find it. The below fourm covers all web service types.

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=wcf

    Wednesday, June 7, 2017 7:26 AM
  • Thanks for the quick reply..

    So i need to add same app.config file to all the libraries i am inheriting with?


    M.Azeem

    Wednesday, June 7, 2017 8:14 AM
  • Thanks for the quick reply..

    So i need to add same app.config file to all the libraries i am inheriting with?


    M.Azeem

    No, there is only one root project  and a root project app.config that all information in subbordinarte app.config info must be copied to the root config so .Net can find the information in the root config file at runtime.  You should post to the WCF forum. 
    Wednesday, June 7, 2017 8:35 AM
  • What DA924x is trying to say is that class libraries do not have config files. Only applications (console, Windows, WPF, ASP.NET, etc) have config files. The servicemodel end point needs to be in the application project's config. At runtime the configuration subsystem only loads the app's config file (by default). So having a config for a class library doesn't make sense. The application is responsible for determining which URL to use. The class library simply provides the code to connect to the provided endpoint.

    Michael Taylor
    http://www.michaeltaylorp3.net

    Wednesday, June 7, 2017 2:02 PM
    Moderator
  • Hi Mohammad Azeem,

    Thank you for posting here.

    According to your question is more question is more related to WCF, I will move it to Windows Communication Foundation, Serialization, and Networking forum for suitable support.

    The Visual C# discuss and ask the C# programming language, IDE, libraries, samples and tools.

    If you have some grammar or code errors, please feel free to contact us. We will try our best to give you a solution.

    Thanks for your understanding and cooperation.

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, June 8, 2017 5:24 AM
  • Hi M.Azeem,

    Has your issue been resolved?

    I agree with CoolDadTx that class library does not have config which causes your issue.

    If you want such a library which could be used in different projects, I would suggest you configure WCF Client in code instead of app.config.

    Here is a simple demo:

    //Specify the binding to be used for the client.
                BasicHttpBinding binding = new BasicHttpBinding();
    
                //Specify the address to be used for the client.
                EndpointAddress address = 
                   new EndpointAddress("http://localhost/servicemodelsamples/service.svc");
                
    
                // Create a client that is configured with this address and binding.
                CalculatorClient client = new CalculatorClient(binding, address);

    You could refer below link for more information.

    # How to: Specify a Client Binding in Code

    https://docs.microsoft.com/en-us/dotnet/framework/wcf/how-to-specify-a-client-binding-in-code

    Best Regards,

    Edward


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, June 9, 2017 1:46 AM
  • Thanks Edward,

    That's worked perfectly for me.

    Thanks all for your valuable time and comments.


    M.Azeem


    Sunday, June 11, 2017 6:48 AM