This could be due to the service endpoint binding not using the HTTP protocol

前端 未结 22 2141
梦谈多话
梦谈多话 2020-12-22 23:10

I have a WCF Service running fine on my local machine. I put it on the servers, and I am receiving the following error:

An error occurred while receiv

相关标签:
22条回答
  • 2020-12-22 23:52

    I think there is serialization problem, you can find exact error just need to add below code in service config in <configuration> section.

    After config update "App_tracelog.svclog" file will create, where your service exist just need to open .svclog file and find red color line on left side panel which is error and see its description for more info.

    i hope this will help to find your error.

    <system.diagnostics>
        <sources>
          <source name="System.ServiceModel.MessageLogging" switchValue="Warning, ActivityTracing">
            <listeners>
              <add name="ServiceModelTraceListener" />
            </listeners>
          </source>
          <source name="System.ServiceModel" switchValue="Verbose,ActivityTracing">
            <listeners>
              <add name="ServiceModelTraceListener" />
            </listeners>
          </source>
          <source name="System.Runtime.Serialization" switchValue="Verbose,ActivityTracing">
            <listeners>
              <add name="ServiceModelTraceListener" />
            </listeners>
          </source>
        </sources>
        <sharedListeners>
          <add initializeData="App_tracelog.svclog" type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" name="ServiceModelTraceListener" traceOutputOptions="Timestamp" />
        </sharedListeners>
      </system.diagnostics>
    
    0 讨论(0)
  • 2020-12-22 23:52

    In my instance, the error was generated because one of my complex types had a property with no set method.

    The serializer threw an exception because of that fact. Added internal set methods and it all worked fine.

    Best way to find out why this is happening (in my opinion) is to enable trace logging.

    I achieved this by adding the following section to my web.config:

    <system.diagnostics>
      <sources>
        <source name="System.ServiceModel.MessageLogging" switchValue="Warning,ActivityTracing">
          <listeners>
            <add name="traceListener"
                  type="System.Diagnostics.XmlWriterTraceListener"
                  initializeData= "c:\log\Traces.svclog" />
            <add type="System.Diagnostics.DefaultTraceListener" name="Default" />
          </listeners>
        </source>
        <source propagateActivity="true" name="System.ServiceModel" switchValue="Verbose,ActivityTracing">
          <listeners>
            <add name="traceListener"
                  type="System.Diagnostics.XmlWriterTraceListener"
                  initializeData= "c:\log\Traces.svclog" />
            <add type="System.Diagnostics.DefaultTraceListener" name="Default" />
          </listeners>
        </source>
      </sources>
      <trace autoflush="true" />
    </system.diagnostics>
    

    Once set, I ran my client, got exception and checked the 'Traces.svclog' file. From there, I only needed to find the exception.

    0 讨论(0)
  • 2020-12-22 23:52

    I figured out the problem. It ended up being a path to my config file was wrong. The errors for WCF are so helpful sometimes.

    0 讨论(0)
  • 2020-12-22 23:53

    This error can be because of contract mismatch. Consider the three layered application below...

    UI Layer
    |
    Process Layer
    |
    Data Access Layer
    -> Contract Between Process and UI layer has the same enum with missing (Onhold = 3). Enum: Start = 1, Stop = 2. -> Contract Between Data Access And Process layer has enum Enum: Start = 1,Stop = 2,Onhold = 3.

    In this case we will get the same error in process layer response.

    The same error comes in other contract mismatch in multilayered application.

    0 讨论(0)
  • 2020-12-22 23:53

    I had this problem because I configured my WCF Service to return a System.Data.DataTable.

    It worked fine in my test HTML page, but blew up when I put this in my Windows Form application.

    I had to go in and change the Service's Operational Contract signature from DataTable to DataSet and return the data accordingly.

    If you have this problem, you may want to add an additional Operational Contract to your Service so you do not have to worry about breaking code that rely on existing Services.

    0 讨论(0)
  • 2020-12-22 23:53

    Also had this issue and it was due to forgetting to decorate my model with DataContract and DataMember attributes

    0 讨论(0)
提交回复
热议问题