title: WCF over SSL - 404 error
body: <p>Okay, I must be missing something utterly simple here, because I've been googling for days, and looking at dozens of answers there, and here on SO, and i just CANNOT get this to work, no matter what i've tried. The service works perfectly fine when called over plain HTTP. </p>
  
  <p>Here's our setup... we have a domain, <a href="http://www.mydomain.com" rel="noreferrer">http://www.mydomain.com</a> . We have an SSL certificate installed on that domain from thawte, just as we would if we were securing an e-commerce site. That all works fine, and i can go to http<strong>s</strong>://www.mydomain.com and it works right.
  I'm running VS2008, .NET 3.5 site on Windows Server 2003 R2.  </p>
  
  <p>Now, I added a Silverlight-enabled WCF service to my site, which i want to communicate with over SSL. If i browse to http<strong>s</strong>://www.mydomain.com/myservice.svc, it shows me the WSDL-descriptive "<strong>You have created a service</strong>" page as expected, which shows to create your client using </p>
  
  <pre><code>svcutil.exe https:// ... 
  </code></pre>
  
  <blockquote>
    <p><strong>EDIT:</strong> I realized the url shown for the svcutil in the wsdl file was actually pointing to the physical box name of the web server, not the proper domain. So i went through the steps shown in <em><a href="http://www.codemeit.com/wcf/wcf-wsdl-xsdimport-schemalocations-link-to-local-machine-name-not-domain-name-while-hosted-in-iis.html" rel="noreferrer">this blog posting</a></em> to update the SecureBinding of the website in IIS using the adsutil script. Now the wsdl file shows the correct SSL address, but i still get the same error. </p>
  </blockquote>
  
  <p>Now i went and tried to hook my Silverlight app up to it, and it does not work, returning an exception in the result from the async calls, stating "<strong>The remote server returned an error: NotFound</strong>. A number of the blogs i've read talked about narrowing it down to Silverlight issues by creating a test Windows application, and trying to reference it from that. Well, I did that and even in a regular windows application trying to access the service over SSL i get an exception stating: </p>
  
  <pre><code>System.ServiceModel.EndpointNotFoundException: 
  There was no endpoint listening at https://www.mydomain.com/mysubdir/myservice.svc that could accept the message. 
  This is often caused by an incorrect address or SOAP action. 
  See InnerException, if present, for more details. ---&gt; 
  System.Net.WebException: The remote server returned an error: (404) Not Found.
  at System.Net.HttpWebRequest.GetResponse()
  at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
  </code></pre>
  
  <p>This despite the fact that i explicitly added the service reference to the Windows app using the HTTPS scheme and it properly gets all the methods and shows them in Intellisense in the editor.</p>
  
  <p>Note that this is a service which does NOT require explicit log in on the user's part. I am going to be sending custom headers in my SOAP envelopes to verify that the requests are coming from our app, and I just want to keep predators from sniffing the line and picking out the custom headers. </p>
  
  <p>Now to the code, where i must just have some stupid little setting wrong, because from all i've read, this should be a fairly straightforward exercise. </p>
  
  <p>First, my service's code-behind class is decorated with the following attributes: </p>
  
  <pre><code>&lt;ServiceBehavior(AddressFilterMode:=AddressFilterMode.Any)&gt; 
  &lt;AspNetCompatibilityRequirements(RequirementsMode:=AspNetCompatibilityRequirementsMode.Allowed)&gt;
  </code></pre>
  
  <p>The ServiceModel section of my web.config on the server looks like so: </p>
  
  <pre><code>&lt;system.serviceModel&gt;
      &lt;bindings&gt;
          &lt;basicHttpBinding&gt;
              &lt;binding name="basicHttpBinding"&gt;
                  &lt;security mode="Transport"&gt;
                      &lt;transport clientCredentialType ="None"/&gt;
                  &lt;/security&gt;
              &lt;/binding&gt;
          &lt;/basicHttpBinding&gt;
      &lt;/bindings&gt;
      &lt;behaviors&gt;
          &lt;serviceBehaviors&gt;
              &lt;behavior name="standingsBehavior"&gt;
                  &lt;serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/&gt;
                      &lt;serviceDebug includeExceptionDetailInFaults="false"/&gt;
                  &lt;/behavior&gt;
              &lt;/serviceBehaviors&gt;
      &lt;/behaviors&gt;
      &lt;serviceHostingEnvironment aspNetCompatibilityEnabled="true"&gt;
          &lt;baseAddressPrefixFilters&gt;
              &lt;add prefix="http://www.mydomain.com:80"/&gt;
          &lt;/baseAddressPrefixFilters&gt;
      &lt;/serviceHostingEnvironment&gt;
      &lt;services&gt;
          &lt;service behaviorConfiguration="standingsBehavior" name="lijslwebdata"&gt;
              &lt;endpoint address="" binding="basicHttpBinding" contract="lijslwebdata"/&gt;
              &lt;!--&lt;endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/&gt;--&gt;
          &lt;/service&gt;
      &lt;/services&gt;
  &lt;/system.serviceModel&gt;
  </code></pre>
  
  <p>And the ServiceModel section of the app.config in my Windows application looks like the following: </p>
  
  <pre><code>&lt;system.serviceModel&gt;
      &lt;bindings&gt;
          &lt;basicHttpBinding&gt;
              &lt;binding name="BasicHttpBinding_lijslwebdata" 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"&gt;
                  &lt;readerQuotas maxDepth="32" maxStringContentLength="8192"
                      maxArrayLength="16384"
                      maxBytesPerRead="4096" maxNameTableCharCount="16384" /&gt;
                  &lt;security mode="Transport"&gt;
                      &lt;transport clientCredentialType="None" proxyCredentialType="None" realm=""/&gt;
                      &lt;message clientCredentialType="UserName" algorithmSuite="Default" /&gt;
                  &lt;/security&gt;
              &lt;/binding&gt;
          &lt;/basicHttpBinding&gt;
      &lt;/bindings&gt;
      &lt;client&gt;
          &lt;endpoint address="https://www.mydomain.com/mysubdir/myservice.svc"
              binding="basicHttpBinding" 
              bindingConfiguration="BasicHttpBinding_lijslwebdata"
              contract="xdata.lijslwebdata" name="BasicHttpBinding_lijslwebdata" /&gt;
      &lt;/client&gt;
  &lt;/system.serviceModel&gt;
  </code></pre>