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

24

92

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 receiving the HTTP response to http://xx.xx.x.xx:8200/Services/WCFClient.svc. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details.]

I have gone to the service in the url and it is working correctly. All I am doing for the function is returning a string to an image name, so the data being passed isn't a lot. I have traced the log and it gives me the same information. Here is my client config:

<binding name="basicHttpBinding_IWCFClient" closeTimeout="00:01:00"
         openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
         bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
         maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
         messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
         allowCookies="false">
    <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" 
                  maxArrayLength="2147483647" maxBytesPerRead="2147483647" 
                  maxNameTableCharCount="2147483647" />
    <security mode="None">
        <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
        <message clientCredentialType="UserName" algorithmSuite="Default" />
    </security>
</binding>
<endpoint name="basicHttpBinding_IWCFClient" 
    address="http://localhost:4295/Services/WCFClient.svc"
    binding="basicHttpBinding" 
    bindingConfiguration="basicHttpBinding_IWCFClient" 
    behaviorConfiguration="WCFGraphicManagementTool.Services.ClientBehavior"
    contract="WCFClient.IWCFClient" />

Here is my server config:

<service behaviorConfiguration="WCFGraphicManagementTool.Services.WCFClientBehavior"
    name="WCFGraphicManagementTool.Services.WCFClient">
   <endpoint name="basicHttpBinding_IWCFClient"
       address="" 
       binding="basicHttpBinding" 
       contract="WCFGraphicManagementTool.Contracts.IWCFClient" />
   <endpoint 
       address="mex" 
       binding="mexHttpBinding" 
       contract="IMetadataExchange" />
</service>
<behavior name="WCFGraphicManagementTool.Services.WCFClientBehavior">
   <dataContractSerializer maxItemsInObjectGraph="2147483647" />
   <serviceThrottling maxConcurrentCalls="120" maxConcurrentSessions="120"
                      maxConcurrentInstances="120" />
   <serviceMetadata httpGetEnabled="true" />
   <serviceDebug includeExceptionDetailInFaults="true" />
</behavior>

Would it be a setting on the server since it works on my local machine?

Tamarin answered 3/5, 2011 at 14:24 Comment(3)
I solved my issue as I explained here: #5538294Doubleedged
Seems like you got further than me. Perhaps you can give me a pointer on what to do next. #16628882Okun
Any chance you'll accept any of the answers, since I doubt you're still waiting to get one ? :)Hagride
T
1

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.

Tamarin answered 16/5, 2011 at 13:42 Comment(0)
S
111

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.

<configuration>
...
...

<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>

  </configuration>

Update: If you will not able to find updated "App_tracelog.svclog" file then please find "<some GUID>App_tracelog.svclog" like "a39e3026-5dd8-4d39-842a-04d486615eedApp_tracelog.svclog"

Substance answered 23/1, 2013 at 14:10 Comment(1)
Be sure to paste the <system.diagnostics> section to the end of the file, just above </configuration>. If you paste it at the top, you could get a content type error when running your app.Granjon
G
79

I had this problem "This could be due to the service endpoint binding not using the HTTP protocol" and the WCF service would shut down (in a development machine)

I figured out: in my case, the problem was because of Enums,

I solved using this

    [DataContract]
    [Flags]
    public enum Fruits
    {
        [EnumMember]
        APPLE = 1,
        [EnumMember]
        BALL = 2,
        [EnumMember]
        ORANGE = 3 

    }

I had to decorate my Enums with DataContract, Flags and all each of the enum member with EnumMember attributes.

I solved this after looking at this msdn Reference:

