I'm developing a VS2010 Dotnet 4.0 client to a SOAP service in a device (a Pelco brand video dome as it happens) that runs embedded Linux. I have no control over the SOAP server in the device. The vendor has furnished WSDL files that load correctly as service references.
I'm using a command line desktop client to figure this out (before migrating the code into a service).
Simplifying a bit, the SOAP calls in the various services take forms like this:
service.SetPosition(pan,tilt,zoom)
var pos = service.GetPosition();
and so forth. They basically work and do what's expected.
The problem is this: once in a while, intermittently, with a pattern I haven't (yet) figured out, a random one of these service calls throws a CommunicationException whose Message is
The underlying connection was closed: A connection that was
expected to be kept alive was closed by the server.
Here's how I construct my service objects:
var binding = new System.ServiceModel.BasicHttpBinding();
uri = new Uri(/*the correct uri for the service*/);
address = new System.ServiceModel.EndpointAddress(u);
service = new PositioningControlPortTypeClient(binding, address);
In this case the PositioningControlPortTypeClient
gets defined via the WSDL when I load it as a service reference.
Is there a way to force dotnet 4.0 / wcf / soap to use HTTP/1.0?
Is there a way to detect that my service client is about to throw this exception before it throws it?
Should I use each service object just once, then dispose it?
Any other wisdom?