dw.ws
Class WSUtil
Object
dw.ws.WSUtil
A utility class for performing SOAP-based operations for Web Services for use with WebReference2. This class provides methods for setting SOAP headers and a set of constants representing the well-known supported header names. You also use this class to set connection and request timeout values for Web Service calls.
See Also:
Constants
KEY_ID_TYPE_DIRECT_REFERENCE  :  String = "DirectReference"
This key identifier method is used when the X.509 Certificate is included in the message. The certificate is Base-64 encoded and included in the request via a BinarySecurityToken element
KEY_ID_TYPE_ENC_KEY_SHA1  :  String = "EncryptedKeySHA1"
This Key Identifier method only applies for Encryption. Unlike the previous methods it refers to the way the EncryptedData references the EncryptedKey Element, rather than the way the EncryptedKey Element refers to the public key.
See Also:
KEY_ID_TYPE_ISSUE_SERIAL  :  String = "IssuerSerial"
This key identifier method means that the Issuer Name and Serial Number of a X.509 Certificate is included directly in the KeyInfo Element.
KEY_ID_TYPE_SKI_IDENTIFIER  :  String = "SKIKeyIdentifier"
This Key Identifier method refers to a Certificate via a Base-64 encoding of the Subject Key Identifier.
KEY_ID_TYPE_THUMBPRINT  :  String = "Thumbprint"
This Key Identifier method refers to the Certificate via a SHA-1 Thumbprint. The certificate may or may not be included in the request.
KEY_ID_TYPE_X509_KEY_IDENTIFIER  :  String = "X509KeyIdentifier"
This key identifier method is similar to KEY_ID_TYPE_DIRECT_REFERENCE, in that the certificate is included in the request. However, instead of referring to a certificate, the certificate is included directly in the KeyInfo element.
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 list of these values.
WS_ENC_KEY_ID  :  String = "encryptionKeyIdentifier"
Defines which key identifier type to use for encryption. Permissible values are:
  • KEY_ID_TYPE_ISSUE_SERIAL (default value)
  • KEY_ID_TYPE_DIRECT_REFERENCE
  • KEY_ID_TYPE_X509_KEY_IDENTIFIER
  • KEY_ID_TYPE_THUMBPRINT
  • KEY_ID_TYPE_SKI_IDENTIFIER
  • KEY_ID_TYPE_ENC_KEY_SHA1
WS_ENC_PROP_KEYSTORE_ALIAS  :  String = "__EncryptionPropKeystoreAlias"
WS-Security Encryption: The encryption and decryption keystore alias name
WS_ENC_PROP_KEYSTORE_PW  :  String = "__EncryptionPropKeystorePassword"
WS-Security Encryption: The encryption and decryption keystore password
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 has the basename of the WSDL file and the file extension based on the keystore type (e.g. MyService.jks). The keystore file has to be placed in the same cartridge directory as the WSDL file.
WS_ENCRYPT  :  String = "Encrypt"
WS-Security action: Encrypt the message. The encryption specific parameters define how to encrypt.
WS_ENCRYPTION_PARTS  :  String = "encryptionParts"
WS-Security Encryption: Defines which parts of the request shall be encrypted.
WS_ENCRYPTION_USER  :  String = "encryptionUser"
WS-Security Encryption: The user's name for encryption.
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. Allowed values are PW_DIGEST or PW_TEXT.
WS_PW_DIGEST  :  String = "PasswordDigest"
WS-Security password type "digest": Use a password digest to send the password information.
WS_PW_TEXT  :  String = "PasswordText"
WS-Security password type "text": Send the password information in clear.
WS_SECRETS_MAP  :  String = "__SecretsMap"
A secrets map with the username and password entries needed to create the password callback object.
WS_SIG_DIGEST_ALGO  :  String = "signatureDigestAlgorithm"
WS-Security Signature: Defines which signature digest algorithm to use.
WS_SIG_KEY_ID  :  String = "signatureKeyIdentifier"
Defines which key identifier type to use for signature. Permissible values are:
  • KEY_ID_TYPE_ISSUE_SERIAL
  • KEY_ID_TYPE_DIRECT_REFERENCE (default value)
  • KEY_ID_TYPE_X509_KEY_ID_IDENTIFIER
  • KEY_ID_TYPE_THUMBPRINT
  • KEY_ID_TYPE_SKI_IDENTIFIER
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 ), default is jks. Note: The keystore file has the basename of the WSDL file and the file extension based on the keystore type (e.g. MyService.jks). The keystore file has to be placed in the same cartridge directory as the WSDL file.
WS_SIGNATURE  :  String = "Signature"
WS-Security action: Sign the message. The signature specific parameters define how to sign and which keys to use.
WS_SIGNATURE_PARTS  :  String = "signatureParts"
WS-Security Signature: Defines which parts of the request shall be signed.
WS_SIGNATURE_USER  :  String = "signatureUser"
WS-Security Signature: The user's name for signature.
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.
Properties
Constructor Summary
WSUtil()
Method Summary
static addSOAPHeader(port : Object, xml : Object, mustUnderstand : boolean, actor : String) : void
Adds a header element to the SOAP Header.
static addSOAPHeader(port : Object, xml : String, mustUnderstand : boolean, actor : String) : void
Adds a header element to the SOAP Header.
static clearSOAPHeaders(port : Object) : void
Removes all SOAP header elements from the port's request context.
static createHolder(element : Object) : Object
Creates an javax.xml.ws.Holder instance that wraps the specified element.
static getConnectionTimeout(port : Object) : Number
Returns the connection timeout value for the port.
static getHTTPRequestHeader(port : Object, key : String) : String
Returns an HTTP request header property value using the specified key.
static getProperty(key : String, port : Object) : Object
Returns the value of the SOAP request property using the specified key on a port returned from one of the WebReference2 getService methods.
static getRequestTimeout(port : Object) : Number
Returns the read timeout value for a request made on the specified port.
static getResponseProperty(key : String, port : Object) : Object
Returns the property value using the specified key and on a port returned from one of the WebReference2 getService methods.
static isAllowChunking(port : Object) : boolean
Returns true if the HTTP request may be chunked, false otherwise
static setAllowChunking(port : Object, allow : boolean) : void
Indicate that HTTP chunked Transfer-Encoding may be used.
static setConnectionTimeout(timeoutInMilliseconds : Number, port : Object) : void
Sets the connection timeout for the port.
static setHTTPRequestHeader(port : Object, key : String, value : String) : void
Sets an HTTP request header property using the specified key and value.
static setProperty(key : String, value : Object, port : Object) : void
Set the SOAP request property using the specified key and value on a port returned from one of the WebReference2 getService() methods.
static setRequestTimeout(timeoutInMilliseconds : Number, port : Object) : void
Sets the read timeout value for a request made on the specified port.
static setUserNamePassword(userName : String, password : String, port : Object) : void
Set the user name and password to use with Basic authentication.
static setWSSecurityConfig(port : Object, requestConfigMap : Object, responseConfigMap : Object) : void
Set the WS-Security configuration for the request and response based on the constants defined (see above).
Constructor Detail
WSUtil
public WSUtil()

Method Detail
addSOAPHeader
static addSOAPHeader(port : Object, xml : Object, mustUnderstand : boolean, actor : String) : void
Adds a header element to the SOAP Header. Each header element should be XML and it should typically contain a namespace URI.
Parameters:
port - the port.
xml - the header element XML. The XML should contain a namespace URI.
mustUnderstand - directs target endpoint to validate payload.
actor - an URI that identifies that intended recipient of this header element.

addSOAPHeader
static addSOAPHeader(port : Object, xml : String, mustUnderstand : boolean, actor : String) : void
Adds a header element to the SOAP Header. Each header element should be XML and it should typically contain a namespace URI.
Parameters:
port - the port.
xml - the header element XML as a String. The XML should contain a namespace URI.
mustUnderstand - directs target endpoint to validate payload.
actor - an URI that identifies that intended recipient of this header element.

clearSOAPHeaders
static clearSOAPHeaders(port : Object) : void
Removes all SOAP header elements from the port's request context.
Parameters:
port - a port returned from one of the WebReference2 getService methods.
See Also:

