This call modifies the SOAP header to include an OASIS security header. It adds a wsse:Security element with a wsse:UsernameToken of the specified password type. Any existing wsse:Security element is replaced by the new element.
The following table describes the parameters and return value.
Parameter |
Description |
---|---|
url |
The URL for a SOAP HTTP endpoint, e.g. http://serverName:portNumber/URI |
request object |
An object that specifies the remote procedure name and parameters of the XML message to send; see separate section below |
action |
The SOAPAction, a URN written to an HTTP header used by firewalls and servers to filter SOAP requests; the SOAP service description will usually describe the SOAPAction header required, if any The default is for the action to be an empty string |
response object |
An object that describes the return value received by the remote procedure call; see separate section below |
username |
The username used for authentication |
password |
The password used for authentication |
passwordtype |
One of "PasswordText" or "PasswordDigest". |
In the request object, a qualified name is specified as a string in the <namespace>:<localname> notation, where <namespace> can be a custom namespace or one of the predefined prefixes "xsd" (http://www.w3.org/2001/XMLSchema) or "SOAP-ENC" (http://schemas.xmlsoap.org/soap/encoding/).
For example:
"http://soapinterop.org/:param1" "xsd:int"
The request object is an object literal that specifies the remote procedure name and the parameters to call. The object literal uses the qualified method name of the remote procedure as the key. The value of this key is an object literal in which each key is a parameter of the method and the value of each key is the value of the corresponding parameter of the method.
For example:
{ "http://soapinterop.org/:echoString":{inputString: "Echo!"} }
When passing parameters to a remote procedure, JavaScript types are bound to SOAP types automatically as listed in the following table.
JavaScript type |
SOAP type |
Comments |
---|---|---|
Boolean |
xsd:boolean |
|
Number |
xsd:float |
|
String |
xsd:string |
|
Date |
xsd:dateTime |
|
Array |
SOAP-ENC:Array |
Single-dimension arrays only All items must have the same data type, which must be Boolean, Number, String or Date |
ByteArray |
SOAP-ENC:base64 |
Uses the ByteArray "Base64" codec |
Other |
Not supported |
Causes an exception to be thrown |
Instead of providing one of these JavaScript data types, a parameter value can also be represented by a literal object with the following properties:
Property |
Description |
---|---|
soapType : String |
The SOAP type (as a qualified type name) that will be used for the value when generating the SOAP message; this is useful when a datatype is needed other than the automatic bindings described above |
soapValue : String |
The value that will be used when generating the SOAP message The value is passed unescaped (example: "<" is not converted to "<") which means that it can be a raw XML fragment that will be passed on as is |
For example, integers are not supported in JavaScript but an integer parameter to a SOAP method can be constructed as follows:
var iPar = { soapType: "xsd:int", soapValue: "1" }; { "http://soapinterop.org/:echoInteger": { inputInteger: iPar } }
The header-object is an object literal that specifies the soap header to be included. The object literal uses the qualified name of the header XML element(s) as the key. The value of this key is encoded like a request-object.
For example:
{ "http://example.org/2001/06/tx:Transaction":5, "http://example.org/2001/06/tx:PaymentOption":10}
will create the following header:
<env:Header xmlns:env="http://www.w3.org/2003/05/soap-envelope" > <t:Transaction xmlns:t="http://example.org/2001/06/tx"> 5 </t:Transaction> <t: PaymentOption xmlns:t="http://example.org/2001/06/tx"> 10 </t: PaymentOption > </env:Header>
The function returns an object describing the SOAP Body of the returned message in a manner similar to the request object.
The SOAP types in the result are mapped to JavaScript types as listed in the following table.
SOAP type |
JavaScript type |
Comments |
---|---|---|
xsd:boolean |
Boolean |
|
xsd:integer |
Number |
|
xsd:float |
Number |
|
xsd:string |
String |
|
xsd:dateTime |
Date |
|
SOAP-ENC:Array |
Array |
Single-dimension arrays only All items must have the same data type, which must be boolean, integer, float, string or dateTime |
xsd:hexBinary |
ByteArray |
Uses the ByteArray "Hex" codec |
xsd:base64Binary |
ByteArray |
Uses the ByteArray "Base64" codec |
SOAP-ENC:base64 |
ByteArray |
Uses the ByteArray "Base64" codec |
Other |
String |
Copies the XML string content without change |
var url = <get a URL for this service from http://www.whitemesa.com/interop.htm>; // Call the echoString SOAP method var testString = "This is my test string"; var response = SOAP.request( url, { "http://soapinterop.org/:echoString": { inputString: testString } }, "http://soapinterop.org/" ); var result = response["http://soapinterop.org/:echoStringResponse"]["return"]; // Call the echoInteger SOAP method var testInt = { soapType: "xsd:int", soapValue: "10" }; var response = SOAP.request( url, { "http://soapinterop.org/:echoInteger": { inputInteger: testInt } }, "http://soapinterop.org/" ); var result = response["http://soapinterop.org/:echoIntegerResponse"]["return"];