尝试在 Visual Studio 2010 中添加对 Web 服务的引用时遇到错误。该 Web 服务是使用 JAX-WS/Metro/GlassFish 堆栈在 Java 中实现的,并且包含 UsernameToken 策略。以下是 WSDL 的摘录:
<wsp:Policy
xmlns:wsp="http://www.w3.org/ns/ws-policy"
xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702"
wsu:Id="UsernameToken">
<sp:SupportingTokens>
<wsp:Policy>
<sp:UsernameToken sp:IncludeToken=".../IncludeToken/AlwaysToRecipient" />
</wsp:Policy>
</sp:SupportingTokens>
</wsp:Policy>
当我尝试在 Visual Studio 中添加对此 Web 服务的服务引用时,收到以下警告:
Custom tool warning:
The following Policy Assertions were not Imported:
XPath://wsdl:definitions[@targetNamespace='http://archfirst.org/bfoms/tradingservice.wsdl']/wsdl:binding[@name='TradingWebServicePortBinding']
Assertions:
<sp:SupportingTokens xmlns:sp='http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702'>..</sp:SupportingTokens>
Custom tool warning:
Endpoint 'TradingWebServicePort' at address 'http://localhost:8080/bfoms-javaee/TradingService'
is not compatible with Silverlight 4. Skipping...
Custom tool warning:
No endpoints compatible with Silverlight 4 were found. The generated client
class will not be usable unless endpoint information is provided via the
constructor.
为什么 Visual Studio 无法导入断言?
附注我能够使用 SoapUI 工具导入并测试 Web 服务。
最佳答案
默认情况下,WCF 仅支持通过安全传输 = HTTPS 的用户名 token (或使用证书提供的消息安全性,但完全由 Silverlight 提供 message security is not supported)。 There is a way构建自定义绑定(bind)以允许用户名 token 通过不安全的传输,但 allowInsecureTransport
is probably not supported由 Silverlight 4 提供(我在创建自定义绑定(bind)时也没有找到它)。
WCF 也不支持带有摘要密码的用户名 token 。如果您需要带有摘要密码的用户名 token you have to implement additional part WCF 安全管道。同样,这可能是 Silverlight 功能集有限的问题。
您可以尝试在托管应用程序中创建代理服务。该服务将由 Silverlight 应用程序调用,并且它将调用 Java 服务。
关于wcf - Visual Studio 无法使用包含 UsernameToken 策略的 Web 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4911579/