2010-07-01 48 views
1

我試圖連接到一個現有的Windows服務,公開了幾個WCF端點。我所關心的是Silverlight 4應用程序將與之交談的那一個。這裏是服務的配置文件(至少是部分我們關注):WSDualHttpBinding在Silverlight 4程序集中?

<system.serviceModel> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="EnableMetadataBehavior"> 
      <serviceMetadata httpGetEnabled="true"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <services> 
     <service behaviorConfiguration="EnableMetadataBehavior" name="Cad.Server.ConsoleCustomerServicePortal"> 
     <endpoint address="ConsoleCustomerServicePortal" binding="wsDualHttpBinding" 
      name="CustomerServiceEndpoint" contract="Cad.Net.Wcf.Contracts.CustomerService.ICustomerService" /> 
     <endpoint address="" behaviorConfiguration="webHttpBehavior" 
      binding="webHttpBinding" name="CustomerServiceSilverlightEndpoint" 
      contract="Cad.Net.Wcf.Contracts.Silverlight.IClientAccessPolicy" /> 
     <host> 
      <baseAddresses> 
      <add baseAddress="http://localhost:31313/" /> 
      </baseAddresses> 
     </host> 
     </service> 
    </services> 
    </system.serviceModel> 

服務是自主辦,下面開始服務主機:

Public Sub StartServiceHost() 
     'Publish the Wcf Service endpoint. 
     Try 
     shRccUserInterface = New ServiceHost(Me._CsService) 
     AddHandler shRccUserInterface.Faulted, AddressOf OnChannelFaulted 
     AddHandler shRccUserInterface.Closed, AddressOf OnChannelClosed 
     AddHandler shRccUserInterface.Opened, AddressOf OnChannelOpened 
     AddHandler shRccUserInterface.Opening, AddressOf OnChannelOpening 
     AddHandler shRccUserInterface.UnknownMessageReceived, AddressOf OnUnknownMessageReceived 

     shRccUserInterface.Open() 
     Me.blnServiceHostOpen = True 
     RaiseEvent ServiceHostOpenEvent(Me) 
     Catch exWcf As Exception 
     log.Write_Error("CsGuiComm", "StartServiceHost()", exWcf) 
     RaiseEvent SendUtaEmailEvent("Wcf Problem", exWcf.ToString, System.Net.Mail.MailPriority.High) 
     End Try 
    End Sub 

我可以生成在Silverlight應用程序服務參考就好了,但因爲該服務設置方式,我ServiceReferences.ClientConfig文件看起來像這樣:

<configuration /> 

我搜索和f回答這個問題的方法是向代理提供綁定和端點信息(http://tomasz.janczuk.org/2009/07/pubsub-sample-using-http-polling-duplex.html)。基於這個例子中,我試着寫:

昏暗_address作爲新的EndpointAddress( 「http://localhost:31313/ConsoleCustomerServicePortal」) 昏暗_binding作爲新WSDualHttpBinding()

昏暗_Client作爲新CustomerService.CsServiceReference.CustomerServiceClient(_binding,_address)

Dim _RequestType As CustomerService.CsServiceReference.VehicleSearchType = CsServiceReference.VehicleSearchType.Badge 
Dim strSearchValue As String = String.Empty 

... 

AddHandler _Client.GetVehicleCompleted, AddressOf OnFindVehicleCompleted 
_Client.GetVehicleAsync(CurrentUserName(), strSearchValue, _RequestType) 

但是,WSDualHttpBinding不在Silverlight 4程序集中。我錯過了什麼嗎?當我生成服務引用,在Silverlight應用程序中獲取對WSDualHttpBinding的引用,或者我應該切換到不同的綁定(PollingDuplexHttpBinding)時,如何獲取ServiceReferences.ClientConfig以填充?

回答

1

此綁定不在Silverlight框架中。只有最基本的綁定是。

0

WSDualHttpBinding類:

一個安全和可互操作的結合,設計用於與雙工服務合同的使用,使這兩種服務和客戶端發送和接收消息。

命名空間: System.ServiceModel
大會: System.ServiceModel(在System.ServiceModel.dll)

這是你在找什麼?

如果您添加對System.ServiceModel的引用,它應該可以工作。

+0

這很奇怪。我已經確定它在我的Silverlight 4應用程序中存在大約7次,並且它不在那裏。它引用的組件 C:\ Program Files文件\參考大會\微軟\框架\ Silverlight的\ V4.0 \ System.ServiceModel.dll ,而不是一個在: C:\ Program Files文件\參考大會\微軟\框架\ 3.0 \ System.ServiceModel.dll – Jasonthemasonkcch 2010-07-01 21:06:04

相關問題