createHolder
static createHolder(element : Object) : Object
Creates an javax.xml.ws.Holder instance that wraps the specified element. When a WSDL operation is defined to have an input and output message using the same type, the operation may require the operation's object to be wrapped in a holder.
Parameters:
element - the element to be wrapped in the Holder.
Returns:
the holder.

getConnectionTimeout
static getConnectionTimeout(port : Object) : Number
Returns the connection timeout value for the port.
Parameters:
port - a port returned from one of the WebReference2 getService methods.
Returns:
the connection timeout value.
See Also:

getHTTPRequestHeader
static getHTTPRequestHeader(port : 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:
port - a port returned from one of the WebReference2 getService methods.
key - the header property key.
Returns:
an HTTP request header property value using the specified key or null.

getProperty
static getProperty(key : String, port : Object) : Object
Returns the value of the SOAP request property using the specified key on a port returned from one of the WebReference2 getService methods. The property keys are defined as constants in Port.
Parameters:
key - the key to use.
port - the port on which the property is set.
Returns:
the property using the specified key and port.
See Also:

getRequestTimeout
static getRequestTimeout(port : Object) : Number
Returns the read timeout value for a request made on the specified port. If the request exceeds the timeout value, an error is thrown.
Parameters:
port - a port returned from one of the WebReference2 getService methods.
Returns:
the request timeout value for the port.
See Also:

getResponseProperty
static getResponseProperty(key : String, port : Object) : Object
Returns the property value using the specified key and on a port returned from one of the WebReference2 getService methods.
Parameters:
key - the key to use.
port - the port on which the property is set
Returns:
the property using the specified key and port.
See Also:

isAllowChunking
static isAllowChunking(port : Object) : boolean
Returns true if the HTTP request may be chunked, false otherwise
Parameters:
port - a port returned from one of the WebReference2 getService methods.
Returns:
returns true if the HTTP request may be chunked and false otherwise

setAllowChunking
static setAllowChunking(port : Object, allow : boolean) : void
Indicate that HTTP chunked Transfer-Encoding may be used.

The default behavior is true. If false then the request will not be chunked and the Content-Length will always be sent.

Parameters:
port - a port returned from one of the WebReference2 getService methods.
allow - true to enable chunking, false otherwise

setConnectionTimeout
static setConnectionTimeout(timeoutInMilliseconds : Number, port : Object) : void
Sets the connection timeout for the port.
Parameters:
timeoutInMilliseconds - the connection timeout.
port - a port returned from one of the WebReference2 getService methods.
See Also:

setHTTPRequestHeader
static setHTTPRequestHeader(port : Object, key : String, value : String) : void
Sets an HTTP request header property using the specified key and value.
Parameters:
port - a port returned from one of the WebReference2 getService methods.
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.

setProperty
static setProperty(key : String, value : Object, port : Object) : void
Set the SOAP request property using the specified key and value on a port returned from one of the WebReference2 getService() methods. The property keys are defined as constants in Port.
Parameters:
key - the key to use.
value - the value.
port - the port on which the property is set.
See Also:

setRequestTimeout
static setRequestTimeout(timeoutInMilliseconds : Number, port : Object) : void
Sets the read timeout value for a request made on the specified port. If the request exceeds the timeout value, an error is thrown.
Parameters:
timeoutInMilliseconds - the timeout.
port - a port returned from one of the WebReference2 getService methods.
See Also:

setUserNamePassword
static setUserNamePassword(userName : String, password : String, port : Object) : void
Set the user name and password to use with Basic authentication. For stronger authentication, use the setWSSecurityConfig(Object, Object, Object) method.
Parameters:
userName - the user name.
password - the password.
port - a port returned from one of the WebReference2 getService methods.

setWSSecurityConfig
static setWSSecurityConfig(port : Object, requestConfigMap : Object, responseConfigMap : Object) : void
Set the WS-Security configuration for the request and response based on the constants defined (see above).
Parameters:
port - a port returned from one of the WebReference2 getService methods.
requestConfigMap - the WS-Security request configuration.
responseConfigMap - the WS-Security response configuration.
See Also: