简体   繁体   English

在https:// wserver:442 / service1.svc上没有侦听端点

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

I am trying to setup a WCF Service with a self signed SSL. 我正在尝试使用自签名SSL设置WCF服务。

I can browse to the HTTPS and it shows the meta data and I can create a service refernce. 我可以浏览到HTTPS,它显示了元数据,并且可以创建服务引用。

however it throws the exception: There was no endpoint listening at https://wserver:442/service1.svc that could accept that message. 但是,它引发了一个异常:在https://wserver:442/service1.svc上没有侦听终结点的端点可以接受该消息。

wserver is the name of my server, but I do not use it anywhere so I dont know where it is getting it from? wserver是我的服务器的名称,但是我不在任何地方使用它,所以我不知道它从哪里得到的?

My Server Webhost.config (where i think the problem probably lies) is: 我的服务器Webhost.config(我认为问题可能出在哪里)是:

<?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? 还是我对自签名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. 由于您具有在443上运行的默认https,因此您将端口442用于https的服务。

Have you performed any mapping about https listening on port 442? 您是否执行过有关在端口442上侦听https的映射? You can do it by using netsh command as shown below: 您可以使用netsh命令来做到这一点,如下所示:

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. 您的证书哈希值必须是指纹ID,而appid是WCF项目dll的哈希值ID,您将在Assembly.cs文件中拥有该哈希值,否则将在创建项目之前创建一个并包含它。

Next you have a mex endpoint defined which can be removed and change your serviceMetaData element to have httpsGetEnabled ="true" and httpGetEnabled="false" 接下来,您将定义一个可以删除的混合端点,并将httpsGetEnabled ="true"元素更改为具有httpsGetEnabled ="true"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: 接下来,在调用WCF服务的调用之前,在客户端代码中,您需要执行以下步骤来绕过证书验证检查:

    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. 我在服务器端Web.Config文件的WCF服务中更改了HTTPSEnabled和HTTPEnabled属性,如上所示。 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. 由于网站严格要求使用SSL,因此应将HTTPEnabled属性设置为false。 Thanks for posting solutions in the above. 感谢您在上面发布解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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