Web Services, Part IV: WebService Behavior's Objects, Properties, and Events: The result Object - Doc JavaScript
Web Services, Part IV: WebService Behavior's Objects, Properties, and Events
The result Object
The result
object includes four properties (error
, id
, raw
, and value
) and one three-property object (errorDetail
) that includes the properties: code
, raw
, and string
.
The error
property is Boolean. It is generated by the WebService
behavior, after using the callService()
method. A false
value returned means there were no errors. A true
value signals there were errors while calling the remote Web service. In case of errors, the object errorDetail
exists and can provide further details about the errors (code
, raw
, and string
). In case there were no errors, the object errorDetail
is null
, and should not be accessed.
The id
property includes a unique identifier of the callService()
execution. Use this value to match the returned result
object to its corresponding callService()
invocation. If the call to callService()
looks like this:
iCallID = service.MyMath.callService(mathResults, "add", intA, intB);
you would check that result.id
is equal to iCallID
.
The raw
property exposes the SOAP data packet returned from the Web service. This property is valid only when the error
property is true
, because only when the call to the Web service is successful, there is a returned SOAP packet. Use this XML fragment to display a very detailed error message to the user.
The value
property specifies the returned value by the callService()
call. The value
property is determined by the Web service method that has been called. For example, the echoService
Web service echos the argument sent by callService()
.
The result
object exposes the above four parameters and one object, the errorDetail
object. This object is valid only when an error occurs during an invocation of the Web service. It has three properties: code
, raw
, and string
.
The code
property is a string defining a fault type. The four possible values are:
VersionMismatch
MustUnderstand
Client
Server
Try calling a Web service with a wrong function name. You will receive an errorDetail
object where code
is equal to Client
, inferring that the error occurs at the client side, before reaching the Web service.
The raw
property exposes the SOAP data packet returned by the Web service. This property is identical to the result
object's raw
property.
The string
property is a human-readable fault code. If the code
property gives a very brief machine-readable message, the string
property gives a much more elaborate message that makes sense to the user. Try calling a Web service with a wrong function name. You will receive an errorDetail
object where string is "Error is Invalid argument."
The WebService behavior's third object is useOptions
. It can be passed as a parameter to useService()
. It has a single property, reuseConnection
. reuseConnections is a Boolean property that specifies whether to persist the userName
and password
properties from one remote call to another. These properties are required by Secure Socket Layer authentication.
Next: How to use the result object
Produced by Yehuda Shiran and Tomer Shiran
All Rights Reserved. Legal Notices.
Created: December 17, 2001
Revised: December 17, 2001
URL: https://www.webreference.com/js/column99/4.html