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

时间:2016-08-12 10:42:18

标签: soap soapui ws-security

如您所知,在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应用程序中,我重新制作了这些客户端/服务器属性,如下所示,

enter image description here enter image description here

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

1 个答案:

答案 0 :(得分:0)

要在 SOAPUI 上使用 WS Security ,您必须使用其特定的 WS-Security配置,如下所示。首先双击 Navigator 窗口中的项目名称:

enter image description here

在上图中,您可以看到 WS-Security Configurations 选项卡。

首先添加包含执行操作的密钥的密钥库。为此,请点击 Keystores 标签,根据您的clients.properties添加您的密钥库信息:

enter image description here

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

enter image description here

最后要检查您的配置,请转到 SOAP请求,右键单击请求面板,然后选择 Outgoing wss&gt;申请[你的ws cfg名称]

enter image description here

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

我希望这能指出你正确的方向。