簡體   English   中英

代理的WebService錯誤

[英]WebService error with proxy

我有一個使用asp.net web服務(wsdl)的#win app。 如果我啟用了代理,應用程序將停止工作,當我查看事件日志查看器時,我看到此錯誤:

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

我可以從瀏覽器訪問webservice。 我怎樣才能找到解決方案?

謝謝,

Win 7,Framework 4.0

聽起來網絡服務使用的安全/身份驗證設置取決於用戶與服務位於同一域中。

然后,如果您通過代理調用服務,則安全性(用戶)通常會丟失。 當您在代理上使用basicHttpBinding時會出現這種情況,因為這是默認情況,我假設您正在做的事情。

如果您希望您的Web服務能夠對用戶進行身份驗證,即使用戶和服務位於不同的域上,您也需要使用另一個綁定,例如ws2007HttpFederationBinding(WIF)。

如果您只是需要確保代理設置不受阻礙,則可以更改Windows應用程序的app.config文件中的設置,以便服務調用將繞過代理並直接調用服務。 這可以通過在app.config中設置綁定規范的屬性來完成,有關basicHttpBinding可用屬性的詳細信息,請參閱http://msdn.microsoft.com/en-us/library/ms731361.aspx

您應該更改的屬性是bypassproxyonlocal和usedefaultproxy。

我想到了。 我已將此行添加到app.config中

      <system.net>
            <defaultProxy enabled="true" useDefaultCredentials="true">
            </defaultProxy>
            <settings>
              <servicePointManager expect100Continue="false" />
            </settings>
      </system.net>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM