添加WCF服务引用与HTTPS端点 [英] Adding WCF Service Reference with https endpoint

查看:230
本文介绍了添加WCF服务引用与HTTPS端点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的WCF服务应用程序的工作原理通过HTTP和HTTPS,但是,当我添加一个服务引用(使用HTTPS URL)把它在我的客户端,Visual Studio 2010中设置的配置文件到http端点。它似乎并不那样简单改变这种配置端点到https,因为有幕后的多个文件做的事情与XSD的,并引用了HTTP端点。如何设置我的服务/客户端强制HTTPS,使其正确地设置了终点?

My WCF service application works over http and https, however, when I add a service reference (with the https url) to it in my client, Visual Studio 2010 sets the endpoint in the config file to http. It doesn't appear to be as simple as changing that config endpoint to https since there are multiple files behind the scenes doing things with the xsd's and reference the http endpoint. How can I setup my service / client to force https so that it correctly sets the endpoint?

当我尝试手动更改端点的配置文件,并设置安全模式为传输我得到这个错误:

When I try to manually change the endpoint in the config file and set security mode to "Transport" I get this error:

异常消息:没有任何端点监听    HTTPS://myservice/AvailabilityService.svc 是可以接受的   信息。这通常是由不正确的地址或SOAP动作引起的。   见的InnerException,如果present,了解更多信息。

Exception Message: There was no endpoint listening at https://myservice/AvailabilityService.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.

我可以,但是,看到在IE中的端点,并正在调试本地。之后我加我为https服务的参考,并搜索其HTTP equivolent的解决方案,它找到一个WSDL文件中引用的HTTP,一个configuration.svcinfo和configuration91.svcinfo,利用HTTPS

I can, however, see that endpoint in IE, and am debugging locally. After I add my service reference with https and search the solution for its http equivolent, it finds a wsdl file referencing http, a configuration.svcinfo, and a configuration91.svcinfo that utilizes the http url instead of https

下面是我的服务器端配置:

Here's my server side config:

<?xml version="1.0"?>
<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
</configuration>

..与客户端的配置:

.. And the client side config:

<system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IAvailabilityService" closeTimeout="00:01:00"
            openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
            allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
            maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
            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>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="https://myservice/AvailabilityService.svc"
          binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IAvailabilityService"
          contract="PaymentAvailabilityService.IAvailabilityService"
          name="BasicHttpBinding_IAvailabilityService" />
    </client>
  </system.serviceModel>

也许我最好手动消费的服务,code?

Perhaps I'm better off manually consuming the services in code?

推荐答案

您需要更改绑定使用传输安全使用HTTPS

You need to change your binding to use transport security to use HTTPS

<一个href="http://msdn.microsoft.com/en-us/library/ms733043.aspx">http://msdn.microsoft.com/en-us/library/ms733043.aspx

您的服务器端绑定应为HTTPS和客户端进行配置:

Your server side binding should be configured for https as well as client:

<bindings>
  <basicHttpBinding>
    <binding name="httpsBinding" allowCookies="true" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647">
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
      <security mode="Transport">
        <transport clientCredentialType="None" />
      </security>
    </binding>
  </basicHttpBinding>
</bindings>
<services>
  <service name="yourNamespace.YourService" behaviorConfiguration="yourBehaviors">
    <endpoint contract="yourNamespace.YourService" binding="basicHttpBinding" bindingConfiguration="httpsBinding" />
  </service>
</services>

这篇关于添加WCF服务引用与HTTPS端点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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