SEARCH:   GO
{Blog entries}
Jul 6

Written by: Javier Callico
7/6/2010  RssIcon

Two days ago I tried to deploy to a production environment a WCF service and got the following error:
 
System.ServiceModel.EndpointNotFoundException
There was no channel actively listening at 'http://somehostnameIdidntrecognize.local/services/myservice.svc'. This is often caused by an incorrect address URI. Ensure that the address to which the message is sent matches an address on which a service is listening.


What was this http://somehostnameIdidntrecognize.local host since my service was hosted at a completely different location? Could it be that this site was Load Balanced or Web Accelerated somehow by the hosting provider? The fact was that the service was receiving a completly different URL than the one I was typing on my browser.

After playing with the configuration for a while the following got the service working for my requirements which were:

  • Be able to access the service using SOAP, REST or JSON
  • Be available only under SSL.
  • Support ASP.NET sessions.
<system.servicemodel>
  <behaviors>
    <servicebehaviors>
      <behavior name="MyServiceBehavior">
        <servicemetadata httpgetenabled="true" httpsgetenabled="true">servicemetadata>
        <servicedebug includeexceptiondetailinfaults="true">servicedebug>
      behavior>
    servicebehaviors>
    <endpointbehaviors>
      <behavior name="restBehavior">
        <webhttp>webhttp>
      behavior>
      <behavior name="jsonBehavior">
        <enablewebscript>enablewebscript>
      behavior>
    endpointbehaviors>
  behaviors>
  <services>
    <service name="Callicode.Services.MyService" behaviorconfiguration="MyServiceBehavior">
      <endpoint address="soap" binding="basicHttpBinding" bindingconfiguration="SecureTransport" contract="Callicode.Services.MyIService">endpoint>
      <endpoint address="rest" binding="webHttpBinding" bindingconfiguration="SecureTransport" behaviorconfiguration="restBehavior" contract="Callicode.Services.MyIService">endpoint>
      <endpoint address="json" binding="webHttpBinding" bindingconfiguration="SecureTransport" behaviorconfiguration="jsonBehavior" contract="Callicode.Services.MyIService">endpoint>
    service>
  services>
  <servicehostingenvironment aspnetcompatibilityenabled="true">
    <baseaddressprefixfilters>
      <add prefix="http://somehostnameIdidntrecognize.local">add>
    baseaddressprefixfilters>
  servicehostingenvironment>
  <bindings>
    <basichttpbinding>
      <binding name="SecureTransport" maxbuffersize="2147483647" maxreceivedmessagesize="2147483647">
        <security mode="Transport">
          <transport clientcredentialtype="None">transport>
        security>
        <readerquotas maxdepth="2147483647" maxstringcontentlength="2147483647" maxarraylength="2147483647" maxbytesperread="2147483647" maxnametablecharcount="2147483647">readerquotas>
      binding>
    basichttpbinding>
    <webhttpbinding>
      <binding name="SecureTransport" maxbuffersize="2147483647" maxreceivedmessagesize="2147483647">
        <security mode="Transport">
          <transport clientcredentialtype="None">transport>
        security>
        <readerquotas maxdepth="2147483647" maxstringcontentlength="2147483647" maxarraylength="2147483647" maxbytesperread="2147483647" maxnametablecharcount="2147483647">readerquotas>
      binding>
    webhttpbinding>
  bindings>
system.servicemodel>

What is curious about this situation is that at this point I still don't know why the original URL of the service is getting replaced with this mysterious http://somehostnameIdidntrecognize.local address by the time the request reaches the service.

Tags: .NET , WCF , SSL
Categories:

Your name:
Gravatar Preview
Your email:
(Optional) Email used only to show Gravatar.
Your website:
Title:
Comment:
Add Comment   Cancel