|
-
July 20th, 2015, 04:11 PM
#1
Can a WCF service hosted in a Windows service questions
The only examples I've found of hosting a WCF service in a Windows service have the WCF service configured inside the Windows service's OnStart() method. I would think that would severely hamper the WCF service's flexibility. Is there some reason why the examples I've found do it that way?
The example I've been working with, http://www.codeproject.com/Articles/...indows-Service, uses svcutil to create a process class for a client project. But I saw something on one website that said that a proxy is not needed if the service and the client are going to be running on the same machine, which is my situation. Can someone point me to an example of building a WCF client without using a proxy?
I tried to replace the programmatic configuration of the service in the above article with configuration using app.config and a proxy, but I always get complaints about the service not being able to handle utf-8. It seems that the service is not able to handle messages in the format used by svcutil, but I don't know what svcutil uses. Here is my configuration file:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<services>
<service behaviorConfiguration="MetadataBehavior" name="WcfInWindowsService2.WcfService">
<endpoint address="http://localhost:9001/CalcService2"
binding="basicHttpBinding"
contract="WcfInWindowsService2.IWcfService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
<endpoint address="net.tcp://locahost:9002/CalcService2"
binding="netTcpBinding"
contract="WcfInWindowsService2.IWcfService" />
<endpoint address="net.tcp://localhost:9002/mex"
binding="mexTcpBinding"
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/Design_Time_Addresses/WcfInWindowsService2/Service1/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MetadataBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
Thank you very much.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|