Silverlight 4 WCF 服务器未提供有意义的回复

发布于 2024-12-29 08:01:07 字数 3662 浏览 1 评论 0原文

我在我的项目中遇到了臭名昭著的问题:“服务器没有提供有意义的回复;这可能是由合同不匹配、会话过早关闭或内部服务器错误引起的”。它是一个 WCF PollingDuplex 服务,由 Silverlight 4 项目使用。

我正在通过该服务请求文档,以便可以在 SL 应用程序的查看器中显示它。

这是服务器 Web 配置 XML:

    <system.serviceModel>

    <extensions>
      <bindingExtensions>
        <add name="pollingDuplex" type="System.ServiceModel.Configuration.PollingDuplexHttpBindingCollectionElement,System.ServiceModel.PollingDuplex, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
      </bindingExtensions>
    </extensions>


  <serviceHostingEnvironment aspNetCompatibilityEnabled="true"
      multipleSiteBindingsEnabled="true" />

 <behaviors>
      <serviceBehaviors>
    <behavior name="PortalOnlineBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
          <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>

 <bindings>
 <pollingDuplex>
        <binding name="SLPollingDuplex" duplexMode="MultipleMessagesPerPoll" />
      </pollingDuplex>
    </bindings>

    <services>
      <service name="Online.Web.PortalOnline" behaviorConfiguration="PortalOnlineBehavior">
        <endpoint address="" binding="pollingDuplex" bindingConfiguration="SLPollingDuplex"
          contract="Notification.IPortalOnline" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://portalonline.com/PortalOnline/IPortalOnline" />
          </baseAddresses>
        </host>
      </service>
    </services>

  </system.serviceModel>

这是我试图通过此 WCF 服务返回到 SL 的对象

Imports System.ServiceModel
Imports System.Runtime.Serialization
Imports DocCave.Common
Imports System.Xml
Imports System.IO

    <DataContract(NAMESPACE:=DataStore.NAMESPACE)>
    Public Class PortalDocument

        <DataMember()>
        Public Property DataSource As Byte()

        <DataMember()>
        Public Property FileName As String

        <DataMember()>
        Public Property FileType As String

    End Class

这是正在调用的 WCF 方法:

 Public Function GetDocument(sessionUserMeta As Common.UserMetaData, docId As System.Guid) As Notification.PortalDocument Implements Notification.IPortalOnline.GetDocument

        Dim doc As Documents.Document = Documents.Document.GetDocument(docId, sessionUserMeta)

        Dim portalDoc As New PortalDocument

        portalDoc.DataSource = doc.DataSource

        portalDoc.FileName = doc.QueryPackage.DocumentName
        portalDoc.FileType = doc.QueryPackage.Type

        Return portalDoc

    End Function

更多详细信息:

这非常适合一两个文档请求,并且给了我上述错误。例如,当使用此服务的方法加载 SL 应用程序时,我可以加载默认文档,并且它可以完美填充。然后我可以转到我拥有的树视图,并选择一个文档,它对于第一个文档来说非常完美......但之后,错误。另外,我注意到有时它只能工作一次,如果我选择某些稍大一点的 pdf(250kb 左右..)...哦,我忘了...这是我的 SL 应用程序中的代码,即连接到 WCF 服务。我使用“GetBaseWebAddress()”是因为我使用动态子域,所以地址的一部分每次都可能不同......

Private Sub LoadClient()


        Dim bind As New PollingDuplexHttpBinding(PollingDuplexMode.MultipleMessagesPerPoll)

        Dim endpoint As New EndpointAddress(GetBaseWebAddress() & "PortalOnline/PortalOnline.svc")

        Me.client = New PortalOnline.PortalOnlineClient(bind, endpoint)

        AddHandlers()

    End Sub

我已经为此苦苦挣扎了一段时间,所以任何帮助将不胜感激。 ..

I'm getting the notorious, "The server did not provide a meaningful reply; this might be caused by a contract mismatch, a premature session shutdown or an internal server error" in my project. It's a WCF PollingDuplex Service, consumed by a Silverlight 4 project.

I'm requesting a document with the service, so I can display it in a viewer in my SL application.

Here is the Server Web Config XML:

    <system.serviceModel>

    <extensions>
      <bindingExtensions>
        <add name="pollingDuplex" type="System.ServiceModel.Configuration.PollingDuplexHttpBindingCollectionElement,System.ServiceModel.PollingDuplex, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
      </bindingExtensions>
    </extensions>


  <serviceHostingEnvironment aspNetCompatibilityEnabled="true"
      multipleSiteBindingsEnabled="true" />

 <behaviors>
      <serviceBehaviors>
    <behavior name="PortalOnlineBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
          <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>

 <bindings>
 <pollingDuplex>
        <binding name="SLPollingDuplex" duplexMode="MultipleMessagesPerPoll" />
      </pollingDuplex>
    </bindings>

    <services>
      <service name="Online.Web.PortalOnline" behaviorConfiguration="PortalOnlineBehavior">
        <endpoint address="" binding="pollingDuplex" bindingConfiguration="SLPollingDuplex"
          contract="Notification.IPortalOnline" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://portalonline.com/PortalOnline/IPortalOnline" />
          </baseAddresses>
        </host>
      </service>
    </services>

  </system.serviceModel>

Here is the Object I'm trying to return to SL via this WCF service

Imports System.ServiceModel
Imports System.Runtime.Serialization
Imports DocCave.Common
Imports System.Xml
Imports System.IO

    <DataContract(NAMESPACE:=DataStore.NAMESPACE)>
    Public Class PortalDocument

        <DataMember()>
        Public Property DataSource As Byte()

        <DataMember()>
        Public Property FileName As String

        <DataMember()>
        Public Property FileType As String

    End Class

Here's the WCF Method that is being called:

 Public Function GetDocument(sessionUserMeta As Common.UserMetaData, docId As System.Guid) As Notification.PortalDocument Implements Notification.IPortalOnline.GetDocument

        Dim doc As Documents.Document = Documents.Document.GetDocument(docId, sessionUserMeta)

        Dim portalDoc As New PortalDocument

        portalDoc.DataSource = doc.DataSource

        portalDoc.FileName = doc.QueryPackage.DocumentName
        portalDoc.FileType = doc.QueryPackage.Type

        Return portalDoc

    End Function

Further Details:

This works perfectly for one or two document request, and the gives me the above mentioned error. For instance, I can load a default document when the SL application is loaded using this method with this service, and it populates perfectly. I can then go to a tree view I have, and select a document, and it works perfect for the first document... but after that, error. Also, I've noticed sometimes it will only work once, if I select certain pdfs that are a bit larger (250kb or so..) ... oh, and I forgot... here's the code in my SL application that is connecting to the WCF service. I'm using the "GetBaseWebAddress()" because I'm using dynamic sub domains, so part of the address can be different each time...

Private Sub LoadClient()


        Dim bind As New PollingDuplexHttpBinding(PollingDuplexMode.MultipleMessagesPerPoll)

        Dim endpoint As New EndpointAddress(GetBaseWebAddress() & "PortalOnline/PortalOnline.svc")

        Me.client = New PortalOnline.PortalOnlineClient(bind, endpoint)

        AddHandlers()

    End Sub

I've struggled with this for a while, so any help would be greatly appreciated...

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

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

发布评论

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