Gaultiero answered 11/8, 2012 at 18:56 Comment(5)
Related to this - if you have an enum type on a contract that isn't the type of a DataMember then you'll get this error. I simply just added a property that was a DataMember and gave it the non-DataContract enum type.Spitball
Isn't it also the case that the enumerations need to start with at index 0? This was certainly an issue in the past for me. So in the above example APPLE = 0 rather than 1.Feigin
Received this error due to having an IEnumerable<T> property decorated with a [DataMember] attribute. Funny thing is that the code worked locally, but not when deployed to our production server.Rovelli
My case, I was referring to composite types inside a composite type, but had not declared the underlying types, i.e. Shipment >> ShipLines >> LineType (LineType Class/Type not defined). Didn't know why VS didn't complain.Tardiff
Just by chance this was my same issue (Enum not serializing). I do have to agree that Rikin Patel above on how to find the issue, but i am grateful for your post as it turn on a light bulb for me.Fusco
S
18

I've had this same error and the problem was serialization. I managed to find the real problem using Service Trace Viewer http://msdn.microsoft.com/en-us/library/ms732023.aspx and solved it easy. Maybe this will help someone.

Serration answered 26/1, 2012 at 8:6 Comment(0)
I
17

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.

Indubitable answered 29/1, 2015 at 19:9 Comment(1)
autoflush=true was keyRalphralston
Q
9

Solution with DataContract, Flags for Enums looks a bit ugly. In my case problem been solved by adding something like "NotSet = 0" into enum:

public enum Fruits
{
  UNKNOWN = 0,
  APPLE = 1,
  BALL = 2,
  ORANGE = 3 
}
Quit answered 25/2, 2013 at 6:45 Comment(2)
Ah yes, sorry, just commented on a further up answer. I've seen this behaviour too.Feigin
explanation: I had the same problem. @Rikin's answer led me to: "The InnerException message was 'Enum value '0' is invalid for type..." from [social.msdn.microsoft.com/Forums/vstudio/en-US/… I got the jem: "The problem here is that you're not initializing the ..Response and it is taking the default (and invalid) value of '0'... so it cannot be serialized".Sathrum
M
5

I was facing the same issue and solved with below code. (if any TLS connectivity issue)

System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;

Please paste this line before open the client channel.

Mock answered 17/10, 2018 at 23:58 Comment(0)
B
2

I've seen this error caused by a circular reference in the object graph. Including a pointer to the parent object from a child will cause the serializer to loop, and ultimately exceed the maximum message size.

Bulwerlytton answered 12/3, 2013 at 16:47 Comment(0)
I
2

I struggled with this for a couple of days and tried every answer from this post and many others and share my solution because symptoms were the same but the problem was different.

The problem was that the app pool was configured with a memory limit and it just get recycled after a variable period of time.

Hope this helps somebody else!
Greetings,

Induce answered 10/9, 2015 at 14:30 Comment(0)
T
1

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.

Tamarin answered 16/5, 2011 at 13:42 Comment(0)
C
1

To fix this, we had to changed the AppPool Identity to an administrator account.

Cocoa answered 17/1, 2013 at 1:42 Comment(1)
This was useful to me. I didn't do exactly what Sarjan suggested but just gave read/write rights on the application folder (under wwwroot...) to the application pool identity I was using.Tedder
I
1

My problem was, that return type of my service was string. But I returned string of type xml:

<reponse><state>1</state><message>Operation was successfull</message</response>

so error was thrown.

Ingathering answered 19/4, 2013 at 9:33 Comment(0)
S
1

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.

Semipalmate answered 9/5, 2013 at 4:25 Comment(1)
Your answer doesn't appear to have anything to do with the question. Note also that the OP has already solved his problem - the path to the config file was wrong.Expulsive
O
1

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.

Oligarch answered 30/9, 2013 at 21:45 Comment(0)
A
1

This could be due to many reasons; below are few of those:

  1. If you are using complex data contract objects(that means custom object with more child custom objects), make sure you have all the custom objects decorated with DataContract and DataMember attributes
  2. If your data contract objects use inheritance, make sure all base classes has the DataContract and DataMember attributes. Also, you need to have the base classes specify the derived classes with the [KnownType(typeof(BaseClassType))] attribute ( check out more info here on this).

  3. Make sure all your data contract object properties have both get and set properties.

Ablepsia answered 2/10, 2013 at 18:18 Comment(0)
P
1

My problem was too many items were being passed between client and server. I had to change this settings in the behavior on both sides.

<dataContractSerializer maxItemsInObjectGraph="2147483646"/>
Paladin answered 9/12, 2014 at 17:38 Comment(1)
I used the same solution. But I had to use Service Trace Viewer as suggested by @Serration to see that it was the error.Longmire
J
1

This might not be relevant to your specific problem, but the error message you mentioned has many causes, one of them is using a return type for an [OperationContract] that is either abstract, interface, or not known to the WCF client code.

Check the post (and solution) below

https://mcmap.net/q/76648/-wcf-web-service-error-quot-service-endpoint-binding-not-using-http-protocol-quot

Juliennejuliet answered 8/3, 2015 at 8:40 Comment(0)
S
1

I think the best way to solve this is to follow the error advice, hence looking for server logs. To enable logs I added

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

Then you go to c:\logs\TracesServ_ce.svclog open it with microsoft service trace viewer. And see what the problem really is.

Silo answered 6/7, 2015 at 8:34 Comment(0)
G
1

For more insight into this issue, also see: An existing connection was forcibly closed by the remote host - WCF

My problem ended up being that my data transfer objects were too complex. Start withsimple properties like public long Id { get; set; } and once you get that working than start adding additional stuff as needed.

Groundsheet answered 10/9, 2015 at 2:55 Comment(0)
S
1

in my case

my service has function to download Files

and this error only shown up on trying to download Big Files

so I found this answer to Increase maxRequestLength to needed value in web.config

I know that's weird, but problem solved

if you don't make any upload or download operations maybe this answer will not help you

Stepheniestephens answered 23/6, 2016 at 8:2 Comment(0)
W
1

For me the solutions of this Error very strange. It was the issue of port address of EndpointAddress. In Visual studio port address of your file (e.g. Service1.svc) and port address of your wcf project must be the same which you gives into EndpointAddress. Let me describe you this solution in detail.

There are two steps to check the port addresses.

  1. In your WCF Project right click to your Service file (e.g. Service1.svc) -> than select View in browser now in your browser you have url like http://localhost:61122/Service1.svc so now note down your port address as a 61122

  2. Righ click your wcf project -> than select Properties -> go to the Web Tab -> Now in Servers section -> select Use Visual Studio Development Server -> select Specific Port and give the port address which we have earlier find from our Service1.svc service. That is (61122).

Earlier I have different port address. After Specifying port address properly which I have given into EndpointAddress, my problem was solved.

I hope this might be solved your issue.

Wandy answered 10/10, 2016 at 12:13 Comment(0)
P
0

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

Polynuclear answered 14/9, 2016 at 11:33 Comment(0)
D
0

If you have a database(working in visual studio), make sure there are no foreign keys in the tables, I had foreign keys and it gave me this error and when I removed them it ran smoothly

Derian answered 22/9, 2020 at 13:17 Comment(0)
C
0

I realize there are seemingly many "solutions" to this problem. I was experiencing this same error message in a VB.NET application that was making a call to a wsdl. The framework that I published the application under was 3.5, and IT recently disabled TLS 1.0 and 1.1 on my application server that was running the app as a schedule task.

Targeting the application framework to 4.5.2 resolved this issue for me.

Creedon answered 14/1, 2022 at 20:26 Comment(0)
A
0

I had this issue, mine was web application binding to a web service. The web service was hosted on a server with SSL certificates and using http while the web application was using http. I just changed the binding in the webconfig of the web application to communicate to the webservice using https. Hope it helps

 <binding name="XXXXSoap" closeTimeout="00:50:00" openTimeout="00:40:00" receiveTimeout="00:20:00" sendTimeout="00:40:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxBufferSize="65536" maxReceivedMessageSize="65536" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true" messageEncoding="Text">
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
      <security mode="Transport">
        <transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
      </security>
    </binding>

then the endpoint:

<endpoint address="https://ipaddress:port/xxxx.asmx" binding="basicHttpBinding" bindingConfiguration="XXXXSoap" contract="xxxxSoap" name="XXXXSoap" />
Asserted answered 28/7, 2022 at 10:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.