WCF service access from client application when user is behind proxy
I have a WCF service hosted on a server. A client application is accessing the service on a windows 7 machine. There are two users on Windows 7 machine. Windows application is a installed through Clickonce so separate instance will be there for two users.
When userA accessing the service through Winforms application it works fine, but when userB on the same machine trying to access it throws following exception: Communication Exception: The remote server returned an unexpected response: (417) Expectation failed.
Server stack trace:
at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory factory, WebException responseException, ChannelBinding channelBinding)
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, Pr开发者_Python百科oxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at Myapp.ServiceProxy.IMyAPIService.GetData(String userName, String passWord)
What could be the reason behind working for one user and not for other? Am I missing anything?
UPDATE: Though I found a solution (Please see my answer below) to this issue but still wanted to know what should be done in this scenario. As MSDN article says it blocks user to send large amount of data to server, but it didn't mention about any limit in that?
What is the limit of data client can send to server? Is there any better approach for connecting a WCF service from a client who is behind proxy?
Finally I cracked it. It happens because the user is behind a proxy.
Following setting in the app.config resolved the issue:
<system.net>
<settings>
<servicePointManager expect100Continue="false" />
</settings>
</system.net>
But this is still an issue for large file upload, looking for a solution for the same now.
More information on this in MSDN article
精彩评论