Click here to Skip to main content
15,920,438 members
Please Sign up or sign in to vote.
4.33/5 (2 votes)
I've got a few problems configuring an ASP.NET Webapplication which hosts a WCF Service. And I've been searching quite a while now. There are quite a lot of results to be honest, and I'm not an expert with WCF. Mostly the solutions are either for the wsHttpBinding (which i don't use) or showing ErrorMessages not associated with the one I get.

This is what I want to accomplish:
Access the WCF Service only through https binding on specific port (eg. "https://example.org:5555/MyService.svc")

This is my current problem:
I can successfully access the service at "https://example.org:5555/MyService.svc"
BUT
I have to configure a http binding in IIS7.5 (it's sufficient if it points to the localhost and a nonsense port as long as it's configured...)

The error Message when making a get request on MyService.svc (with CustomErrors="Off")
Service 'CustomNamespace.MyService' has zero application (non-infrastructure) endpoints. This might be because no configuration file was found for your application, or because no service element matching the service name could be found in the configuration file, or because no endpoints were defined in the service element.


I do understand from that, that there might be some configuration missing. However why should it work if http and https binding in IIS are present, but not if only https binding is present?

My Question:
What are the steps necessary to be able to remove the http binding?


Any help will be truly appreciated :)

Additional Info:
- The service works fine on IIS 7.5. if a https binding (e.g. ip "All Unassigned" and port 5555) AND http binding (e.g. ip "::1"(localhost) and port 55555) are configured for the site.
- As soon as I do either of the following steps in IIS. The application stops working:
- Remove the http binding
- Set "Require SSL" in IIS -> "SSL Settings" to true.

Contents of ConfigFile:
XML
<?xml version="1.0"?>
<configuration>
   <system.serviceModel>
      <bindings>
         <basicHttpBinding>
            <binding>
               <security mode="Transport">
                  <transport clientCredentialType="None" />
               </security>
            </binding>
         </basicHttpBinding>
      </bindings>
      <behaviors>
         <serviceBehaviors>
            <behavior>
               <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" />
               <serviceDebug includeExceptionDetailInFaults="false" />
            </behavior>
         </serviceBehaviors>
      </behaviors>
      <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
   </system.serviceModel>
</configuration>


Content of MyService.svc (simplified):

XML
<%@ ServiceHost Service="CustomNamespace.MyServiceImpl" %>


Content of "MyServiceImpl.cs" (simplified)
C#
namespace CustomNamespace {   

   public interface IMyService {

      [OperationContract(Name = "doSomething", Action = "", ReplyAction = "*")]
      [XmlSerializerFormat]
      CustomReplyType DoSomething(CustomType request)

   }

   public class MyServiceImpl : IMyService {

      public CustomReplyType DoSomething(CustomType request) {
         // Do Stuff
         return new CustomReplyType();
      }

   }

}
Posted
Updated 15-Dec-22 18:30pm

You said you've tried a few things, have you read this article and tried its approach?

Seven simple steps to enable HTTPS on WCF WsHttp bindings[^]
 
Share this answer
 
Comments
Nicholas Marty 7-May-13 14:06pm    
Hm. I'm not looking for enabling https (which is working) but disabling http (with that meaning the unsecured connection) ;). Also this article seems more to address iis6 on a local machine than wcf and ssl in general. Will still take a look at it. :)
Thank you, I've been trying to figure this out all day. Your comment about require ssl clued me in. Yes, I need both http and https bindings in iis for webHttpBinding, in my case, to work, so I set those up as normal port 80 and port 443 web sites, allowing All Unassigned access, but by setting Require SSL (check box) it forces people to use https, with the side benefit that if the person does access http they will get a friendly or not so friendly message indicating that it is a secure web site or a 403 - Forbidden: Access is denied message.

btw, i see in your http binding you have five 5's (55555) instead of four 5's (5555) as you have in your https binding.
 
Share this answer
 
Comments
Richard Deeming 16-Dec-22 8:15am    
If you want to reply to a solution, click the "Have a Question or Comment?" button under that solution and post a comment. Do not post your comment as another "solution".

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900