从 Silverlight 客户端添加自定义 SOAP 标头
我正在尝试在 Silverlight 客户端和 Java 服务器之间设置 Web 服务。我需要从 Silverlight 客户端发送用户名令牌(用户名/密码)以进行身份验证。由于这是一个概念验证,我想让事情变得简单并使用 HTTP 作为我的传输层。然而,Silverlight 似乎只支持通过 HTTPS 的用户名令牌(Visual Studio 无法从我的通过 HTTP 处理用户名令牌的 Java 服务器中消化 WSDL)。
所以我的问题是:如何在 Silverlight 客户端发送的 SOAP 标头中添加用户名/密码信息 - 仍然使用 basicHttpBinding 和 HTTP?它不必符合 WS-Security。像这样简单的事情就足以满足我的应用程序:
<soapenv:Header>
<UsernameToken>
<Username>john</Username>
<Password>cool</Password>
</UsernameToken>
</soapenv:Header>
I am trying to set up a web service between a Silverlight client and a Java server. I need to send username tokens (username/password) from the Silverlight client for authentication purposes. Since this is a proof-of-concept, I want to keep things simple and use HTTP as my transport layer. However it looks like Silverlight only supports username tokens over HTTPS (Visual Studio is unable to digest the WSDL from my Java server that does username tokens over HTTP).
So my question is this: how can I add username/password information in the SOAP header sent by my Silverlight client - still using basicHttpBinding and HTTP? It does not have to be WS-Security compliant. Something as simple as this will suffice for my application:
<soapenv:Header>
<UsernameToken>
<Username>john</Username>
<Password>cool</Password>
</UsernameToken>
</soapenv:Header>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看
IClientMessageInspector
。在BeforeSendRequest
方法中,您可以添加您的用户名/密码:您必须将其添加到您的绑定中:
have a look at the
IClientMessageInspector
. In theBeforeSendRequest
method you can add your username/password:You have to add this to your binding: