Skip to content

Instantly share code, notes, and snippets.

@JoanComasFdz
JoanComasFdz / gist:1524311
Created December 27, 2011 16:45
Basic service endpoints declaration for services using wsDualHttpBinding
<services>
<service name="<YOUR_SERVICE_NAMESPACE.<YOUR_SERVICE_NAME">
<!--
Dual http binding
-->
<endpoint address=""
binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBinding_<YOUR_SERVICE_INTERFACE>"
contract="<YOUR_SERVICE_NAMESPACE.<YOUR_SERVICE_INTERFACE>">
<identity>
<dns value="localhost" />
@JoanComasFdz
JoanComasFdz / Program.cs
Created December 27, 2011 16:50
Host wcf service in console app basic code (using dual tcp to allow callbacks)
using System;
using System.ServiceModel;
using <YORU_SERVICE_NAMESPACE>;
namespace <YORU_APP_NAMESPACE>
{
class Program
{
static void Main(string[] args)
{
@JoanComasFdz
JoanComasFdz / Program.cs
Created December 27, 2011 16:50
Client for wcf service in console app basic code (using dual tcp to allow callbacks)
using System;
using System.ServiceModel;
using <YOUR_SERVICE_NAMESPACE>;
namespace <YOUR_APP_NAMESPACE>
{
/// <summary>
/// This class receives the callbacks from the server.
/// </summary>
public class CallbackGetter : <YOUR_SERVICE_CALLBACK_INTERFACE>
@JoanComasFdz
JoanComasFdz / gist:1524334
Created December 27, 2011 16:52
Basic wsDualHttpBinding
</bindings>
<wsDualHttpBinding>
<binding name="WSDualHttpBinding_<YOUR_SERVICE_INTERFACE>" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" />
@JoanComasFdz
JoanComasFdz / gist:1527148
Created December 28, 2011 08:47
Basic netTcpBinding
<netTcpBinding>
<binding name="DuplexNetTcpBinding_<YOUR_SERVICE_INTERFACE>"
sendTimeout="00:00:10"
portSharingEnabled="false">
</binding>
</netTcpBinding>
@JoanComasFdz
JoanComasFdz / gist:1527150
Created December 28, 2011 08:48
Basic service endpoints declaration for services using wsDualHttpBinding
<services>
<service name="<YOUR_SERVICE_NAMESPACE.<YOUR_SERVICE_NAME">
<!--
Dual http binding
-->
<endpoint address=""
binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBinding_<YOUR_SERVICE_INTERFACE>"
contract="<YOUR_SERVICE_NAMESPACE.<YOUR_SERVICE_INTERFACE>">
<identity>
<dns value="localhost" />
@JoanComasFdz
JoanComasFdz / gist:1527153
Created December 28, 2011 08:49
Basic service behaviour for netTcpBinding.
<serviceBehaviors>
<behavior name="Behaviour_<YOUR_SERVICE_INTERFACE>" >
<serviceMetadata />
</behavior>
</serviceBehaviors>
@JoanComasFdz
JoanComasFdz / Program.cs
Created December 28, 2011 08:50
Host wcf service in console app basic code (using dual tcp to allow callbacks)
using System;
using System.ServiceModel;
using <YOUR_SERVICE_NAMESPACE>;
namespace Host_Service_with_callbacks_via_tcp
{
class Program
{
static void Main(string[] args)
{
@JoanComasFdz
JoanComasFdz / Program.cs
Created December 28, 2011 08:50
Client for wcf service in console app basic code (using dual tcp to allow callbacks)
using System;
using System.ServiceModel;
using Client_Service_with_callbacks_via_tcp.<YOUR_SERVICE_NAME>;
namespace Client_Service_with_callbacks_via_tcp
{
class Program
{
/// <summary>
/// Handles the callbacks from the server following
@JoanComasFdz
JoanComasFdz / gist:1527187
Created December 28, 2011 09:01
Basic custom UserNamePasswordValidator implementation
public class CustomValidator : UserNamePasswordValidator
{
public override void Validate(string user_name, string password)
{
if (string.IsNullOrEmpty(user_name) || string.IsNullOrEmpty(password))
throw new SecurityTokenException("Username and password required");
if (!(user_name == "test" && password == "test"))
throw new SecurityTokenException("Wrong username or password.");
// Not throwing exceptions indicates