Reputation: 2826
I have a c# win app with asp.net web service (wsdl). If I enabled proxy, the application stops working and when i look event log viewer , i see this error :
Framework Sürümü: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.ServiceModel.ProtocolException
Stack:
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.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at: System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
at: System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(System.Runtime.Remoting.Messaging.IMessage, System.Runtime.Remoting.Messaging.IMessage)
at: System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(System.Runtime.Remoting.Proxies.MessageData ByRef, Int32)
at: MatriksMessenger.MsgService.ServiceSoap.IsBlocked(System.String, System.String, System.String)
at: MatriksMessenger.LoginForm.CallService()
at: System.Threading.ThreadHelper.ThreadStart_Context(System.Object)
at: System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at: System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at: System.Threading.ThreadHelper.ThreadStart()
I can access the webservice from the browser. How can i find a solution?
Thanks,
Win 7 , Framework 4.0
Upvotes: 0
Views: 22549
Reputation: 2826
I figured it out. I have added this lines to app.config
<system.net>
<defaultProxy enabled="true" useDefaultCredentials="true">
</defaultProxy>
<settings>
<servicePointManager expect100Continue="false" />
</settings>
</system.net>
Upvotes: 1
Reputation: 4954
It sounds like the webservice is using security/authentication settings that depend on the user being in the same domain as the service.
Then, if you are calling the service via a proxy, the security (user) typically gets lost. This is the case when you use basicHttpBinding over proxy, and since that is the default I'm assuming that's what you are doing.
If you want your webservice to be able to authenticate the user even though the user and service are on different domains, you need to use another binding, e.g. ws2007HttpFederationBinding (WIF).
If you just need to ensure that your proxy settings are not getting in your way, you can change settings in your app.config file for your Windows application so that the service call will bypass the proxy and call the service directly. This can be done with setting attributes on your binding specification in your app.config, see http://msdn.microsoft.com/en-us/library/ms731361.aspx for details of attributes available for basicHttpBinding.
The attributes you should change are bypassproxyonlocal and usedefaultproxy.
Upvotes: 1