This chapter provides a complete listing and reference for the methods in the OpenScript WSService Class of WebService Module Application Programming Interface (API).
The following section provides an alphabetical listing of the enums in the OpenScript WSService API.
The following section provides an alphabetical listing of the methods in the OpenScript WSService API.
The following table lists the WSService API methods in alphabetical order.
Table 27-2 List of WSService Methods
Method | Description |
---|---|
Add Security Attachment property settings to current URL. |
|
Convenience method to create a new Attachment. |
|
Convenience method to create a new Attachment[]. |
|
Request a web service using an HTTP POST method with requestSoap string, headers, URL encoding, and character sets. |
|
Performs a RESTful DELETE operation. |
|
Performs a RESTful GET operation. |
|
Performs a RESTful PATCH operation. |
|
Performs a RESTful POST operation. |
|
Performs a RESTful PUT operation. |
|
Convenience method to create a new WSSecurity object with a specified timeout value. |
|
Extract values from the browser's last retrieved contents using XPath notation. |
The following sections provide detailed reference information for each method and enum in the WSService Class of WebService Module Application Programming Interface.
Add Security Attachment property settings to current URL.
The ws.addSecurityAttachments method has the following command format(s):
ws.addSecurityAttachments(url, security, attachments);
a String specifying the URL to request.
a WSSecurity object specifying the security settings for the specified URL.
a WSAttachments object specifying the attachment settings for the specified URL.
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Add Security Attachments with indicated property settings.
//No username token ws.addSecurityAttachments("http://myserver/EmployeeLookup.asmx", null, null); //Username, Password Text ws.addSecurityAttachments("http://myserver/EmployeeLookup.asmx", ws.security("username", decrypt("sO7ijipCONXoxAURd+8BQw=="), true, false, false), null); //Username, Password digest ws.addSecurityAttachments("http://myserver/EmployeeLookup.asmx", ws.security("username", decrypt("sO7ijipCONXoxAURd+8BQw=="), false, false, false), null); //Username, Password text, Add Created Header ws.addSecurityAttachments("http://myserver/EmployeeLookup.asmx", ws.security("username", decrypt("sO7ijipCONXoxAURd+8BQw=="), true, true, false), null); //Username, Password text, Add Timestamp, valid for 10 seconds ws.addSecurityAttachments("http://myserver/EmployeeLookup.asmx", ws.security("username", decrypt("sO7ijipCONXoxAURd+8BQw=="), true, false, false, 10), null); //Username, Password text, Add Nonce ws.addSecurityAttachments("http://myserver/EmployeeLookup.asmx", ws.security("username", decrypt("sO7ijipCONXoxAURd+8BQw=="), true, false, true), null); //Username, Password text, Add Created Header, //Add Timestamp, valid for 10 seconds, Add Nonce ws.addSecurityAttachments("http://myserver/EmployeeLookup.asmx", ws.security("username", decrypt("sO7ijipCONXoxAURd+8BQw=="), true, true, true, 10), null); //Username, Password text, Add Created Header, //Add Timestamp, valid for 10 seconds, Add Nonce //With attachments ws.addSecurityAttachments("http://myserver/EmployeeLookup.asmx", ws.security("username", decrypt("sO7ijipCONXoxAURd+8BQw=="), true, true, true, 10), ws.attachments(AttachmentMechanism.DEFAULT, ws.attachment("C:\\MTOMService.xml", "attachmentPart"), ws.attachment("C:\\SecureService.xml","attachmentPart")));
Convenience method to create a new Attachment.
The ws.attachment method has the following command format(s):
ws.attachment(filename, attachmentPart);
a String specifying the attachment file name.
a String specifying the Attachment part.
Add Security with indicated attachments.
ws.addSecurityAttachments("http://myserver/EmployeeLookup.asmx", ws.security("username", decrypt("sO7ijipCONXoxAURd+8BQw=="), true, true, true, 10), ws.attachments(AttachmentMechanism.DEFAULT, ws.attachment("C:\\MTOMService.xml", "attachmentPart"), ws.attachment("C:\\SecureService.xml","attachmentPart")));
The AttachmentMechanism has the following values:
Table 27-3 List of AttachmentMechanism Values
Value | Description |
---|---|
DEFAULT |
Specifies the default transfer type specified by the Content-Type header. |
SWA |
Specifies Security SOAP Messages with Attachments. |
MTOM |
Specifies SOAP Message Transmission Optimization Mechanism. |
DIME |
Specifies Direct Internet Message Encapsulation. |
Convenience method to create a new Attachment[].
The ws.attachments method has the following command format(s):
ws.attachments(am, attachments);
an AttachmentMechanism enum specifying the attachment transfer type.
the Attachment objects.
Add Security with indicated attachments.
ws.addSecurityAttachments("http://myserver/EmployeeLookup.asmx",
ws.security("username", decrypt("sO7ijipCONXoxAURd+8BQw=="),
true, true, true, 10),
ws.attachments(AttachmentMechanism.DEFAULT,
ws.attachment("C:\\MTOMService.xml", "attachmentPart"),
ws.attachment("C:\\SecureService.xml","attachmentPart")));
Request a web service using an HTTP POST method with requestSoap string, headers, URL encoding, and character sets.
The ws.post method has the following command format(s):
ws.post(recid, url, requestSoap, headers, bEncode, reqCharset, respCharset);
ID of a previously recorded navigation, used for comparison purposes. May be null.
URL to request
A string representation of SOAP contents
a Header array specifying the Additional headers to add/remove from the request before submitting it to the server.
a boolean specifying the parameter encoding. Set to true
to URL-encode the parameters before submitting them to the sever.
a String specifying the character set to use if URL-encoding any of the request parameters.
a String specifying the character set to use when reading the response contents.
Specifies a POST navigation with requestSoap string, headers, URL encoding, and character sets.
//Example UI added Post ws.post(7, "http://myserver/EmployeeLookup.asmx", "requestSoap string", http.headers(http.header("name1", "value1", Header.HeaderAction.Add), http.header("name2", "value2", Header.HeaderAction.SetIfNotSet), http.header("name3", "value3", Header.HeaderAction.GlobalAdd), http.header("name4", "value4", Header.HeaderAction.GlobalSetIfNotSet)), true, "ASCII", "ASCII"); //Example WSDL Manager added Post with requestSoap string ws.post(8,"http://myserver/EmployeeLookup.asmx", "<soapenv:Envelope " + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " + "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " + "xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" " + "xmlns:web=\"http://mysite.com/webservices\">\r\n " + "<soapenv:Header/>\r\n " + "<soapenv:Body>\r\n " + "<web:addEmployee " + "soapenv:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">\r\n " + "<data xsi:type=\"enc:Employee\" " + "xmlns:enc=\"http://mysite.com/webservices/encodedTypes\">\r\n " + "<FirstName xsi:type=\"xsd:string\">string</FirstName>\r\n " + "<LastName xsi:type=\"xsd:string\">string</LastName>\r\n " + "<EmployeeID xsi:type=\"xsd:int\">0</EmployeeID>\r\n " + "<Address xsi:type=\"xsd:string\">string</Address>\r\n " + "<City xsi:type=\"xsd:string\">string</City>\r\n " + "<State xsi:type=\"xsd:string\">string</State>\r\n " + "<Zip xsi:type=\"xsd:string\">string</Zip>\r\n " + "<Phone xsi:type=\"xsd:int\">0</Phone>\r\n " + "</data>\r\n " + "</web:addEmployee>\r\n " + "</soapenv:Body>\r\n " + "</soapenv:Envelope>", http.headers(http.header("Content-Type","text/xml;charset=UTF-8", Header.HeaderAction.Modify), http.header("SOAPAction","\"http://mysite.com/webservices/addEmployee\"", Header.HeaderAction.Modify)), true, null, null);
Performs a RESTful DELETE operation.
The ws.restDelete method has the following command format(s):
ws.restDelete(recid, url, deleteData, headers, bEncode, reqCharset, respCharset);
ID of a previously recorded navigation, used for comparison purposes.
a String specifying the URL for the request to the server.
a String specifying the data to DELETE.
a Header[] object specifying the header data.
a boolean specifying if the data is encoded.
a String specifying the character set to use if URL-encoding any of the request parameters.
a String specifying the character set to use when reading the response contents.
Performs a RESTful GET operation.
The ws.restGet method has the following command format(s):
ws.restGet(recid, url, headers, bEncode, reqCharset, respCharset);
ID of a previously recorded navigation, used for comparison purposes.
a String specifying the URL for the request to the server.
a Header[] object specifying the header data.
a boolean specifying if the data is encoded.
a String specifying the character set to use if URL-encoding any of the request parameters.
a String specifying the character set to use when reading the response contents.
Performs a RESTful PATCH operation.
The ws.restPatch method has the following command format(s):
ws.restPatch(recid, url, patchData, headers, bEncode, reqCharset, respCharset);
ID of a previously recorded navigation, used for comparison purposes.
a String specifying the URL for the request to the server.
a String specifying the data to PATCH to the URL's host.
a Header[] object specifying the header data.
a boolean specifying if the data is encoded.
a String specifying the character set to use if URL-encoding any of the request parameters.
a String specifying the character set to use when reading the response contents.
Performs a RESTful POST operation.
The ws.restPost method has the following command format(s):
ws.restPost(recid, url, postData, headers, bEncode, reqCharset, respCharset);
ID of a previously recorded navigation, used for comparison purposes.
a String specifying the URL for the request to the server.
a String specifying the data to POST to the URL's host.
a Header[] object specifying the header data.
a boolean specifying if the data is encoded.
a String specifying the character set to use if URL-encoding any of the request parameters.
a String specifying the character set to use when reading the response contents.
Performs a RESTful PUT operation.
The ws.restPut method has the following command format(s):
ws.restPut(recid, url, putData, headers, bEncode, reqCharset, respCharset);
ID of a previously recorded navigation, used for comparison purposes.
a String specifying the URL for the request to the server.
a String specifying the data to PUT to the URL's host.
a Header[] object specifying the header data.
a boolean specifying if the data is encoded.
a String specifying the character set to use if URL-encoding any of the request parameters.
a String specifying the character set to use when reading the response contents.
Convenience method to create a new WSSecurity object with a specified timeout value.
The ws.security method has the following command format(s):
ws.security(username, securcode, pplaintextSecurCode, addCreatedHeader, addNonce);
ws.security(username, securcode, plaintextSecurCode, addCreatedHeader, addNonce, timeToLive);
a String specifying the username.
a String specifying the password.
a boolean specifying the password type. true
for Password Text, false
for Password Digest.
a boolean specifying if a created header is added.
a boolean specifying if Nonce is added.
a value specifying the timeout.
Add Security with indicated property settings.
//Username, Password Text ws.addSecurityAttachments("http://myserver/EmployeeLookup.asmx", ws.security("username", decrypt("sO7ijipCONXoxAURd+8BQw=="), true, false, false), null); //Username, Password digest ws.addSecurityAttachments("http://myserver/EmployeeLookup.asmx", ws.security("username", decrypt("sO7ijipCONXoxAURd+8BQw=="), false, false, false), null); //Username, Password text, Add Created Header ws.addSecurityAttachments("http://myserver/EmployeeLookup.asmx", ws.security("username", decrypt("sO7ijipCONXoxAURd+8BQw=="), true, true, false), null); //Username, Password text, Add Timestamp, valid for 10 seconds ws.addSecurityAttachments("http://myserver/EmployeeLookup.asmx", ws.security("username", decrypt("sO7ijipCONXoxAURd+8BQw=="), true, false, false, 10), null); //Username, Password text, Add Nonce ws.addSecurityAttachments("http://myserver/EmployeeLookup.asmx", ws.security("username", decrypt("sO7ijipCONXoxAURd+8BQw=="), true, false, true), null); //Username, Password text, Add Created Header, //Add Timestamp, valid for 10 seconds, Add Nonce ws.addSecurityAttachments("http://myserver/EmployeeLookup.asmx", ws.security("username", decrypt("sO7ijipCONXoxAURd+8BQw=="), true, true, true, 10), null);
Extract values from the browser's last retrieved contents using XPath notation.
The value will be stored to the given variable.
The ws.solveXpath method has the following command format(s):
ws.solveXpath(varName, xpath, resultIndex);
a String specifying the variable name where the value will be stored. Must not be null
.
a String specifying the XPath describing which value to parse from the last retrieved contents. Must not be null
.
an index value specifying the 0-based index of the specific result to retrieve if the XPath returns multiple results. A null
value specifies that all results should be returned.
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
if the XPath cannot be solved.
if happens error when parsing the xpath.
Verifies the Xpath set to the script variable "solvedXPath" can vbe solved.
http.get(13, "http://example.com/stocks/", null,
null, true, "ASCII", "ASCII");
ws.solveXpath("solvedXPath", ".//FORM[@name='loginform']/@action", 0);
if (getVariables().get("solvedXPath").equals("default.asp"))
info ("method \"solveXpath()\" is passed.");
else
warn ("method \"solveXpath()\" is failed.");