WCF服务通过https运行 [英] WCF service to run via https

查看:187
本文介绍了WCF服务通过https运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能这个问题之前被问过无数次,但是由于无法解决我的问题,因此发布了这个问题.

好吧,我的要求很简单,我需要在https下运行我的服务.我创建了一个普通的WCF服务,该服务返回当前日期和时间以及传递的字符串.

当我通过浏览器在http.
下查看Service.svc文件时,它工作得很好.
为了使服务与https兼容,我对web.config进行了一些更改,并在本地IIS中创建了一个证书.

以下是我的web.config文件

Hi,
May be this question is asked numerous times before, but since I could not get it my problem solved, hence posting this question.

Well my requirement is simple, I need to run my service under https. I created a normal WCF service which returns the current date and time along with the string passed.

It works pretty well when i view the Service.svc file over a browser under http.

I did some changes to my web.config in order to make the service compatible for https and also created a certificate in my local IIS.

Below is my web.config file

<system.serviceModel>
<services>
  <service name="Service" behaviorConfiguration="ServiceBehavior">
    <!-- Service Endpoints -->
    <endpoint address="" binding="wsHttpBinding" bindingConfiguration="customHttp" contract="IService">

      <identity>
        <dns value="localhost"/>
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="ServiceBehavior">
     <serviceMetadata httpsGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<bindings>
  <wsHttpBinding>
    <binding name="customHttp">
      <security mode="Transport">
        <transport clientCredentialType="None"/>
      </security>
    </binding>
  </wsHttpBinding>
</bindings>



我创建了一个新的wsHttpBinding绑定,其安全模式为传输方式,并将绑定配置附加到首选端点.

当我尝试在浏览器中浏览service.svc文件时,它显示:

找不到与具有绑定WSHttpBinding的端点的方案https匹配的基地址.注册的基址方案为[http].

我在端点的地址部分中将服务URL设置为"http://[localhost:54110]/samplewcf/Service.svc",然后我开始收到如下错误:

找不到与绑定MetadataExchangeHttpsBinding的端点匹配方案https的基地址.注册的基址方案为[http].

我试图将wsHttpBinding更改为basicHttpBinding和webHttpBinding,但是它不起作用.我收到上述错误.

由于我使用IIS中的服务器证书手动创建了证书,因此我可以通过https浏览localhost,但是我的服务无法在https下运行.我在Stack Overflow中浏览了许多帖子,也浏览了许多博客,但是找不到解决方法.

专家们请帮我.任何指针将不胜感激.

问候

Anurag



I have created a new wsHttpBinding binding with security mode as transport and attached the binding configuration to the preferred endpoint.

When I try to browse the service.svc file in the browser, it says:

Could not find a base address that matches scheme https for the endpoint with binding WSHttpBinding. Registered base address schemes are [http].

I gave the service URL in the address portion of the endpoint as ''http://[localhost:54110]/samplewcf/Service.svc'', then I started getting the error as:

Could not find a base address that matches scheme https for the endpoint with binding MetadataExchangeHttpsBinding. Registered base address schemes are [http].

I tried to change the wsHttpBinding to basicHttpBinding and webHttpBinding, but it doesn''t work. I get the above errors.

Since I manually created a certificate using Server Certificates in IIS, i am able to browse localhost over https, but my service does not run under https. I went throught numerous posts in Stack Overflow and many blogs too, but couldn''t find the resolution.

Experts kindly assist me. Any pointers would be highly appreciated.

Regards

Anurag

推荐答案

首先,您尚未将端点设置为https,而是写为http.

其次,https保留用于端口433.

因此,我认为您无法在端口54110上使用https.不能在IIS中将https绑定分配给其他端口.

摆脱端口号.在IIS中创建一个https绑定.使用https且没有端口访问.
Firstly, you haven''t set the endpoint to https, it''s written http.

Second, https is reserved for port 433.

So I don''t think you can have have https on port 54110. You can''t assign a https binding in IIS to a different port.

Get rid of the port number. Create a https binding within IIS. Access using https and no port.


这篇关于WCF服务通过https运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