Reputation: 38091
I've got a simple WCF service that has worked fine while I've been testing on my dev machine.
Now I've moved the web service to a web server, and I'm running the service (in debug mode) at http://mydomain.com:8005. Opening a web browser to that URL shows the expected service page, and if I put a breakpoint on the server inside the interface I'm calling, it hits the breakpoint and returns the expected data... but on the client side it comes back with the following error:
An error occurred while receiving the HTTP response to http://mydomain.com:8005/. 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.
More clues: the interface signature is:
IEnumerable<MyClass> GetThings(out string errMsg);
where MyClass
is defined as Serializable, and the definitions are identical between client and server.
Any ideas what secret switches I need to flip?
Upvotes: 11
Views: 70600
Reputation: 256
It was something different for me when I started getting this error after upgrading my projects to .NET Framework 4.8.1. All I had to do was to include .netFramework in httpRuntime as below:
<httpRuntime targetFramework="4.8.1" maxRequestLength=
Upvotes: 0
Reputation: 4525
I have faced the same issue. 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.
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
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.
Upvotes: 0
Reputation: 2784
Just faced the exact same problem but it was caused by security protocol type hardcoded to TLS 1.2
while the service was deployed to 2008 server without R2 (and 32 bit to boot, which means non-upgradable to R2).
This is a very unlikely scenario for anyone else, but thought I'd mention.
If anyone is in the same situation and has a line of code like this, you know why you are getting the error now:
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;
Upvotes: 0
Reputation: 107
I just leave this here just in case someone need it. I came across with the same error. I was calling my service which has an argument of the type Dictionary<int, string>
and one of the key/value pairs had the string value set to null.
I changed the code to make sure there were no null values and it worked
Upvotes: 0
Reputation: 1443
Late answer to the party, but I got the same error.
Turns out, you cannot use abstract classes for data contract members. I had to use the following:
[DataContract]
public class MyClass {
[DataMember]
public A MyProperty { get; set; }
}
[DataContract]
[KnownType(typeof(B))]
[KnownType(typeof(C))]
public class A {
}
[DataContract]
public class B : A {
}
[DataContract]
public class C : A {
}
In order to allow WCF to serialize something like
var myClass = new MyClass();
myClass.MyProperty = new B();
Upvotes: 2
Reputation: 1
Update your Entity if any changes made in your previous tables and didn't update your entity also this error will occur
Upvotes: 0
Reputation: 161
I had the same problem because I was returning an insanely large amount of record from the server, i added the following line to my wcf config file and it worked.
<system.web>
<httpRuntime maxRequestLength ="262144" executionTimeout="103600"/>
</system.web>
Upvotes: 8
Reputation: 755411
WCF also needs to have concrete classes to pass data around (since it all needs to be XML-serializable and must be capable of being expressed in XML schema - interfaces aren't well suited).
I believe it won't be able to pass back an IEnumerable<T>
- try using a List<T>
(or an T[]
array) or a concrete type instead.
Any luck?
Upvotes: 23
Reputation: 3337
Don't define MyClass as Serializable. Mark it as [DataContract] and it's properties as [DataMember].
If you can't, well... I think I've seen that question lying around here as well.
EDIT
While there is nothing inherently blocking [Serializable] will cause your serialization to perhaps process more than it can handle.
EDIT 2
marc_s's comment got it right
Upvotes: 4