RAD - 如何在 websphere 应用程序服务器管理控制台中为 JAX-WS 添加用户名令牌

我已经使用 JAX-WS 创建了一个 Web 服务,并尝试将 Simple UsernameToken 安全性添加到 Web 服务中。该应用程序部署在 Websphere 8.5 上。


我发现以下链接有助于为基于 JAX-RPC 的 Web 服务添加来自RAD -> 服务选项卡的 usernameToken,但相同的功能不适用于JAX-WS类型的 Web 服务。


RAD - 如何在 websphere 应用程序服务器管理控制台中为 JAX RPC 添加用户名令牌


任何人都可以帮助提供一些类似的步骤或其他可能的简单解决方案来为 JAX-WS Web 服务实现相同的目标吗?


    <Soapenv:Header>

    <wsse:Security soapenv: mustUnderstand="1"

        xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wsswssecurity-secext-1.0.xsd">

        <wsse:UsernameToken>

            <wsse:Username>user</wsse: Username>

            <wsse:Password

                Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wssusername-token-profile-1.0#PasswordText">paas</wsse: Password>

        </wsse:UsernameToken>

    </wsse:Security>

</soapenv:Header>


森林海
浏览 144回答 1
1回答

烙印99

最后,我设法找到了解决上述问题的方法。它如下:在谷歌上搜索了很多之后,我发现了一个Web 服务处理程序的概念,可以分别为从 Web 服务提供者接收或发送的每个请求和响应调用它。如何配置: 1. 创建一个 Java File SecurityHandler 并在其中粘贴以下代码:public class SecurityHandler implements SOAPHandler<SOAPMessageContext>{&nbsp; &nbsp; @Override&nbsp; &nbsp; public boolean handleMessage(SOAPMessageContext context)&nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; boolean outbound = (Boolean)context.get(SOAPMessageContext.MESSAGE_OUTBOUND_PROPERTY);&nbsp; &nbsp; &nbsp; &nbsp; if(outbound) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //logic to handle a response&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; if (!outbound) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //logic to handle a request&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; return true;&nbsp; &nbsp; }&nbsp; &nbsp; @Override&nbsp; &nbsp; public boolean handleFault(SOAPMessageContext context) {&nbsp; &nbsp; &nbsp; &nbsp; return true;&nbsp; &nbsp; }&nbsp; &nbsp; @Override&nbsp; &nbsp; public void close(MessageContext context) {}&nbsp; &nbsp; @Override&nbsp; &nbsp; public Set<QName> getHeaders() {&nbsp; &nbsp; &nbsp; &nbsp; return Collections.emptySet();&nbsp; &nbsp; }}使用以下代码示例创建一个 XML 文件:<?xml version="1.0" encoding="UTF-8" standalone="yes"?><javaee:handler-chains&nbsp;&nbsp; &nbsp; &nbsp;xmlns:javaee="http://java.sun.com/xml/ns/javaee"&nbsp;&nbsp; &nbsp; &nbsp;xmlns:xsd="http://www.w3.org/2001/XMLSchema">&nbsp; <javaee:handler-chain>&nbsp; &nbsp; <javaee:handler>&nbsp; &nbsp; &nbsp; <javaee:handler-class>your.package.path.SecurityHandler</javaee:handler-class>&nbsp; &nbsp; </javaee:handler>&nbsp; </javaee:handler-chain></javaee:handler-chains>要激活对您公开的 Web 服务的每个请求或响应的处理程序,请在 Web 服务类中添加注释,如下所示:&nbsp; &nbsp; @HandlerChain(file="/your/package/path/handler-chain.xml")&nbsp; &nbsp; 公开课我的网络服务{&nbsp; &nbsp; &nbsp; &nbsp; //要公开的方法或网络服务。&nbsp; &nbsp; }
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python