<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Phil Henning's WebLog</title><link>http://blogs.msdn.com/b/phenning/</link><description /><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>Silverlight Web Services Team Blog</title><link>http://blogs.msdn.com/b/phenning/archive/2008/03/07/silverlight-web-services-team-blog.aspx</link><pubDate>Fri, 07 Mar 2008 21:58:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8104751</guid><dc:creator>Phil Henning</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/phenning/rsscomments.aspx?WeblogPostID=8104751</wfw:commentRss><comments>http://blogs.msdn.com/b/phenning/archive/2008/03/07/silverlight-web-services-team-blog.aspx#comments</comments><description>For those interested in WCF development on Silverlight, the Silverlight Web Services team just set up a &lt;A class="" href="http://blogs.msdn.com/silverlightws" mce_href="http://blogs.msdn.com/silverlightws"&gt;team blog&lt;/A&gt;.&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8104751" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/phenning/archive/tags/WCF/">WCF</category><category domain="http://blogs.msdn.com/b/phenning/archive/tags/Silverlight/">Silverlight</category></item><item><title>Custom transport channels and BindingElements</title><link>http://blogs.msdn.com/b/phenning/archive/2008/01/14/removing-the-message-encoding-binding-element-from-the-binding-context.aspx</link><pubDate>Mon, 14 Jan 2008 19:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7080072</guid><dc:creator>Phil Henning</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/phenning/rsscomments.aspx?WeblogPostID=7080072</wfw:commentRss><comments>http://blogs.msdn.com/b/phenning/archive/2008/01/14/removing-the-message-encoding-binding-element-from-the-binding-context.aspx#comments</comments><description>&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-themecolor: dark2"&gt;When&amp;nbsp;creating a custom transport channel, you must be sure to remove the&amp;nbsp;encoding binding element from the binding context before&amp;nbsp;returning from your BuildChannelFactory and BuildChannelListener calls. The best place to do this is within the constructor for your transport channel factory or listener.&lt;/SPAN&gt;&lt;/P&gt;&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;&lt;PRE class=csharpcode&gt;MessageEncodingBindingElement encodingBindingElement = context.BindingParameters.Remove&amp;lt;MessageEncodingBindingElement&amp;gt;();&lt;/PRE&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-themecolor: dark2"&gt;Its needs to be removed because there is a validation step that is performed after the channel stack has been fully created. If there are binding elements left in the stack, an InvalidOperaionException will be thrown from Binding.BuildChannelFactory or Binding.BuildChannelListener.&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-themecolor: dark2"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-themecolor: dark2"&gt;Also, be aware if you are building a custom encoder; be sure to add your MessageEncodingBindingElement back to the BindingContext before returning from your BuildChannelListener/BuildChannelFactory methods of your MessageEncodingBindingElement back so that the transport is able to create your encoder.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;&lt;PRE class=csharpcode&gt;context.BindingParameters.Add(&lt;SPAN class=kwrd&gt;this&lt;/SPAN&gt;); &lt;/PRE&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=7080072" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/phenning/archive/tags/WCF/">WCF</category></item><item><title>Custom UserNamePassword Validators in .Net Framework 3.5</title><link>http://blogs.msdn.com/b/phenning/archive/2008/01/11/custom-usernamepassword-validators-in-net-framework-3-5.aspx</link><pubDate>Sat, 12 Jan 2008 00:29:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7079764</guid><dc:creator>Phil Henning</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/phenning/rsscomments.aspx?WeblogPostID=7079764</wfw:commentRss><comments>http://blogs.msdn.com/b/phenning/archive/2008/01/11/custom-usernamepassword-validators-in-net-framework-3-5.aspx#comments</comments><description>&lt;P&gt;In the version of WCF that shipped with .Net Framework 3.0 we didn't support custom validators with transport level HTTP security. We received much feedback from the community that this was a highly desired feature, so I'm happy to say we added support for this scenario in the 3.5 release of the .Net Framework. &lt;/P&gt;
&lt;P&gt;Note that this is only supported under self hosted services. &lt;/P&gt;
&lt;P&gt;Here is what you'll need to do to get it to work: &lt;/P&gt;
&lt;P&gt;1. Create your validator: &lt;/P&gt;&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;namespace&lt;/SPAN&gt; Sample
{
   &lt;SPAN class=kwrd&gt;using&lt;/SPAN&gt; System.ServiceModel;
   &lt;SPAN class=kwrd&gt;using&lt;/SPAN&gt; System.IdentityModel.Selectors;
   &lt;SPAN class=kwrd&gt;using&lt;/SPAN&gt; System.ServiceModel.Security;

   &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;class&lt;/SPAN&gt; CustomUserNameValidator : UserNamePasswordValidator
   {
       &lt;SPAN class=rem&gt;// This method validates users. It allows in two users, test1 and test2 &lt;/SPAN&gt;
       &lt;SPAN class=rem&gt;// with passwords 1tset and 2tset respectively.&lt;/SPAN&gt;
       &lt;SPAN class=rem&gt;// This code is for illustration purposes only and &lt;/SPAN&gt;
       &lt;SPAN class=rem&gt;// must not be used in a production environment because it is not secure. &lt;/SPAN&gt;
       &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;override&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;void&lt;/SPAN&gt; Validate(&lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt; userName, &lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt; password)
       {
           &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (&lt;SPAN class=kwrd&gt;null&lt;/SPAN&gt; == userName || &lt;SPAN class=kwrd&gt;null&lt;/SPAN&gt; == password)
           {         
               &lt;SPAN class=kwrd&gt;throw&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; ArgumentNullException();
           }

           &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (!(userName == &lt;SPAN class=str&gt;"test1"&lt;/SPAN&gt; &amp;amp;&amp;amp; password == &lt;SPAN class=str&gt;"1tset"&lt;/SPAN&gt;) &amp;amp;&amp;amp; !(userName == &lt;SPAN class=str&gt;"test2"&lt;/SPAN&gt; &amp;amp;&amp;amp; password == &lt;SPAN class=str&gt;"2tset"&lt;/SPAN&gt;))
           {
               &lt;SPAN class=kwrd&gt;throw&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; SecurityTokenException(&lt;SPAN class=str&gt;"Unknown Username or Incorrect Password"&lt;/SPAN&gt;);
           }
      }
   }
}

