如何将 jbossws 属性文件绑定到 soapui 中的 soap 请求和响应消息?

How to bind jbossws properties files to soap request and response message in soapui?

如您所知,在 wildfly ws-security 配置中,2 个属性文件绑定到 web 服务。在服务器端 server.properties 绑定如下,

== server.properties

org.apache.ws.security.crypto.provider=org.apache.ws.security.components.crypto.Merlin
org.apache.ws.security.crypto.merlin.keystore.type=jks
org.apache.ws.security.crypto.merlin.keystore.password=password123
org.apache.ws.security.crypto.merlin.keystore.alias=servicekey
org.apache.ws.security.crypto.merlin.keystore.file=META-INF/serviceKeystore.jks

== jaxws-endpoint-config.xml

<endpoint-config>     
   <config-name>Custom WS-Security Endpoint</config-name>     
   <property>       
      <property-name>ws-security.signature.properties</property-name>       
      <property-value>META-INF/server.properties</property-value>     
   </property>     
   <property>       
      <property-name>ws-security.callback-handler</property-name>       
      <property-value>
      com.aaa.soap.KeystorePasswordCallback
      </property-value>        
   </property>   
   </endpoint-config>

== HelloWorld.java

@WebService
@EndpointConfig(configFile = "WEB-INF/jaxws-endpoint-config.xml", configName = "Custom WS-Security Endpoint")
public class HelloWorld implements IHelloWorld {
    @Override
    public String sayHello(String name) {
        // TODO Auto-generated method stub
        return "Hello " + name;
    }
}

在客户端,JSP 文件正在绑定 client.properties 到 soap 请求。

== client.properties

org.apache.ws.security.crypto.provider=org.apache.ws.security.components.crypto.Merlin
org.apache.ws.security.crypto.merlin.keystore.type=jks
org.apache.ws.security.crypto.merlin.keystore.password=password123
org.apache.ws.security.crypto.merlin.keystore.alias=servicekey
org.apache.ws.security.crypto.merlin.keystore.file=META-INF/serviceKeystore.jks

== index.jsp

<body>
<% 
String SERVICE_URL = "http://localhost:8080/SOAPEncryptWeb/HelloWorld";

try {
    QName serviceName = new QName("http://soap.aaa.com/", "HelloWorldService");

    URL wsdlURL;
    wsdlURL = new URL(SERVICE_URL + "?wsdl");
    Service service = Service.create(wsdlURL, serviceName);

    IHelloWorld port = (IHelloWorld) service.getPort(IHelloWorld.class); 

    ((BindingProvider) port).getRequestContext().put(SecurityConstants.CALLBACK_HANDLER, new KeystorePasswordCallback());
    ((BindingProvider) port).getRequestContext().put(SecurityConstants.ENCRYPT_PROPERTIES, Thread.currentThread().getContextClassLoader().getResource("META-INF/client.properties"));
    ((BindingProvider) port).getRequestContext().put(SecurityConstants.ENCRYPT_USERNAME, "servicekey");
    out.println(port.sayHello("jina"));
} catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}
%>
</body>

所以在 soapui 应用程序中,我重新制作了这些 client/server 属性,如下所示,

但是我卡在了这一部分。这些服务器和客户端属性已在 Eclipse IDE 上成功绑定。但是在 SoapUI 应用程序中,我不知道如何将这些属性与 soap 请求和响应绑定。

要在 SOAPUI 上使用 WS 安全性,您必须使用其特定的 WS-Security 配置 如下。首先在 Navigator window:

上双击您的项目名称

如上图所示,这里有一个 WS-Security Configurations 选项卡。

首先添加包含执行操作的密钥的密钥库。为此,请单击 Keystores 选项卡并添加您的密钥库信息,在您的情况下基于您的 clients.properties:

其次,根据您的代码,您似乎想要加密传出到 Web 服务的消息,因此 select 传出 WS-Security Configuration 选项卡并添加一个新的配置。您的 outgoing/incoming 属性位于您未在问题中显示的 WEB-INF/jaxws-endpoint-config.xml 配置文件中,因此请根据此文件的内容配置此选项卡。配置后它看起来像:

最后检查您的配置,转到您的 SOAP 请求,右键单击请求面板并 select Outgoing wss > Apply [your ws 配置名称]:

有关更多详细信息,请查看 SOAPUI documentation

我希望这能为您指明正确的方向。