从 ObjectDataSource Select 方法调用 MVC Service 时出现 CommunicationException

发布于 2024-11-08 22:43:27 字数 2302 浏览 4 评论 0原文

我在我的网络应用程序中遇到以下异常: “通信对象 System.ServiceModel.Channels.ServiceChannel 无法用于通信,因为它处于故障状态” 堆栈跟踪:

" 服务器堆栈跟踪:位于 System.ServiceModel.Channels.CommunicationObject.Close(TimeSpan 超时)在 [0] 处重新抛出异常: System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg、IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData,Int32 类型)位于 System.ServiceModel.ICommunicationObject.Close(TimeSpan超时)
在 System.ServiceModel.ClientBase1.System.ServiceModel.ICommunicationObject.Close(TimeSpan 超时)在 System.ServiceModel.ClientBase1.Close() 处 System.ServiceModel.ClientBase`1.System.IDisposable.Dispose() 在 System.Web.UI.WebControls.ObjectDataSourceView.ReleaseInstance(对象 实例)在 System.Web.UI.WebControls.ObjectDataSourceView.ExecuteSelect(DataSourceSelectArguments 参数)在 System.Web.UI.WebControls.ObjectDataSource.Select() 在 BudgeteerWeb.EditTransaction.Page_Load(对象发送者,EventArgs e) 在 C:\Develop\Budgeteer\BudgeteerWeb\BudgeteerWeb\MemberPages\Transactions\Edit.aspx.vb:line 27 英寸

我从 ObjectDataSource 使用的 select 方法中调用 WCF 服务。如果我不使用基于消息的安全性,一切正常。但是一旦我使用 ClientCredentials 打开 wsHttpBinding,我就会得到不确定我错过了什么。

ASP 代码:

背后代码: objectDataSource select 方法使用的函数:

Protected Function getTransaction(ByVal userID As String, ByVal transactionID As Int64)   
    As BudgeteerService.Transaction

    Dim transaction As BudgeteerService.Transaction = New BudgeteerService.Transaction
    transaction = wcfProxy.GetTransaction(userID, transactionID)

    Return transaction

End Function

Try
    transactionID = Int64.Parse(Request.QueryString("TransactionID"))

    Dim userIdParm As Parameter = New Parameter

    TransactionDataSource.Select() '**EXCEPTION GETS THROWN HERE**
    FormView1.DataSource = TransactionDataSource
    FormView1.DataBind()
Catch timeOutEx As TimeoutException
    Throw timeOutEx
Catch comEx As CommunicationException
    Throw comEx
Catch ex As Exception
    Throw New Exception("An error occured while trying to retrieve this transaction")
End Try

提前致谢。

I am getting the exception below in my web application:
"The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state"
Stack Trace:

" Server stack trace: at
System.ServiceModel.Channels.CommunicationObject.Close(TimeSpan
timeout) 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
System.ServiceModel.ICommunicationObject.Close(TimeSpan timeout)
at
System.ServiceModel.ClientBase1.System.ServiceModel.ICommunicationObject.Close(TimeSpan
timeout) at System.ServiceModel.ClientBase
1.Close() at
System.ServiceModel.ClientBase`1.System.IDisposable.Dispose() at
System.Web.UI.WebControls.ObjectDataSourceView.ReleaseInstance(Object
instance) at
System.Web.UI.WebControls.ObjectDataSourceView.ExecuteSelect(DataSourceSelectArguments
arguments) at System.Web.UI.WebControls.ObjectDataSource.Select()
at BudgeteerWeb.EditTransaction.Page_Load(Object sender, EventArgs e)
in
C:\Develop\Budgeteer\BudgeteerWeb\BudgeteerWeb\MemberPages\Transactions\Edit.aspx.vb:line
27"

I am calling a WCF Service from within a select method used by a ObjectDataSource. Everything works OK if I'm not using message-based security. But as soon as I turn on the wsHttpBinding with the ClientCredentials, I get the above error. Not sure what I'm missing.

ASP Code:

Code Behind:
Function That is used by objectDataSource select method:

Protected Function getTransaction(ByVal userID As String, ByVal transactionID As Int64)   
    As BudgeteerService.Transaction

    Dim transaction As BudgeteerService.Transaction = New BudgeteerService.Transaction
    transaction = wcfProxy.GetTransaction(userID, transactionID)

    Return transaction

End Function

Try
    transactionID = Int64.Parse(Request.QueryString("TransactionID"))

    Dim userIdParm As Parameter = New Parameter

    TransactionDataSource.Select() '**EXCEPTION GETS THROWN HERE**
    FormView1.DataSource = TransactionDataSource
    FormView1.DataBind()
Catch timeOutEx As TimeoutException
    Throw timeOutEx
Catch comEx As CommunicationException
    Throw comEx
Catch ex As Exception
    Throw New Exception("An error occured while trying to retrieve this transaction")
End Try

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文