The server was unable to process the request due to an internal error. in WCF error

偶尔善良 提交于 2020-01-13 11:37:07

问题


I have written my service in framework 4.0 using C#. It's an simple method which returns a value

The Web.config is like this:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.web>
    <machineKey validationKey="0E1F430D6FFFA91FBEDAEC1D2DDAAC2127EB055DBAFB78328C5BDE83249A94EA66400453B" decryptionKey="A13EACEAAABBECF2D06619924A8" validation="SHA1" decryption="AES" />
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <services>
      <service name="DecryptCookie.Service1">
        <host>
          <baseAddresses>
            <add baseAddress = "http://localhost:8732/Design_Time_Addresses/WCFandEFService/ProductService/" />
          </baseAddresses>
        </host>
        <endpoint address=""  binding="wsHttpBinding"    contract="DecryptCookie.IService1">
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract = "IMetadataExchange"/>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="True"/>
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>  
</configuration>

When I try to consume the service, I am getting an error like this:

Error: The server was unable to process the request due to an internal error. 
For more information about the error, either turn on
IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from
the configuration behavior) on the server in   order to send the exception
information back to the client, or turn on tracing as per the Microsoft .NET
Framework 3.0 SDK documentation and inspect the server trace
logs.System.Exception {System.ServiceModel.FaultException}

I am not sure what the problem is.


回答1:


When I get these cryptic errors, I turn on tracing and create a service log (.svcLog). You can then load/read this file using the Service Trace Viewer tool. This will give you detailed data regarding the error(s). Follow the instructions on this link - http://msdn.microsoft.com/en-us/library/ms732023.aspx




回答2:


Please Check the Proxy file. check whether have you updated any thing in business/data access file and not updated the proxy. this is due to proxy error.




回答3:


you can try adding diagnostics your web.config file to get logs:

 <system.diagnostics> 
      <sources> 
        <source name="System.ServiceModel" 
                switchValue="All" 
                propagateActivity="true"> 
          <listeners> 
            <add name="traceListener" 
                type="System.Diagnostics.XmlWriterTraceListener" 
                initializeData= "D:\AppLogs\Traces.svclog" /> 
          </listeners> 
        </source> 
      </sources> 
    </system.diagnostics>



回答4:


It might be the case when you copy project from one system to another. in this case you must delete the endpoint from the web.config and you should add service reference again.

Try configure tracing to get more error info:

Open the app.config file of WCF service library and add the configuration for system.diagnostics

  <sources>
      <source name="System.ServiceModel" 
            switchValue="Critical,Information,ActivityTracing"
                propagateActivity="true">
        <listeners>
                 <add name="messages"
                 type="System.Diagnostics.XmlWriterTraceListener"
                 initializeData="c:\logs\messages.svclog" />
          </listeners>
      </source>
    </sources>
    <trace autoflush="true" />
  </system.diagnostics> ```


来源:https://stackoverflow.com/questions/14217700/the-server-was-unable-to-process-the-request-due-to-an-internal-error-in-wcf-er

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!