ASP.NET MVC : could not find endpoint element with name contract

0

I had created an MVC application that had no authentication so I was advised to create a mvc project that has the 'Individual User Accounts' option selected which brings with it some controllers, models and views.

What I had done to keep my old class library data was rename the current class library as Projectold in my file explorer and created a new class library in Visual Studio with the same name(Project) then imported all the controllers, views, config files that I had from my previous library and included them in the new class library.

I have a proxy to 2 web services that exposes data for me to use. Because I only needed a new class library, I had the existing <system.serviceModel> tag already there in the existing service folder so I just copied and pasted it within the new web.config file in the new class library.

What has happened is that now I cannot access the web service to access the data. I am thrown the error:

System.InvalidOperationException
HResult=0x80131509
Message=Could not find endpoint element with name 'WebServiceSoap' and contract 
'ProxyToWebService.WebServiceSoap' 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.
Source=<Cannot evaluate the exception source>
StackTrace:
<Cannot evaluate the exception stack trace>

My web.config file is (The proxy URL's have been anonymised):

    <system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="WebServiceSoap"/>
            <binding name="SWebServiceSoap"/>
        </basicHttpBinding>
        <customBinding>
            <binding name="WebServiceSoap12">
                <textMessageEncoding messageVersion="Soap12"/>
                <httpTransport/>
            </binding>
            <binding name="SWebServiceSoap12">
                <textMessageEncoding messageVersion="Soap12"/>
                <httpTransport/>
            </binding>
        </customBinding>
    </bindings>
    <client>
  <endpoint address="http://URL/URL/URL.asmx" binding="basicHttpBinding" bindingConfiguration="WebServiceSoap" contract="ProxyToWebService.WebServiceSoap" name="WebServiceSoap" />
  <endpoint address="http://URL/URL/URL.asmx" binding="customBinding" bindingConfiguration="WebServiceSoap12" contract="ProxyToWebService.WebServiceSoap" name="WebServiceSoap12" />
  <endpoint address="http://URL/URL/URL.asmx" binding="basicHttpBinding" bindingConfiguration="SWebServiceSoap" contract="ProxyToSWebService.SWebServiceSoap" name="SWebServiceSoap" />
  <endpoint address="http://URL/URL/URL.asmx" binding="customBinding" bindingConfiguration="SWebServiceSoap12" contract="ProxyToSWebService.SWebServiceSoap" name="SWebServiceSoap12" />
    </client>
</system.serviceModel>

I have returned to a back up copy and it works before I replace my old new class library with my new class library so the endpoint connections should be okay. Just when they are used in the new class library is where it breaks. I cannot just copy the old web.config file either as because the Individual User Accounts option is selected, it has modified the web.config file.

My code for the proxy connection:

        public InboundService()
    {
        proxy = new WebServiceSoapClient("WebServiceSoap", "http://URL/URL/URL.asmx");
        Sproxy = new SWebServiceSoapClient("SWebServiceSoap", "http://URL/URL/URL.asmx");
    }
c#
asp.net-mvc
asked on Stack Overflow Feb 16, 2021 by DerekJo23 • edited Feb 16, 2021 by DerekJo23

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0