Visual Studio 无法使用包含 UsernameToken 策略的 Web 服务
我尝试在 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 无法导入断言?
PS 我能够使用 SoapUI 工具导入和测试 Web 服务。
I am getting errors when trying to add a reference to a Web Service in Visual Studio 2010. The Web Service is implemented in Java using the JAX-WS/Metro/GlassFish stack and contains a UsernameToken policy. Here's an excerpt from the 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>
When I try to add a service reference to this web service in Visual Studio, I get the following warnings:
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.
Why is Visual Studio not able to import the assertion?
P.S. I was able to import and test the web service using the SoapUI tool.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
默认情况下,WCF 仅支持通过安全传输 = HTTPS 的用户名令牌(或使用证书提供的消息安全性,但 Silverlight 根本不支持消息安全性)。 有一种方法构建自定义绑定以允许用户名令牌通过不安全的传输,但
allowInsecureTransport
Silverlight 4 可能不支持(我在创建自定义绑定时也没有找到它)。WCF 也不支持带有摘要密码的用户名令牌。如果您需要带有摘要密码的用户名令牌您必须实现附加部分 WCF 安全管道。这也可能是 Silverlight 功能集有限的问题。
您可以尝试在托管应用程序中创建代理服务。该服务将由 Silverlight 应用程序调用,并且它将调用 Java 服务。
WCF by default only supports username token over secured transport = HTTPS (or with message security provided by certificates but message security is not supported by Silverlight at all). There is a way to build custom binding to allow user name token over unsecured transport but
allowInsecureTransport
is probably not supported by Silverlight 4 (I also didn't find it when creating custom binding).WCF also does not support username token with digested password. If you need username token with digested password you have to implement additional part of WCF security pipeline. Again it can be problem with limited feature set of Silverlight.
You can try to create proxy service in your hosting application. This service will be called by Silverlight application and it will call Java service.