&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;2. Configure your service; you'll want to use Transport security and Basic clientCredentialType, this way the authentication header will be protected by SSL. &lt;/P&gt;
&lt;P&gt;Configuration for the binding and behavior: &lt;/P&gt;&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;bindings&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
 &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;wsHttpBinding&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
  &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;binding&lt;/SPAN&gt; &lt;SPAN class=attr&gt;name&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="BasicAuthentication"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
   &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;security&lt;/SPAN&gt; &lt;SPAN class=attr&gt;mode&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="Transport"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;transport&lt;/SPAN&gt; &lt;SPAN class=attr&gt;clientCredentialType&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="Basic"&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;
   &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;security&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
  &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;binding&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
 &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;wsHttpBinding&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;bindings&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;


&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;behaviors&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
 &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;serviceBehaviors&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
  &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;behavior&lt;/SPAN&gt; &lt;SPAN class=attr&gt;name&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="CustomUserNamePassword"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
   &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;serviceCredentials&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;userNameAuthentication&lt;/SPAN&gt; 
     &lt;SPAN class=attr&gt;userNamePasswordValidationMode&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="Custom"&lt;/SPAN&gt; 
     &lt;SPAN class=attr&gt;customUserNamePasswordValidatorType&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="Sample.CustomUserNameValidator, assemblyName"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;
   &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;serviceCredentials&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
  &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;behavior&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
 &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;serviceBehaviors&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;behaviors&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&lt;/PRE&gt;
&lt;P&gt;You can also add the custom validator through code: &lt;/P&gt;&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;&lt;PRE class=csharpcode&gt;host.Credentials.UserNameAuthentication.CustomUserNamePasswordValidator = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; CustomUserNameValidator();
host.Credentials.UserNameAuthentication.UserNamePasswordValidationMode = UserNamePasswordValidationMode.Custom;

&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: Courier New"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=7079764" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/phenning/archive/tags/WCF/">WCF</category></item><item><title>Client IP addresses in Orcas</title><link>http://blogs.msdn.com/b/phenning/archive/2007/08/08/remoteendpointmessageproperty-in-wcf-net-3-5.aspx</link><pubDate>Thu, 09 Aug 2007 01:08:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4298421</guid><dc:creator>Phil Henning</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/phenning/rsscomments.aspx?WeblogPostID=4298421</wfw:commentRss><comments>http://blogs.msdn.com/b/phenning/archive/2007/08/08/remoteendpointmessageproperty-in-wcf-net-3-5.aspx#comments</comments><description>&lt;P&gt;As Nicholas &lt;A class="" href="http://blogs.msdn.com/drnick/archive/2007/09/10/more-about-client-ip-addresses.aspx" mce_href="http://blogs.msdn.com/drnick/archive/2007/09/10/more-about-client-ip-addresses.aspx"&gt;promised&lt;/A&gt;, here is&amp;nbsp;some more information about client IP address in Orcas.&lt;/P&gt;
&lt;P&gt;In the Orcas release of WCF, we added the ability for services to get the IP address and port of the calling client from your service methods when the underlying transport is Http or Tcp. &lt;/P&gt;
&lt;P&gt;You can access the address and port as follows: &lt;/P&gt;&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;namespace&lt;/SPAN&gt; Sample
{
    &lt;SPAN class=kwrd&gt;using&lt;/SPAN&gt; System;
    &lt;SPAN class=kwrd&gt;using&lt;/SPAN&gt; System.ServiceModel;
    &lt;SPAN class=kwrd&gt;using&lt;/SPAN&gt; System.ServiceModel.Channels;
    &lt;SPAN class=kwrd&gt;using&lt;/SPAN&gt; System.Net;

    [ServiceContract]
    &lt;SPAN class=kwrd&gt;interface&lt;/SPAN&gt; IMyService
    {
        [OperationContract]
        &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt; ProcessUntyped(Message message);
        [OperationContract]
        &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt; ProcessTyped(&lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt; str);
    }

    &lt;SPAN class=kwrd&gt;class&lt;/SPAN&gt; MyService : IMyService
    {
        &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt; ProcessUntyped(Message message)
        {
            RemoteEndpointMessageProperty endpoint = message.Properties[RemoteEndpointMessageProperty.Name] &lt;SPAN class=kwrd&gt;as&lt;/SPAN&gt; RemoteEndpointMessageProperty;
            &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt;.Format(&lt;SPAN class=str&gt;"Connected from {0}:{1}"&lt;/SPAN&gt;, str, endpoint.Address, endpoint.Port);
        }

        &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt; ProcessTyped(&lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt; str)
        {
            OperationContext context = OperationContext.Current;
            MessageProperties properties = context.IncomingMessageProperties;
            RemoteEndpointMessageProperty endpoint = properties[RemoteEndpointMessageProperty.Name] &lt;SPAN class=kwrd&gt;as&lt;/SPAN&gt; RemoteEndpointMessageProperty;
            &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt;.Format(&lt;SPAN class=str&gt;"You said: '{0}'. Connected from {1}:{2}"&lt;/SPAN&gt;, str, endpoint.Address, endpoint.Port);
        }
    }
}&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: Courier New"&gt;&lt;FONT face=Arial size=2&gt;Note, if you are using the channel model directly, you can just look at Message.IncomingMessageProperties for the RemoteEndpointMessageProperty&lt;/FONT&gt;&lt;/P&gt;&lt;/SPAN&gt;
&lt;P&gt;If you are developing your own transport channel, you can attach the property to messages received through your transport channel: &lt;/P&gt;&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; RemoteEndpointMessageProperty(&lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt; address, &lt;SPAN class=kwrd&gt;int&lt;/SPAN&gt; port); &lt;/PRE&gt;
&lt;P&gt;The address specified must be a non zero-length sting and the port should be from 0-65535. &lt;/P&gt;
&lt;P&gt;Some additional things to consider: &lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;The IP address and port are as reported from the underlying socket or http.sys and is from the connected machine, so it may be a proxy address. &lt;/LI&gt;
&lt;LI&gt;We don't do any sort of spoof detection, so be careful about using the IP for any sort of security decisions. &lt;/LI&gt;
&lt;LI&gt;For all transports other then http and net.tcp the property will not be on the message. &lt;/LI&gt;
&lt;LI&gt;If you are using composite duplex, the property will be available on the client on replies from the service. &lt;/LI&gt;&lt;/OL&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=4298421" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/phenning/archive/tags/WCF/">WCF</category></item><item><title>Accessing the Http Query String from a service method.</title><link>http://blogs.msdn.com/b/phenning/archive/2007/06/22/accessing-the-http-query-string-from-a-service-method.aspx</link><pubDate>Sat, 23 Jun 2007 00:40:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3468156</guid><dc:creator>Phil Henning</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/phenning/rsscomments.aspx?WeblogPostID=3468156</wfw:commentRss><comments>http://blogs.msdn.com/b/phenning/archive/2007/06/22/accessing-the-http-query-string-from-a-service-method.aspx#comments</comments><description>&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;I'm trying to access the query string used by the client when contacting my service. How can I do this?&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: Times New Roman"&gt; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;You can access the query string through the HttpRequestMessageProperty.&lt;/P&gt;&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;&lt;PRE class=csharpcode&gt;OperationContext context = OperationContext.Current;
MessageProperties properties = context.IncomingMessageProperties;

