Utility class for working with SOAP web services. This class provides
methods for setting SOAP headers and a set of constants representing the
supported header names.
If you want to use ws-security features, such as signing and encryption,
with your RPC-style SOAP web service, use this class to construct a HashMap with
security constants and values.
Note: this method handles sensitive security-related data.
Pay special attention to PCI DSS v3. requirements 2, 4, and 12.
The following example configures the ws-security actions taken for the request and response to a web service.
importPackage( dw.system );
importPackage( dw.util );
importPackage( dw.rpc );
function execute( args : PipelineDictionary ) : Number
{
var WSU_NS : String = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd";
try
{
// define a map with all the secrets
var secretsMap : Map = new HashMap();
secretsMap.put("myclientkey", "ckpass");
secretsMap.put("myservicekey", "ckpass");
secretsMap.put("username", "password");
var requestCfg : Map = new HashMap();
// define the ws actions to be performed
requestCfg.put(SOAPUtil.WS_ACTION, SOAPUtil.WS_USERNAME_TOKEN + " " +
SOAPUtil.WS_TIMESTAMP + " " +
SOAPUtil.WS_SIGNATURE + " " +
SOAPUtil.WS_ENCRYPT);
requestCfg.put(SOAPUtil.WS_USER, "username");
requestCfg.put(SOAPUtil.WS_PASSWORD_TYPE, SOAPUtil.WS_PW_DIGEST );
requestCfg.put(SOAPUtil.WS_SIG_DIGEST_ALGO, "http://www.w3.org/2001/04/xmlenc#sha256" );
// define signature properties
// the keystore file has the basename of the WSDL file and the
// file extension based on the keystore type (e.g. HelloWorld.jks).
// The keystore file has to be placed beside the WSDL file.
requestCfg.put(SOAPUtil.WS_SIG_PROP_KEYSTORE_TYPE, "jks");
requestCfg.put(SOAPUtil.WS_SIG_PROP_KEYSTORE_PW, "cspass");
requestCfg.put(SOAPUtil.WS_SIG_PROP_KEYSTORE_ALIAS, "myclientkey");
requestCfg.put(SOAPUtil.WS_SIGNATURE_USER, "myclientkey");
// define enrcryption properties
requestCfg.put(SOAPUtil.WS_ENC_PROP_KEYSTORE_TYPE, "jks");
requestCfg.put(SOAPUtil.WS_ENC_PROP_KEYSTORE_PW, "cspass");
requestCfg.put(SOAPUtil.WS_ENC_PROP_KEYSTORE_ALIAS, "myservicekey");
requestCfg.put(SOAPUtil.WS_ENCRYPTION_USER, "myservicekey");
requestCfg.put(SOAPUtil.WS_SIGNATURE_PARTS, "{Element}{http://schemas.xmlsoap.org/soap/envelope/}Body");
requestCfg.put(SOAPUtil.WS_ENCRYPTION_PARTS,"{Element}{" + WSU_NS + "}
Timestamp;"+"{Content}{http://schemas.xmlsoap.org/soap/envelope/}Body");
// set the secrets for the callback
requestCfg.put(SOAPUtil.WS_SECRETS_MAP, secretsMap);
var responseCfg : Map = new HashMap();
// define the ws actions to be performed for the response
responseCfg.put(SOAPUtil.WS_ACTION, SOAPUtil.WS_TIMESTAMP + " " +
SOAPUtil.WS_SIGNATURE + " " +
SOAPUtil.WS_ENCRYPT);
// define signature properties
responseCfg.put(SOAPUtil.WS_SIG_PROP_KEYSTORE_TYPE, "jks");
responseCfg.put(SOAPUtil.WS_SIG_PROP_KEYSTORE_PW, "cspass");
responseCfg.put(SOAPUtil.WS_SIG_PROP_KEYSTORE_ALIAS, "myservicekey");
responseCfg.put(SOAPUtil.WS_SIGNATURE_USER, "myservicekey");
// define decryption properties
responseCfg.put(SOAPUtil.WS_ENC_PROP_KEYSTORE_TYPE, "jks");
responseCfg.put(SOAPUtil.WS_ENC_PROP_KEYSTORE_PW, "cspass");
responseCfg.put(SOAPUtil.WS_ENC_PROP_KEYSTORE_ALIAS, "myclientkey");
responseCfg.put(SOAPUtil.WS_ENCRYPTION_USER, "myclientkey");
// set the secrets for the callback
responseCfg.put(SOAPUtil.WS_SECRETS_MAP, secretsMap);
// get the service and stub
var helloWorldService : WebReference = webreferences.HelloWorld;
var stub : Stub = helloWorldService.defaultService;
// set the security
SOAPUtil.setWSSecurityConfig(stub, requestCfg, responseCfg);
//var h : Hello = new helloWorldService.Hello();
var h = new helloWorldService.com.support.ws.security.test.Hello2();
h.setName('Send Text from client Axis ...');
// call the web service
var response = stub.hello2(h);
//var response = stub.hello(h);
var result = response.getHello2Return();
args.OutStr = result;
Logger.error("Hello World We Are SIGNED old version Send Text from client ...", result);
return PIPELET_NEXT;
}
catch (e)
{
Logger.error("Error in helloWorldRpc.ds is: " + e);
return PIPELET_ERROR;
}
}