简体   繁体   中英

there was no endpoint listening at https://wserver:442/service1.svc

I am trying to setup a WCF Service with a self signed SSL.

I can browse to the HTTPS and it shows the meta data and I can create a service refernce.

however it throws the exception: There was no endpoint listening at https://wserver:442/service1.svc that could accept that message.

wserver is the name of my server, but I do not use it anywhere so I dont know where it is getting it from?

My Server Webhost.config (where i think the problem probably lies) is:

<?xml version="1.0"?>
<configuration>

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="Binding1">
          <security mode="TransportWithMessageCredential">
            <message clientCredentialType="UserName"/>
          </security>
        </binding>
      </wsHttpBinding>

    </bindings>
    <services>
      <service behaviorConfiguration="ServiceBehavior" name="AutoSenderWCFService.AutoSenderService">
        <endpoint binding="wsHttpBinding" bindingConfiguration="Binding1"
          contract="AutoSenderWCFService.IService1" />
        <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
      </service>
    </services>

    <behaviors>
      <serviceBehaviors>
        <behavior name="ServiceBehavior">
          <serviceCredentials>

            <userNameAuthentication userNamePasswordValidationMode="Custom"
              customUserNamePasswordValidatorType="AutoSenderWCFService.MyValidator, AutoSenderWCFService"/>

          </serviceCredentials>

          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="true"/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

</configuration>

Or maybe I made a mistake with the self signed SSL?

My Clientside is just:

    private void button1_Click(object sender, EventArgs e)
    {

        ServiceReference1.Service1Client client = new ServiceReference1.Service1Client();
        client.ClientCredentials.UserName.UserName = "test";
        client.ClientCredentials.UserName.Password = "testPassword";            
        ServiceReference1.Contact[] test = client.GetDrivers();

    }
}

There are a couple of reasons on why this happens. Since you have a default https that runs on 443 you are using port 442 for https for your service.

Have you performed any mapping about https listening on port 442? You can do it by using netsh command as shown below:

C:\> netsh http add sslcert ipport=0.0.0.0:442 certhash=6797aea29440de9389bc636e15a35b741d8c22a3 appid={2e80948d-9ae6-42c9-ad33-294929333965}

Your cert hash needs to be the thumbprint id and appid is the WCF project dll's hash id you would have in your assembly.cs file else create one and include before your build your project.

Next you have a mex endpoint defined which can be removed and change your serviceMetaData element to have httpsGetEnabled ="true" and httpGetEnabled="false"

Now make sure to browse to your service page and see if comes up fine.

Next in your client code before invoking the call to the WCF service you need to perform the below step to bypass the certificate validation check:

    System.Net.ServicePointManager.ServerCertificateValidationCallback = (sender, cert, chain, error) =>
                                                                             {
                                                                                 return true;
                                                                             };

The reason to use the above code is because you are using self signed certificate. If you have a certificate that has been issued by some trusted authority then you dont need to have the abovee code in your client app.

I changed HTTPSEnabled and HTTPEnabled property in WCF service on the server-side Web.Config file as shown above. It works fine without issuing "there was no endpoint listening at ... " problem. As the website requires SSL strictly, HTTPEnabled property should be set to false. Thanks for posting solutions in the above.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM