无法让 WCF 配置与 https 配合使用

发布于 2024-11-27 16:15:58 字数 4025 浏览 2 评论 0 原文

我已经查看了有关此问题的许多不同问题和答复,但仍然找不到正确的解决方案。我有一个通过代码连接到的网络服务。 Web 服务已在开发计算机上启动并运行。我正在运行 IIS 7。我可以通过 IE 通过 http 和 https 地址连接到我的服务。从代码中我可以访问 http,但在尝试通过 https 访问时收到错误 404 无端点监听。这看起来很简单,但我显然错过了一些东西。

服务器 web.config 如下所示: (仅相对部分)

<system.serviceModel>
    <diagnostics>
      <messageLogging logEntireMessage="true" logMessagesAtServiceLevel="true"
        logMessagesAtTransportLevel="true" />
      <endToEndTracing activityTracing="true" />
    </diagnostics>
    <services>
      <service behaviorConfiguration="behaviorAction" name="CI.PCI.ServiceImplementations.SPPService">
        <endpoint address="" binding="basicHttpBinding" bindingConfiguration="HostBinding"
          contract="CI.PCI.ServiceContracts.ISPPService" listenUri="https://cisppdev.children.org/sppservices/sppservices.svc" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="behaviorAction">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <basicHttpBinding>
        <binding name="SafenetTokenServiceSoap11Binding" closeTimeout="00:01:00"
          openTimeout="00:01:00" receiveTimeout="00:30:00" sendTimeout="00:30:00"
          allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
          maxBufferSize="327680" maxBufferPoolSize="524288" maxReceivedMessageSize="327680"
          messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
          useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="Transport">
            <transport clientCredentialType="None" proxyCredentialType="None"
              realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
        <binding name="HostBinding" receiveTimeout="00:30:00" sendTimeout="00:30:00"
          bypassProxyOnLocal="true" maxBufferSize="327680" maxReceivedMessageSize="327680">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="Transport" />
        </binding>
      </basicHttpBinding>
    </bindings>
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>


From the client code I am dynamically creating a connection which basically goes like this:

BasicHttpBinding binding = new BasicHttpBinding();
url = Settings1.Default.DevURL; -- (https://cisppdev.children.org/sppservices/sppservices.svc)
binding.Security.Mode = BasicHttpSecurityMode.Transport;
EndpointAddress ep = new EndpointAddress(url);

                binding.OpenTimeout = new TimeSpan(0, 10, 0);
                binding.CloseTimeout = new TimeSpan(0, 10, 0);
                binding.ReceiveTimeout = new TimeSpan(0, 15, 0);
                binding.SendTimeout = new TimeSpan(0, 15, 0);
                binding.MaxBufferSize = 327680;
                binding.MaxReceivedMessageSize = 327680;
                binding.MaxBufferPoolSize = 524288;
                binding.TransferMode = TransferMode.Buffered;


                ChannelFactory<ServiceContracts.ISPPService> factory = new ChannelFactory<ServiceContracts.ISPPService>(binding, ep);

                factory.Open();

                ServiceContracts.ISPPService channel = factory.CreateChannel();

无论我尝试了什么,我似乎都找不到正确的配置来完成这项工作。我没有证书,我只想调用https服务而不是http。任何帮助将不胜感激!

谢谢

I have looked at many different questions and responses regarding this issue but still cannot find the right solution. I have a web service that I am connecting to via code. The webservice is up and running on a dev machine. I am running IIS 7. I can connect to my service through IE at both http and https addresses. From code I can access the http but I get an error 404 no endpoint listening when trying to access via https. This seems like it would be simple but I am missing something obviously.

SERVER web.config looks like:
(relative portions only)

<system.serviceModel>
    <diagnostics>
      <messageLogging logEntireMessage="true" logMessagesAtServiceLevel="true"
        logMessagesAtTransportLevel="true" />
      <endToEndTracing activityTracing="true" />
    </diagnostics>
    <services>
      <service behaviorConfiguration="behaviorAction" name="CI.PCI.ServiceImplementations.SPPService">
        <endpoint address="" binding="basicHttpBinding" bindingConfiguration="HostBinding"
          contract="CI.PCI.ServiceContracts.ISPPService" listenUri="https://cisppdev.children.org/sppservices/sppservices.svc" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="behaviorAction">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <basicHttpBinding>
        <binding name="SafenetTokenServiceSoap11Binding" closeTimeout="00:01:00"
          openTimeout="00:01:00" receiveTimeout="00:30:00" sendTimeout="00:30:00"
          allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
          maxBufferSize="327680" maxBufferPoolSize="524288" maxReceivedMessageSize="327680"
          messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
          useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="Transport">
            <transport clientCredentialType="None" proxyCredentialType="None"
              realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
        <binding name="HostBinding" receiveTimeout="00:30:00" sendTimeout="00:30:00"
          bypassProxyOnLocal="true" maxBufferSize="327680" maxReceivedMessageSize="327680">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="Transport" />
        </binding>
      </basicHttpBinding>
    </bindings>
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>


From the client code I am dynamically creating a connection which basically goes like this:

BasicHttpBinding binding = new BasicHttpBinding();
url = Settings1.Default.DevURL; -- (https://cisppdev.children.org/sppservices/sppservices.svc)
binding.Security.Mode = BasicHttpSecurityMode.Transport;
EndpointAddress ep = new EndpointAddress(url);

                binding.OpenTimeout = new TimeSpan(0, 10, 0);
                binding.CloseTimeout = new TimeSpan(0, 10, 0);
                binding.ReceiveTimeout = new TimeSpan(0, 15, 0);
                binding.SendTimeout = new TimeSpan(0, 15, 0);
                binding.MaxBufferSize = 327680;
                binding.MaxReceivedMessageSize = 327680;
                binding.MaxBufferPoolSize = 524288;
                binding.TransferMode = TransferMode.Buffered;


                ChannelFactory<ServiceContracts.ISPPService> factory = new ChannelFactory<ServiceContracts.ISPPService>(binding, ep);

                factory.Open();

                ServiceContracts.ISPPService channel = factory.CreateChannel();

No matter what I have tried I cannot seem to find the right configuration to make this work. I dont have a certificate, I just want to call https service rather than http. Any help would be appreciated!!

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文