Use an HTTP binding with WCF.
Again, this is just a configuration change in our working WCF service.
Here’s the server’s app.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service name="WCFHost.FileService"
behaviorConfiguration="FileServiceMEXBehavior">
<endpoint address=""
binding="basicHttpBinding"
contract="FileServiceLib.IFileService"/>
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/FileService"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="FileServiceMEXBehavior">
<!-- Allows metadata to be viewed via a web
browser or other HTTP request -->
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
Note
To be able to enable an HTTP endpoint under Vista or Windows 7, you need to run this command as an administrator:
netsh http add urlacl url=http://+:PORT/user=MYMACHINE\UserName
Here’s an example:
netsh http add urlacl url=http://+:8080/ user=BEN-PC\Ben
The client’s app.config is shown next:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IFileService"
closeTimeout="00:01:00"
openTimeout="00:01:00"
receiveTimeout="00:10:00"
sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false"
hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288"
maxReceivedMessageSize="65536"
messageEncoding="Text"
textEncoding="utf-8"
transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192"
maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None"
proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName"
algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8080/FileService"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IFileService"
contract="IFileService"
name="BasicHttpBinding_IFileService" />
</client>
</system.serviceModel>
</configuration>