15
SOAP and Web Services
Using SOAP and Web Services
Establishing a Synchronous Connection
The
SOAP
object’s
request
method may be used to establish a synchronous connection
with a web service. To establish the connection and invoke the web methods, it is necessary
to provide the
cURL
,
oRequest
, and
cAction
parameters. The example below
demonstrates how to invoke the same web services used in the previous example.
Similar to the parameter used in the
connect
method, the
cURL
parameter contains the
URL for the WSDL document. For the purposes of our example, assume that
myURL
represents the WSDL document location.
The
oRequest
parameter is a fully qualified object literal specifying both the web method
name and its parameters, in which the namespace is separated from the method name by a
colon. It may also contain the following properties:
●
●
●
●
●
●
soapType
: the SOAP type used for the value
soapValue
: the SOAP value used when generating the message
soapName
: the element name used when generating the SOAP message
soapAttributes
: an object containing the XML attributes in the request node
soapQName
: the namespace-qualified name of the request node
soapAttachment
: determines whether
soapValue
is encoded as an attachment
according to the SwA/MTOM
®
specification. In this case,
soapValue
will be a stream.
Assume that the namespace is
http://mydomain/methods,
the method name is
echoString
, and it accepts a string parameter called
inputString
. The following code
represents the
oRequest
parameter:
var echoStringRequest = {
"http://mydomain/methods:echoString {
inputString: "This is a test."
}
};
The
cAction
parameter contains header information described by the WSDL document
that is used by firewalls to filter SOAP requests. In our example, we will supply the location
of the WSDL document:
var mySOAPAction = "http://mydomain/methods";
We may now invoke the
echoString
web method:
var response = SOAP.request ({
cURL: myURL,
oRequest: echoStringRequest,
cAction: mySOAPAction
});
248
Acrobat JavaScript Scripting Guide