views:

17

answers:

2

I'm trying to connect to an existing Windows Service that exposes several WCF endpoints. The one I'm concerned with is the one the Silverlight 4 application will talk to. Here is the Service's config file (at least the sections we're concerned with):

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

The service is self hosted, and the following starts the service host:

 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

I can generate the service reference in the Silverlight application just fine, though because of the way the service is set up, my ServiceReferences.ClientConfig file looks like this:

<configuration />

I searched and found the way around this is to provide binding and endpoint information to the proxy (http://tomasz.janczuk.org/2009/07/pubsub-sample-using-http-polling-duplex.html). Based on that example, I tried writing:

Dim _address As New EndpointAddress("http://localhost:31313/ConsoleCustomerServicePortal") Dim _binding As New WSDualHttpBinding()

Dim _Client As New 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)

However, WSDualHttpBinding is not in the Silverlight 4 Assembly. Am I missing something? How can I either get the ServiceReferences.ClientConfig to be populated when I generate a service reference, get a reference to WSDualHttpBinding in the Silverlight app, or should I switch to a different binding (PollingDuplexHttpBinding)?

A: 

WSDualHttpBinding Class:

A secure and interoperable binding that is designed for use with duplex service contracts that allows both services and clients to send and receive messages.

Namespace: System.ServiceModel
Assembly: System.ServiceModel (in System.ServiceModel.dll)

Is this what you're looking for?

If you add a reference to System.ServiceModel it should then work.

ChrisF
This is very strange. I've made sure that it's there about 7 times in my Silverlight 4 application, and it's not there. It references the assembly in c:\Program Files\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0\System.ServiceModel.dll and not the one in:C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\System.ServiceModel.dll
Jasonthemasonkcch
+1  A: 

This Binding is not in the Silverlight Framework. Only the most basic bindings are.

Jasonthemasonkcch