WEBSITE

Communicate over the Internet (WCF)

9/26/2010 7:52:54 PM
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>


Other  
 
Most View
MSI GX60 Review - Radeon HD 7970M In A $1,200 Gaming Notebook (Part 2)
Silverlight : Binding Across Elements
Graphics Card Shootout - Budget FPS (Part 4)
Tablet Operating Systems (Part 2)
Durable Fashionable Soul SL150 Headphone Review
Nvidia GeForce GTX 690 4GB - Ridiculously Fast, But Expensive
Windows Server 2008 R2 networking : Planning and Deploying a TCP/IP Network Infrastructure (part 2) - Policy-based QoS
Make Your Films DVD Friendly With Markers
NZXT H440 Semi-silent-themed Case
Create A Virtual Machine
Top 10
Sharepoint 2013 : Farm Management - Disable a Timer Job,Start a Timer Job, Set the Schedule for a Timer Job
Sharepoint 2013 : Farm Management - Display Available Timer Jobs on the Farm, Get a Specific Timer Job, Enable a Timer Job
Sharepoint 2013 : Farm Management - Review Workflow Configuration Settings,Modify Workflow Configuration Settings
Sharepoint 2013 : Farm Management - Review SharePoint Designer Settings, Configure SharePoint Designer Settings
Sharepoint 2013 : Farm Management - Remove a Managed Path, Merge Log Files, End the Current Log File
SQL Server 2012 : Policy Based Management - Evaluating Policies
SQL Server 2012 : Defining Policies (part 3) - Creating Policies
SQL Server 2012 : Defining Policies (part 2) - Conditions
SQL Server 2012 : Defining Policies (part 1) - Management Facets
Microsoft Exchange Server 2010 : Configuring Anti-Spam and Message Filtering Options (part 4) - Preventing Internal Servers from Being Filtered