Class SOAPUtil

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.

1importPackage( dw.system );
2importPackage( dw.util );
3importPackage( dw.rpc );
4
5
6function execute( args : PipelineDictionary ) : Number
7{
8    var WSU_NS : String = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd";
9
10    try
11    {
12
13    // define a map with all the secrets
14    var secretsMap   : Map = new HashMap();
15    secretsMap.put("myclientkey", "ckpass");
16    secretsMap.put("myservicekey", "ckpass");
17    secretsMap.put("username", "password");
18
19    var requestCfg   : Map = new HashMap();
20
21    // define the ws actions to be performed
22    requestCfg.put(SOAPUtil.WS_ACTION, SOAPUtil.WS_USERNAME_TOKEN + " " +
23                                       SOAPUtil.WS_TIMESTAMP + " " +
24                                       SOAPUtil.WS_SIGNATURE + " " +
25                                       SOAPUtil.WS_ENCRYPT);
26    requestCfg.put(SOAPUtil.WS_USER, "username");
27    requestCfg.put(SOAPUtil.WS_PASSWORD_TYPE, SOAPUtil.WS_PW_DIGEST );
28    requestCfg.put(SOAPUtil.WS_SIG_DIGEST_ALGO, "http://www.w3.org/2001/04/xmlenc#sha256" );
29
30    // define signature properties
31    // the keystore file has the basename of the WSDL file and the
32    // file extension based on the keystore type (e.g. HelloWorld.jks).
33    // The keystore file has to be placed beside the WSDL file.
34    requestCfg.put(SOAPUtil.WS_SIG_PROP_KEYSTORE_TYPE, "jks");
35    requestCfg.put(SOAPUtil.WS_SIG_PROP_KEYSTORE_PW, "cspass");
36    requestCfg.put(SOAPUtil.WS_SIG_PROP_KEYSTORE_ALIAS, "myclientkey");
37
38    requestCfg.put(SOAPUtil.WS_SIGNATURE_USER, "myclientkey");
39
40    // define enrcryption properties
41    requestCfg.put(SOAPUtil.WS_ENC_PROP_KEYSTORE_TYPE, "jks");
42    requestCfg.put(SOAPUtil.WS_ENC_PROP_KEYSTORE_PW, "cspass");
43    requestCfg.put(SOAPUtil.WS_ENC_PROP_KEYSTORE_ALIAS, "myservicekey");
44
45    requestCfg.put(SOAPUtil.WS_ENCRYPTION_USER, "myservicekey");
46    requestCfg.put(SOAPUtil.WS_SIGNATURE_PARTS, "{Element}{http://schemas.xmlsoap.org/soap/envelope/}Body");
47    requestCfg.put(SOAPUtil.WS_ENCRYPTION_PARTS,"{Element}{" + WSU_NS + "}
48     Timestamp;"+"{Content}{http://schemas.xmlsoap.org/soap/envelope/}Body");
49
50    // set the secrets for the callback
51    requestCfg.put(SOAPUtil.WS_SECRETS_MAP, secretsMap);
52
53    var responseCfg : Map = new HashMap();
54
55    // define the ws actions to be performed for the response
56    responseCfg.put(SOAPUtil.WS_ACTION, SOAPUtil.WS_TIMESTAMP + " " +
57                                        SOAPUtil.WS_SIGNATURE + " " +
58                                        SOAPUtil.WS_ENCRYPT);
59
60    // define signature properties
61    responseCfg.put(SOAPUtil.WS_SIG_PROP_KEYSTORE_TYPE, "jks");
62    responseCfg.put(SOAPUtil.WS_SIG_PROP_KEYSTORE_PW, "cspass");
63    responseCfg.put(SOAPUtil.WS_SIG_PROP_KEYSTORE_ALIAS, "myservicekey");
64
65    responseCfg.put(SOAPUtil.WS_SIGNATURE_USER, "myservicekey");
66
67    // define decryption properties
68    responseCfg.put(SOAPUtil.WS_ENC_PROP_KEYSTORE_TYPE, "jks");
69    responseCfg.put(SOAPUtil.WS_ENC_PROP_KEYSTORE_PW, "cspass");
70    responseCfg.put(SOAPUtil.WS_ENC_PROP_KEYSTORE_ALIAS, "myclientkey");
71
72    responseCfg.put(SOAPUtil.WS_ENCRYPTION_USER, "myclientkey");
73
74    // set the secrets for the callback
75    responseCfg.put(SOAPUtil.WS_SECRETS_MAP, secretsMap);
76
77    // get the service and stub
78    var helloWorldService : WebReference = webreferences.HelloWorld;
79    var stub : Stub = helloWorldService.defaultService;
80    // set the security
81    SOAPUtil.setWSSecurityConfig(stub, requestCfg, responseCfg);
82        //var h : Hello = new helloWorldService.Hello();
83        var h = new helloWorldService.com.support.ws.security.test.Hello2();
84
85        h.setName('Send Text from client Axis ...');
86
87        // call the web service
88        var response  = stub.hello2(h);
89        //var response = stub.hello(h);
90        var result = response.getHello2Return();
91
92
93    args.OutStr = result;
94    Logger.error("Hello World We Are SIGNED old version Send Text from client ...", result);
95
96    return PIPELET_NEXT;
97
98    }
99    catch (e)
100    {
101        Logger.error("Error in helloWorldRpc.ds is: " + e);
102        return PIPELET_ERROR;
103    }
104
105}

See Also:

Deprecated:

This class is deprecated, please use webreferences2 instead (see also WSUtil).

Warning

Constant Summary 

ConstantDescription
WS_ACTION: String = “action”WS-Security action property name.
WS_ENCRYPT: String = “Encrypt”WS-Security action: encrypt the message.
WS_ENCRYPTION_PARTS: String = “encryptionParts”WS-Security encryption: defines which parts of the request are encrypted.
WS_ENCRYPTION_USER: String = “encryptionUser”WS-Security encryption: the user’s name for encryption.
WS_ENC_PROP_KEYSTORE_ALIAS: String = “__EncryptionPropKeystoreAlias”WS-Security encryption: the encryption/decryption keystore alias name
WS_ENC_PROP_KEYSTORE_PW: String = “__EncryptionPropKeystorePassword”WS-Security encryption: the encryption/decryption keystore password
WS_ENC_PROP_KEYSTORE_TYPE: String = “__EncryptionPropKeystoreType”WS-Security encryption: the encryption/decryption keystore type ( jks or pkcs12 ), default is jks.
WS_NO_SECURITY: String = “NoSecurity”WS-Security action: no security
WS_PASSWORD_TYPE: String = “passwordType”WS-Security password type: parameter for UsernameToken action to define the encoding of the password.
WS_PW_DIGEST: String = “PasswordDigest”WS-Security password of type digest: use a password digest to send the password information.
WS_PW_TEXT: String = “PasswordText”WS-Security password of type text: send the password information in clear text.
WS_SECRETS_MAP: String = “__SecretsMap”A secrets map with the username/password entries is needed to create the password callback object.
WS_SIGNATURE: String = “Signature”WS-Security action: sign the message.
WS_SIGNATURE_PARTS: String = “signatureParts”WS-Security signature: defines which parts of the request are signed.
WS_SIGNATURE_USER: String = “signatureUser”WS-Security signature: the user’s name for signature.
WS_SIG_DIGEST_ALGO: String = “signatureDigestAlgorithm”WS-Security signature: sets the signature digest algorithm to use.
WS_SIG_PROP_KEYSTORE_ALIAS: String = “__SignaturePropKeystoreAlias”WS-Security signature: the signature keystore alias name
WS_SIG_PROP_KEYSTORE_PW: String = “__SignaturePropKeystorePassword”WS-Security signature: the signature keystore password.
WS_SIG_PROP_KEYSTORE_TYPE: String = “__SignaturePropKeystoreType”WS-Security: the signature keystore type ( jks or pkcs12 ).
WS_TIMESTAMP: String = “Timestamp”WS-Security action: add a timestamp to the security header.
WS_USER: String = “user”WS-Security user name.
WS_USERNAME_TOKEN: String = “UsernameToken”WS-Security action: add a UsernameToken identification.

Constructor Summary 

ConstructorDescription
SOAPUtil()

Method Summary 

MethodDescription
static getHTTPRequestHeader(Object, String)Returns an HTTP request header property value using the specified key.
static getHTTPResponseHeader(Object, String)Returns an HTTP response header property value using the specified key.
static setHTTPRequestHeader(Object, String, String)Sets an HTTP request header property using the specified key and value.
static setHeader(Object, String)Sets a new SOAPHeaderElement in the SOAP request with the namespace of the XML content.
static setHeader(Object, String, Boolean)Sets a new SOAPHeaderElement in the SOAP request with the namespace of the XML content.
static setHeader(Object, String, String, Object)Creates a new SOAPHeaderElement with the name and namespace and places the given XML into it.
static setHeader(Object, String, String, Object, Boolean)Creates a new SOAPHeaderElement with the name and namespace and places the given XML into it.
static setHeader(Object, String, String, Object, Boolean, String)Creates a new SOAPHeaderElement with the name and namespace and places the given XML into it.
static setHeader(Object, String, String, String)Creates a new SOAPHeaderElement with the name and namespace and places the given XML into it.
static setHeader(Object, String, String, String, Boolean)Creates a new SOAPHeaderElement with the name and namespace and places the given XML into it.
static setHeader(Object, String, String, String, Boolean, String)Creates a new SOAPHeaderElement with the name and namespace and places the given XML into it.
static setWSSecurityConfig(Object, Object, Object)Sets the WS-Security configuration for the request and response based on the constants defined.

Methods inherited from class Object 

assign, create, create, defineProperties, defineProperty, entries, freeze, fromEntries, getOwnPropertyDescriptor, getOwnPropertyNames, getOwnPropertySymbols, getPrototypeOf, hasOwnProperty, is, isExtensible, isFrozen, isPrototypeOf, isSealed, keys, preventExtensions, propertyIsEnumerable, seal, setPrototypeOf, toLocaleString, toString, valueOf, values

Constant Details 

WS_ACTION 

WS_ACTION: String = "action"

WS-Security action property name. Allowed property values are WS_NO_SECURITY, WS_TIMESTAMP, WS_ENCRYPT, WS_SIGNATURE, WS_USERNAME_TOKEN or a space separated String with multiple values.

Deprecated:

use webreferences2 instead

Warning


WS_ENCRYPT 

WS_ENCRYPT: String = "Encrypt"

WS-Security action: encrypt the message. The encryption-specific parameters define how to encrypt, which keys to use, and other parameters.

Deprecated:

use webreferences2 instead

Warning


WS_ENCRYPTION_PARTS 

WS_ENCRYPTION_PARTS: String = "encryptionParts"

WS-Security encryption: defines which parts of the request are encrypted.

Deprecated:

use webreferences2 instead

Warning


WS_ENCRYPTION_USER 

WS_ENCRYPTION_USER: String = "encryptionUser"

WS-Security encryption: the user's name for encryption.

Deprecated:

use webreferences2 instead

Warning


WS_ENC_PROP_KEYSTORE_ALIAS 

WS_ENC_PROP_KEYSTORE_ALIAS: String = "__EncryptionPropKeystoreAlias"

WS-Security encryption: the encryption/decryption keystore alias name

Deprecated:

use webreferences2 instead

Warning


WS_ENC_PROP_KEYSTORE_PW 

WS_ENC_PROP_KEYSTORE_PW: String = "__EncryptionPropKeystorePassword"

WS-Security encryption: the encryption/decryption keystore password

Deprecated:

use webreferences2 instead

Warning


WS_ENC_PROP_KEYSTORE_TYPE 

WS_ENC_PROP_KEYSTORE_TYPE: String = "__EncryptionPropKeystoreType"

WS-Security encryption: the encryption/decryption keystore type ( jks or pkcs12 ), default is jks.

Note: the keystore file must have the basename of the WSDL file and the file extension based on the keystore type. For example: MyService.jks. The keystore file must be placed in the same cartridge directory as the WSDL file.

Deprecated:

use webreferences2 instead

Warning


WS_NO_SECURITY 

WS_NO_SECURITY: String = "NoSecurity"

WS-Security action: no security

Deprecated:

use webreferences2 instead

Warning


WS_PASSWORD_TYPE 

WS_PASSWORD_TYPE: String = "passwordType"

WS-Security password type: parameter for UsernameToken action to define the encoding of the password. Allowed values are PW_DIGEST or PW_TEXT.

Deprecated:

use webreferences2 instead

Warning


WS_PW_DIGEST 

WS_PW_DIGEST: String = "PasswordDigest"

WS-Security password of type digest: use a password digest to send the password information.

Deprecated:

use webreferences2 instead

Warning


WS_PW_TEXT 

WS_PW_TEXT: String = "PasswordText"

WS-Security password of type text: send the password information in clear text.

Deprecated:

use webreferences2 instead

Warning


WS_SECRETS_MAP 

WS_SECRETS_MAP: String = "__SecretsMap"

A secrets map with the username/password entries is needed to create the password callback object.

Deprecated:

use webreferences2 instead

Warning


WS_SIGNATURE 

WS_SIGNATURE: String = "Signature"

WS-Security action: sign the message. The signature-specific parameters define how to sign, which keys to use, and other parameters.

Deprecated:

use webreferences2 instead

Warning


WS_SIGNATURE_PARTS 

WS_SIGNATURE_PARTS: String = "signatureParts"

WS-Security signature: defines which parts of the request are signed.

Deprecated:

use webreferences2 instead

Warning


WS_SIGNATURE_USER 

WS_SIGNATURE_USER: String = "signatureUser"

WS-Security signature: the user's name for signature.

Deprecated:

use webreferences2 instead

Warning


WS_SIG_DIGEST_ALGO 

WS_SIG_DIGEST_ALGO: String = "signatureDigestAlgorithm"

WS-Security signature: sets the signature digest algorithm to use.

Deprecated:

use webreferences2 instead

Warning


WS_SIG_PROP_KEYSTORE_ALIAS 

WS_SIG_PROP_KEYSTORE_ALIAS: String = "__SignaturePropKeystoreAlias"

WS-Security signature: the signature keystore alias name

Deprecated:

use webreferences2 instead

Warning


WS_SIG_PROP_KEYSTORE_PW 

WS_SIG_PROP_KEYSTORE_PW: String = "__SignaturePropKeystorePassword"

WS-Security signature: the signature keystore password.

Deprecated:

use webreferences2 instead

Warning


WS_SIG_PROP_KEYSTORE_TYPE 

WS_SIG_PROP_KEYSTORE_TYPE: String = "__SignaturePropKeystoreType"

WS-Security: the signature keystore type ( jks or pkcs12 ). The default is jks.

Note: The keystore file must have the basename of the WSDL file and the file extension of the keystore type. For example: MyService.jks. The keystore file must be placed in the same cartridge directory as the WSDL file.

Deprecated:

use webreferences2 instead

Warning


WS_TIMESTAMP 

WS_TIMESTAMP: String = "Timestamp"

WS-Security action: add a timestamp to the security header.

Deprecated:

use webreferences2 instead

Warning


WS_USER 

WS_USER: String = "user"

WS-Security user name.

Deprecated:

use webreferences2 instead

Warning


WS_USERNAME_TOKEN 

WS_USERNAME_TOKEN: String = "UsernameToken"

WS-Security action: add a UsernameToken identification.

Deprecated:

use webreferences2 instead

Warning


Constructor Details 

SOAPUtil() 

SOAPUtil()


Method Details 

getHTTPRequestHeader(Object, String) 

static getHTTPRequestHeader(svc: Object, key: String): String

Returns an HTTP request header property value using the specified key. Null is returned if the key does not represent an HTTP header property.

Parameters:

  • svc - a service stub returned from getService().
  • key - the header property key.

Returns:

  • an HTTP request header property value using the specified key or null.

Deprecated:

use webreferences2 instead

Warning


getHTTPResponseHeader(Object, String) 

static getHTTPResponseHeader(svc: Object, key: String): String

Returns an HTTP response header property value using the specified key. Null is returned if the key does not represent an HTTP response header property.

Parameters:

  • svc - a service stub returned from getService().
  • key - the header property key.

Returns:

  • an HTTP response header property value using the specified key or null.

Deprecated:

use webreferences2 instead

Warning


setHTTPRequestHeader(Object, String, String) 

static setHTTPRequestHeader(svc: Object, key: String, value: String): void

Sets an HTTP request header property using the specified key and value.

Parameters:

  • svc - a service stub returned from getService().
  • key - the header property key.
  • value - the header property value. If the value is null, the property identified by the key is removed from the HTTP request header.

Deprecated:

use webreferences2 instead

Warning


setHeader(Object, String) 

static setHeader(svc: Object, xml: String): void

Sets a new SOAPHeaderElement in the SOAP request with the namespace of the XML content.

Parameters:

  • svc - a service stub returned from getService()
  • xml - a string with arbitrary XML content

Deprecated:

use webreferences2 instead

Warning


setHeader(Object, String, Boolean) 

static setHeader(svc: Object, xml: String, mustUnderstand: Boolean): void

Sets a new SOAPHeaderElement in the SOAP request with the namespace of the XML content.

Parameters:

  • svc - a service stub returned from getService()
  • xml - a string with arbitrary XML content
  • mustUnderstand - sets the SOAP header attribute 'mustUnderstand'

Deprecated:

use webreferences2 instead

Warning


setHeader(Object, String, String, Object) 

static setHeader(svc: Object, namespace: String, name: String, xml: Object): void

Creates a new SOAPHeaderElement with the name and namespace and places the given XML into it.

Parameters:

  • svc - a service stub returned from getService()
  • namespace - the namespace of the header element
  • name - the element name for the header element
  • xml - a E4X XML object

Deprecated:

use webreferences2 instead

Warning


setHeader(Object, String, String, Object, Boolean) 

static setHeader(svc: Object, namespace: String, name: String, xml: Object, mustUnderstand: Boolean): void

Creates a new SOAPHeaderElement with the name and namespace and places the given XML into it.

Parameters:

  • svc - a service stub returned from getService()
  • namespace - the namespace of the header element
  • name - the element name for the header element
  • xml - a E4X XML object
  • mustUnderstand - sets the SOAP header attribute mustUnderstand

Deprecated:

use webreferences2 instead

Warning


setHeader(Object, String, String, Object, Boolean, String) 

static setHeader(svc: Object, namespace: String, name: String, xml: Object, mustUnderstand: Boolean, actor: String): void

Creates a new SOAPHeaderElement with the name and namespace and places the given XML into it.

1var usernameToken : XML =
2  <wsse:UsernameToken xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
3      <wsse:Username>{merchantID}</wsse:Username>
4      <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">
5          {merchantPassword}
6      </wsse:Password>
7  </wsse:UsernameToken>
8SOAPUtil.setHeader( service, "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd",
9 "Security", usernameToken, true, null

Parameters:

  • svc - a service stub returned from getService()
  • namespace - the namespace of the header element
  • name - the element name for the header element
  • xml - a E4X XML object
  • mustUnderstand - sets the SOAP header attribute 'mustUnderstand'
  • actor - the SOAP actor, which should be set for this header element. null removes any actor.

Deprecated:

use webreferences2 instead

Warning


setHeader(Object, String, String, String) 

static setHeader(svc: Object, namespace: String, name: String, xml: String): void

Creates a new SOAPHeaderElement with the name and namespace and places the given XML into it.

Parameters:

  • svc - a service stub returned from getService()
  • namespace - the namespace of the header element
  • name - the element name for the header element
  • xml - a string with arbitrary XML content

Deprecated:

use webreferences2 instead

Warning


setHeader(Object, String, String, String, Boolean) 

static setHeader(svc: Object, namespace: String, name: String, xml: String, mustUnderstand: Boolean): void

Creates a new SOAPHeaderElement with the name and namespace and places the given XML into it.

Parameters:

  • svc - a service stub returned from getService()
  • namespace - the namespace of the header element
  • name - the element name for the header element
  • xml - a string with arbitrary XML content
  • mustUnderstand - sets the SOAP header attribute mustUnderstand

Deprecated:

use webreferences2 instead

Warning


setHeader(Object, String, String, String, Boolean, String) 

static setHeader(svc: Object, namespace: String, name: String, xml: String, mustUnderstand: Boolean, actor: String): void

Creates a new SOAPHeaderElement with the name and namespace and places the given XML into it.

Parameters:

  • svc - a service stub returned from getService()
  • namespace - the namespace of the header element
  • name - the element name for the header element
  • xml - a string with arbitrary XML content
  • mustUnderstand - sets the SOAP header attribute mustUnderstand
  • actor - the SOAP actor, which should be set for this header element. null removes any actor.

Deprecated:

use webreferences2 instead

Warning


setWSSecurityConfig(Object, Object, Object) 

static setWSSecurityConfig(svc: Object, requestConfigMap: Object, responseConfigMap: Object): void

Sets the WS-Security configuration for the request and response based on the constants defined.

Parameters:

  • svc - a service stub returned from getService()
  • requestConfigMap - the WS-Security request config
  • responseConfigMap - the WS-Security response config

Deprecated:

use webreferences2 instead

Warning