开发者

WCF Basics with a Windows Service

I am looking into WCF specifically in relation to Silverlight.

Can someone tell me if I am correct in thinking that I can create a WCF Service, and expose a TCP endpoint using a Windows Service that my Silverlight app can use?

I have managed to expose this using IIS but it would be good if we could bypass using IIS as some of our customers don't like it.

UPDATE...

OK I have created a WCF Service Library (RemoteClientLib with IRemoteClients defining my service contracts and RemoteClients Implementing this Interface) and a Windows Service to host it. I have added an App.config to both projects that looks like this:

<?xml version="1.0"?>
<configuration>
  <system.serviceModel>
    <services>
      <service name="RemoteClientLib.RemoteClients" behaviorConfiguration="remoteBehavior">
        <endpoint address="" binding="netTcpBinding" contract="RemoteClientLib.IRemoteClients" bindingConfiguration="remoteBinding"/>
        <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/>
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://localhost:4520/RemoteClients"/>
          </baseAddresses>
        </host>
      </service>

    </services>
    <bindings>
      <netTcpBinding>
        <binding name="remoteBinding"></binding>
      </netTcpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="remoteBehavior">
          <serviceMetadata/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
  <system.web>
    <compilation debug="true"/>
  </system.web>

  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
  </startup>
</configuration>

I created a project installer to install the service and started it up but when I try and add a service reference in my silverlight project I get 'No connection could be made because the ta开发者_开发问答rget machine actively refused it' Is there something I am missing?


This sample on codeproject.com I've used for self-hosting WCF services. It would be pretty straight forward to build it into a Windows service. Consider Topshelf as a Windows service framework too.


You can create a windows service that acts as your own host. Here is a link to the various methods available to hosting a WCF service.


You should be able to do so. Any of the bindings you can use while in IIS, you should be able to use with self-hosting.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