HttpRequestMessageProperty requestProperty = properties[HttpRequestMessageProperty.Name] &lt;SPAN class=kwrd&gt;as&lt;/SPAN&gt; HttpRequestMessageProperty;

&lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt; queryString = requestProperty.QueryString; 
&lt;/PRE&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=3468156" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/phenning/archive/tags/WCF/">WCF</category></item><item><title>Securing WCF to only respond to local requests.</title><link>http://blogs.msdn.com/b/phenning/archive/2006/10/31/securing-wcf-to-only-respond-to-local-requests.aspx</link><pubDate>Wed, 01 Nov 2006 02:45:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:916194</guid><dc:creator>Phil Henning</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/phenning/rsscomments.aspx?WeblogPostID=916194</wfw:commentRss><comments>http://blogs.msdn.com/b/phenning/archive/2006/10/31/securing-wcf-to-only-respond-to-local-requests.aspx#comments</comments><description>&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;Is it possible to secure a web service to only respond to local requests over HTTP?&lt;/STRONG&gt;&lt;BR&gt;&lt;BR&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Yes, you just need to make sure that you listen at http://127.0.0.1/MyService/ with HostNameComparisonMode = Exact.&lt;/P&gt;&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;&lt;PRE class=csharpcode&gt;ServiceHost service = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; ServiceHost(&lt;SPAN class=kwrd&gt;typeof&lt;/SPAN&gt;(MyService), &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; Uri(&lt;SPAN class=str&gt;"http://127.0.0.1/MyService/"&lt;/SPAN&gt;));
BasicHttpBinding binding = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; BasicHttpBinding();
binding.HostNameComparisonMode = HostNameComparisonMode.Exact;
service.AddServiceEndpoint(&lt;SPAN class=kwrd&gt;typeof&lt;/SPAN&gt;(IMyService), binding , &lt;SPAN class=str&gt;"BasicEndpoint"&lt;/SPAN&gt;);&lt;/PRE&gt;
&lt;P mce_keep="true"&gt;&lt;FONT size=2&gt;Also, be sure to run httpcfg or netsh http&amp;nbsp;add urlacl with&amp;nbsp;the&amp;nbsp;127.0.0.1 address.&amp;nbsp;&amp;nbsp;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=916194" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/phenning/archive/tags/WCF/">WCF</category></item><item><title>Changing BindingElement settings on a Binding.</title><link>http://blogs.msdn.com/b/phenning/archive/2006/05/15/changing-bindingelement-settings-on-a-binding.aspx</link><pubDate>Mon, 15 May 2006 21:03:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:598185</guid><dc:creator>Phil Henning</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/phenning/rsscomments.aspx?WeblogPostID=598185</wfw:commentRss><comments>http://blogs.msdn.com/b/phenning/archive/2006/05/15/changing-bindingelement-settings-on-a-binding.aspx#comments</comments><description>&lt;BR&gt;&lt;SPAN style="mso-bidi-font-size: 11.0pt; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri"&gt;&lt;FONT size=3&gt;&lt;FONT color=#000000&gt;&lt;FONT face=Calibri&gt;We don’t allow you to modify the properties of the binding directly, but you can create a copy of the binding elements used to create a particular binding, alter the desired properties, then use the binding element collection to create a new custom binding.&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&amp;nbsp; &lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;&lt;PRE class=csharpcode&gt;BasicHttpBinding basicBinding = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; BasicHttpBinding();
BindingElementCollection bindingElementCollection = basicBinding.CreateBindingElements();
bindingElementCollection.Find&amp;lt;HttpTransportBindingElement&amp;gt;().KeepAliveEnabled = &lt;SPAN class=kwrd&gt;false&lt;/SPAN&gt;;
CustomBinding myBasicBinding = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; CustomBinding(bindingElementCollection);
&lt;/PRE&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;PRE&gt;&lt;/PRE&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=598185" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/phenning/archive/tags/WCF/">WCF</category></item></channel></rss>