这是我在web.config中的服务配置:

<binding name="statefulSessionWithUsernameOverTransport">
  <security authenticationMode="SecureConversation"
    requireSecurityContextCancellation="False" allowInsecureTransport="True">
    <secureConversationBootstrap authenticationMode="UserNameOverTransport"/>
  </security>
  <binaryMessageEncoding />
  <httpTransport />
</binding>

<service name="com.example.FooService"
  behaviorConfiguration="usernamePasswordAuthBehavior">
  <endpoint contract="com.example.FooService.IFooService"
    address="custom" binding="customBinding"
    bindingConfiguration="statefulSessionWithUsernameOverTransport" />
</service>

我正在设置允许InsecureTransport = true,因为在生产中,服务将在SSL终止负载平衡器后面运行。从我的.NET 4.0客户端拨打服务没有任何问题,但是试图更新VS2010中的服务参考总是会导致错误:

System.ServiceModel.Channels.TransportSecurityBindingElement错误:安全策略导出失败。该绑定包含运输安全性,但没有实现ItransportTokenAssertionProvider的运输安全绑定元件。不支持此类政策导出的政策出口。

我了解它试图告诉我的东西 - 基本上,我在绑定上禁用了运输安全性,该绑定要求它避免损害凭借电线上行驶的凭据。但是 - 这就是重点 允许Insecuretransport. 。可能是代理生成器根本不知道此属性吗?

更新:

看起来WSDL生成器确实无法处理属性。我不得不回到消息级别的安全性和自我签名的开发证书。使用消息安全具有能够坚持开发的优势,而不是完全吹牛IIS。

<wsHttpBinding>
    <binding name="wshttpDevelopmentBinding">
      <security mode="Message">
        <message clientCredentialType="UserName" />
      </security>
    </binding>
</wsHttpBinding>
有帮助吗?

解决方案

我遇到了同一问题。问题似乎是HTTP传输,因为它没有实现ItransportTokenAssertionProvider界面,但HTTPS确实如此。我能够解决这两种方法:切换我的自定义绑定以使用HTTPS Transport,该运输实现了接口,并将EnableUnSecuredResponse =“ true”添加到配置中的安全元素,或编写从HTTPTransportBindingElement派生但实现的自定义绑定。必要的接口。

其他提示

我读了几次(例如 这里 或者 这里)但是我从未尝试过。它看起来像是WSDL导出中的一个错误,因为当您配置服务和客户端时,它应该起作用,但元数据导出不起作用。第二个链接提出了一些解决方法,但这是丑陋的。

我的建议是使用允许Insecuretransport设置为False和HTTPS带有测试证书的HTTP,并在部署应用程序时切换此配置(可以是安装程序包的一部分)。

我遇到了类似的问题。我在客户端机器上为.NET Framework安装了Hot Fix,此后起作用。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top