class Service
All Implemented Interfaces:
This class is used in conjunction with the XML Mapping Utility to provide transactional support for those services using XML-based messaging.
Support includes those services defined via Schema, XML, XHTML, and WSDL (SOAP). In practice a developer would open General Interface™ Builder
to access the XML Mapping Utility. They would then point the utility at a "pattern master" (i.e., WSDL, Schema, XML, etc) and begin using its
visual tools to bind application objects to nodes in the XML messages to be sent and received.
The output from the Mapping Utility is referred to as a mapping rule set. This rule set is an XML document based upon the Common Exchange Format (CXF)
and defines the information necessary to support transactional data mapping. Many of the APIs available to the Service class allow the devloper to
dynamically update various static values that were set using the XML Mapping Utility.
| Field Summary |
|---|
| static String | event type for unsuccessful response |
| static String | Event type published each time a rule with one or more restrictions fails during message generation. |
| static String | Event type published each time a mapping rule is used to create a node, locate a node, or map to a node. |
| static String | event type for successful response |
| static String | Event type published when the response is still not ready after the specified timeout period. |
| Constructor Summary |
|---|
| void | instance initializer |
| Method Summary |
|---|
| void | Deprecated. Renamed to setRequestHeader. |
| jsx3.xml.Document | Compiles the CXF rules for this service instance to an equivalent XSLT document. |
| boolean | Generates the request message (if applicable) and sends to the remote service. |
| void | Applies all inbound mappings, using the server response document as the source for the operation. |
| String | Gets the URL for the service endpoint where the request will be sent |
| jsx3.xml.Document | Call this method after the service has responded to get a parsed instance of the server's XML response |
| String | Gets the URL for a "typical", XML-formatted server resonse document. |
| String | Gets the method for the request. |
| jsx3.Boolean | Gets the mode (static jsx3.Boolean.FALSE or live jsx3.Boolean.TRUE). |
| String | Gets the namespace for the server/project to run the service instance within. |
| void | Deprecated. Renamed to getOperationName. |
| String | Gets the name of the operation to use within a multi-operation rules file. |
| jsx3.xml.Document | Call this method after 'doCall' has been called to get a parsed instance of the request document--what was actually sent to the remote service |
| String | Gets XPath address for the node in the outbound stub document to which to append the generated message. |
| String | null | Gets URL for the base stub to use for the request message (the XML document to contain the generated document) |
| String | Gets URL for a 'typical' XML-formatted request document to send to the server; when this is set, the mapper does not even attempt to generate a document. |
| jsx3.net.Request | Gets the jsx3.net.HttpRequest instance that performs the transaction with the remote service (the transport object for the message). |
| String | Gets the URL for the rules file to use (a CXF document). |
| jsx3.xml.Document | Returns the rules document used by the Service instance (a CXF document) |
| jsx3.app.Server | Returns the server that this service runs in, as set by the setNamespace() method. |
| jsx3.xml.Document | Gets the request message specific to the MESSAGETYPE (input, output, fault). |
| int | Gets the HTTP response code (i.e. |
| void | Deprecated. Renamed to getOutboundStubURL. |
| String | Returns a CR-LF delimited list of supported namespaces and thei related prefix (as defined by the Object, jsx3.net.Service.ns). |
| String | Gets user name to send as part of the http request (for servers requiring http authentication) |
| String | Gets password to send as part of the http request (for servers requiring http authentication) |
| static void | |
| jsx3.xml.Document | Deprecated. The WSDL is no longer relevant to the Service class as the rules file will contain all information necessary to generate and process the Service interaction.
|
| jsx3.net.Service | Resets the rules tree to default state (with all 'skip' flags removed) from those rules that were skipped during the previous transaction |
| jsx3.net.Service | Dereferences the parsed rules tree (a jsx3.xml.Document instance) managed by this Service instance, forcing a reload of the document from disk the next time the rules document is requested |
| jsx3.net.Service | Sets the URL for the service endpoint where the request will be sent. |
| void | Sets a parsed instance of the response document as soon as it returns from the server returned from the service; otherwise null |
| jsx3.net.Service | Sets the URL for a "typical", XML-formatted server resonse document. |
| void | Sets the method for the request different than the one described in the rules file. |
| void | Sets the mode (static jsx3.Boolean.FALSE or live jsx3.Boolean.TRUE). |
| jsx3.net.Service | Sets the namespace for the server/project to run the service instance within. |
| jsx3.net.Service | Deprecated. Use jsx3.EventDispatcher interface instead with event type jsx3.net.Service.ON_ERROR.
|
| jsx3.net.Service | Deprecated. Use jsx3.EventDispatcher interface instead with event type jsx3.net.Service.ON_SUCCESS.
|
| void | Deprecated. Renamed to setOperationName. |
| jsx3.net.Service | Sets the name of the operation to use within a multi-operation rules file. |
| jsx3.net.Service | Sets the document that will serve as the container for the message generated by doCall and/or getServiceMessage. |
| jsx3.net.Service | Sets XPath address for the node in the outbound stub document to which to append the generated message. |
| jsx3.net.Service | Sets the URL to the document that will serve as the container for the message generated by doCall and/or getServiceMessage. |
| jsx3.net.Service | Sets the URL for a static XML-formatted request document to send to the Service. |
| void | Sets an HTTP Request header on the request. |
| jsx3.net.Service | Sets the URL for the rules file to use (a CXF document). |
| void | Deprecated. Renamed to setEndpointURL. |
| void | Sets the HTTP response code (i.e. |
| void | Deprecated. Renamed to setOutboundStubURL. |
| jsx3.net.Service | Specifies how long to wait for the service to respond before cancelling the call. |
| jsx3.net.Service | Deprecated. Due to browser security constraints, this method is no longer used. Use setTimeout instead. This method no longer affects any aspect of the Service call.
|
| jsx3.net.Service | Sets the user name to send with the posting (for those sites requiring http authentication) |
| jsx3.net.Service | Sets the password to send with the posting (for those sites requiring http authentication) |
| Methods Inherited From jsx3.lang.Object |
|---|
| clone, equals, eval, getClass, getInstanceOf, getInstanceOfClass, getInstanceOfPackage, instanceOf, isInstanceOf, isSubclassOf, jsxmix, jsxsuper, jsxsupermix, setInstanceOf, toString |
event type for unsuccessful response
static final
String ON_INVALID
Event type published each time a rule with one or more restrictions fails during message generation. The following named properties are available on the event object:
-
rule the rule node
-
message the message node
-
target this jsx3.net.Service instance
-
type the type of restriction that caused the invalidation event to be publsihed. For example, pattern.
-
value the value for the type. For example if type is pattern, then [A-Z]*
static final
String ON_PROCESS_RULE
Event type published each time a mapping rule is used to create a node, locate a node, or map to a node.
-
target this jsx3.net.Service instance
-
rule the rule node being processed
-
action the action being performed by the rule. For example,
Create Node, Map to Cache, Invalidate Node, etc.
-
description a description of the 'action'. For example,
this.eval(setValue(2));
-
level the log level (e.g., 'severity' level) for the message. For example,
6 would signify a 'Trace' level event.
static final
String ON_SUCCESS
event type for successful response
static final
String ON_TIMEOUT
Event type published when the response is still not ready after the specified timeout period.
instance initializer
Parameters:
strRulesURL – The resolved URI for the rules document (a CXF document).
Note: since this class is lazily loaded as of v3.2, the preferred method of instantiating this class is by calling the loadResource
method on the context server (jsx3.app.Server) instance. This ensures proper URL resolution while also establishing the
appropriate server context.
strOperationName – name of operation to call. This is only required if the rules file was generated via a WSDL.
strOutboundURL – address of a sample outbound message to use as opposed to the one generated by the tool
strInboundURL – when the project is run in static mode (as defined by the 'project deployment options' dialog),
this document is used to simulate a typical server response
void addHeader()
Deprecated. Renamed to setRequestHeader.
Compiles the CXF rules for this service instance to an equivalent XSLT document. This enables
much faster performance than using the DOM-based iterator (default) to convert the XML response
document into a CDF Document type. Note that this process only supports the map types
CDF Document, CDF Record, and CDF Attribute. Only one CDF Document
can be declared per Operation. Otherwise the compilation will fail.
All other mapping types will be ignored and will not be converted into an XSLT equivalent. Also note
that the order of a set of sibling mapping rules does not proscribe proper processing by way of
sequence. This means that any order of sibling mapping rules will result in appropriate processing, regardless of the
sibling node order returned from the given service. This facilitates nested record structures in that
attributes can first be applied to a given record before child elements (e.g., a 'record') are added.
Stated otherwise, any rule that has a descendant rule that would created a nested 'record' node should follow
all sibling mapping rules that would create an 'attribute' entity. Call this method immediately before/after doCall
for best performance.
Returns:
XSLT document
Generates the request message (if applicable) and sends to the remote service.
Parameters:
bCancelIfInvalid – If true, the remote service will not be called if the message does not pass validation while being generated.
Returns:
true if the message passed all validation rules while being generated.
void doInboundMap()
Applies all inbound mappings, using the server response document as the source for the operation. Although this method is called once automatically, it can be called at any time to reapply the mapping rules.
Example usage:
var oService = new jsx3.net.Service();
oService.setInboundDocument(objSomeDocumentIManuallyWantToLoad);
oService.doInboundMap();
Gets the URL for the service endpoint where the request will be sent
Returns:
Call this method after the service has responded to get a parsed instance of the server's XML response
Returns:
Gets the URL for a "typical", XML-formatted server resonse document. This document is then used when the project is
run in static mode (as defined by the Project Deployment Options).
Returns:
Gets the method for the request. Default is POST
Returns:
one of: GET or POST
Gets the mode (static jsx3.Boolean.FALSE or live jsx3.Boolean.TRUE).
Returns:
Gets the namespace for the server/project to run the service instance within. If a namespace isn't provided, the system will look for the first
application and use its namespace. If no applications exist, the namespace will be completely ignored.
Returns:
void getOperation()
Deprecated. Renamed to getOperationName.
Gets the name of the operation to use within a multi-operation rules file. Note: Rules created via a WSDL often have multiple named operations. Rules files generated without a WSDL contain no named operations, and instead use a single transaction.
Returns:
Call this method after 'doCall' has been called to get a parsed instance of the request document--what was actually sent to the remote service
Returns:
Gets XPath address for the node in the outbound stub document to which to append the generated message.
Returns:
Valid XSL path
String | null getOutboundStubURL()
Gets URL for the base stub to use for the request message (the XML document to contain the generated document)
Returns:
Gets URL for a 'typical' XML-formatted request document to send to the server; when this is set, the mapper does not even attempt to generate a document. Instead, this document is sent directly to the server without any processing. Useful for testing requests that never change
Returns:
Gets the jsx3.net.HttpRequest instance that performs the transaction with the remote service (the transport object for the message).
Returns:
Gets the URL for the rules file to use (a CXF document). This rules file will be used by the Service instance to generate, send, receive and process XML messages
Returns:
Returns the rules document used by the Service instance (a CXF document)
Returns:
Returns the server that this service runs in, as set by the setNamespace() method.
Returns:
See Also:
Gets the request message specific to the MESSAGETYPE (input, output, fault). Typically only used for input (outbound) messages, but can be used for simulating a server response for output and fault (in the case of a SOAP transaction, fault) messages
Parameters:
MESSAGETYPE – one of: input, output, or fault. If this value is provided, the server will generate test data for all nodes lacking a mapped or scripted value
strShellURL – relative URL to message shell to use as the starting container to put content into. Note that calling setOutboundStubURL or setOutboundStubDocument in conjunction with setOutboundStubPath
are preferred to passing this parameter, since they provide much greater control. Also note that this value is stored statically in the rules document when the rules document is first created via the XML Mapping Utility.
Returns:
Gets the HTTP response code (i.e., 200, 404, 500, etc). This will be the response code provided by the bound jsx3.net.Request instance
used for the transport. However, if setStatus has been called on the Service instance, the value supplied by the developer will be used instead.
Returns:
void getStubURL()
Deprecated. Renamed to getOutboundStubURL.
String getSupportedNamespaces()
Returns a CR-LF delimited list of supported namespaces and thei related prefix (as defined by the Object, jsx3.net.Service.ns). Any nodes in a rules document (CXF) that implements one of the namespaces listed by this function, should implement the corresponding namespace prefix as also detailed here.
Returns:
Gets user name to send as part of the http request (for servers requiring http authentication)
Returns:
Gets password to send as part of the http request (for servers requiring http authentication)
Returns:
static void getVersion()
Deprecated.
Gets the release/build for the class (i.e., "2.2.00")
@ returns {String}
Deprecated. The WSDL is no longer relevant to the Service class as the rules file will contain all information necessary to generate and process the Service interaction.
Gets the parsed WSDL (what was used as the original input to create the rules file being used by this service instance).
Returns:
Resets the rules tree to default state (with all 'skip' flags removed) from those rules that were skipped during the previous transaction
Returns:
reference to self
Dereferences the parsed rules tree (a jsx3.xml.Document instance) managed by this Service instance, forcing a reload of the document from disk the next time the rules document is requested
Returns:
reference to self
Sets the URL for the service endpoint where the request will be sent. Overrides the endpoint specified in the rules file.
Parameters:
Returns:
reference to self
Sets a parsed instance of the response document as soon as it returns from the server returned from the service; otherwise null
Parameters:
Sets the URL for a "typical", XML-formatted server resonse document. This document is then used when the project is
run in static mode (as defined by the Project Settings dialog). Overrides the static setting in the rules file.
Parameters:
strInboundURL – Alternate URL for the "typical" Service response. Note that this URL will be resolved
relative to the context server. For example, if the project directory for the context server is 'test',
then the following inputs (all of which are valid) are equivalent: jsxapp://test/xml/typical.xml,
and xml/typical.xml, and JSXAPPS/test/xml/typical.xml
Returns:
reference to self
See Also:
void setMethod(METHOD
: String)
Sets the method for the request different than the one described in the rules file.
Parameters:
METHOD – one of: GET or POST
Sets the mode (static jsx3.Boolean.FALSE or live jsx3.Boolean.TRUE). Overrides the default setting for the context Server
instance within which this Service instnace is running. (NOTE: This setting is accessible at the server level via the Project Settings dialog.)
Setting this value to jsx3.Boolean.FALSE, forces a test document
to be used to simulate a "typical" server response, instead of actually sending a request to a remote service. This is useful when setting up
test environments as well as providing "live" interactions when the remote server may not be available.
Parameters:
See Also:
Sets the namespace for the server/project to run the service instance within.
Parameters:
namespace – the server (preferred) or the namespace of the server.
Returns:
this object
Deprecated. Use jsx3.EventDispatcher interface instead with event type jsx3.net.Service.ON_ERROR.
sets the script that will fire after the service has failed; if a soap fault envelope is returned, this will be processed as would any mapped tree. Allows for object repaints, cleanup, etc.
Parameters:
vntItem – either a script (as string) to execute via eval or a function that will be notified. Note: this function will receive a single parameter, a reference to this jsx3.net.Service instance
Returns:
reference to self
Deprecated. Use jsx3.EventDispatcher interface instead with event type jsx3.net.Service.ON_SUCCESS.
Sets the script that will fire after the service has finished an inbound mapping or a function to callback to; allows for object repaints, cleanup, etc
Parameters:
vntItem – either a script (as string) to execute via eval or a function that will be notified when the service call completes. Note: this function will receive a single parameter, a reference to this jsx3.net.Service instance
Returns:
reference to self
void setOperation()
Deprecated. Renamed to setOperationName.
Sets the name of the operation to use within a multi-operation rules file. Note: Rules created via a WSDL often have multiple operations
Parameters:
strOperationName – operation name
Returns:
reference to self
Sets the document that will serve as the container for the message generated by doCall and/or getServiceMessage.
This is a useful way to dynamically assemble documents by chaining multiple service instances, using the output from one service as the input to another.
For example, when a SOAP Envelope requires both a SOAP Header as well as a SOAP Body, this method allows the Envelope to be assembled via a
two-step process of first adding mapped content to the Body, followed by a call to add mapped content to the Header.
Note that this method takes precedence over the static stub document url referenced in the rules file as well as
any call to setOutboundStubURL. Use this method in conjunction with setOutboundStubPath to
point to theer, a reference to this jsx3.net.Service instance
Returns:
reference to self
Deprecated. Use jsx3.EventDispatcher interface instead with event type jsx3.net.Service.ON_SUCCESS.
Sets the script that will fire after the service has finished an inbound mapping or a function to callback to; allows for object repaints, cleanup, etc
Parameters:
vntItem – either a script (as string) to execute via eval or a function that will be notified when the service call completes. Note: this function will receive a single parameter, a reference to this jsx3.net.Service instance
Returns:
reference to self
void setOperation()
Deprecated. Renamed to setOperationName.
Sets the name of the operation to use within a multi-operation rules file. Note: Rules created via a WSDL often have multiple operations
Parameters:
strOperationName – operation name
Returns:
reference to self
Sets the document that will serve as the container for the message generated by doCall and/or getServiceMessage.
This is a useful way to dynamically assemble documents by chaining multiple service instances, using the output from one service as the input to another.
For example, when a SOAP Envelope requires both a SOAP Header as well as a SOAP Body, this method allows the Envelope to be assembled via a
two-step process of first adding mapped content to the Body, followed by a call to add mapped content to the Header.
Note that this method takes precedence over the static stub document url referenced in the rules file as well as
any call to setOutboundStubURL. Use this method in conjunction with setOutboundStubPath to
point to the specific location in the document where the generated message should be appended.
Parameters:
Returns:
reference to self
See Also:
Sets XPath address for the node in the outbound stub document to which to append the generated message.
Overrides the static setting in the rules file.
Parameters:
strPath – Valid XSL path. For example, /SOAP-ENV:Envelope/SOAP-ENV:Body
Returns:
reference to self
See Also:
Sets the URL to the document that will serve as the container for the message generated by doCall and/or getServiceMessage.
Overrides the static setting stored in the rules file. Use this method in conjunction with setOutboundStubPath to
point to the specific location in the document where the generated message should be appended.
Parameters:
strURL – URL for the document. Note that this URL will be resolved relative to the context server.
For example, if the project directory for the context server is 'test', then the following inputs (all of which are valid) are
equivalent: jsxapp://test/xml/typical.xml, and xml/typical.xml, and JSXAPPS/test/xml/typical.xml
Returns:
reference to self
See Also:
Sets the URL for a static XML-formatted request document to send to the Service. Note that when this is set, the mapper does not even
attempt to generate a request document via the rules file. Instead, the static request document is sent directly to the remote Service
without any processing. This is useful for requests that never change or as a means to test whether a Service is working, using a known, valid input.
Parameters:
strOutboundURL – Alternate URL for the static request to send. Note that this URL will be resolved relative
to the context server. For example, if the project directory for the context server is 'test', then the following inputs
(all of which are valid) are equivalent: jsxapp://test/xml/typical.xml, and xml/typical.xml,
and JSXAPPS/test/xml/typical.xml
Returns:
reference to self
Sets an HTTP Request header on the request. Set before calling, doCall()
Parameters:
strName – name for header parameter
strValue – value for the header parameter
Sets the URL for the rules file to use (a CXF document). This rules file will be used by the Service instance to generate, send, receive and process XML messages
Parameters:
Returns:
reference to self
void setServiceURL()
Deprecated. Renamed to setEndpointURL.
void setStatus(intStatus
: int)
Sets the HTTP response code (i.e., 200, 404, 500, etc). Typically, the Service instance determines this value by querying the bound request instance
(jsx3.net.Request) returned by the method, [service_instance].getRequest(). However, calling this method will override
normal operation by forcing a valid/invalid state that affects methdods relying on the HTTP status
such as doInboundMap. This is particularly useful for SOAP services that provide alternate processing
instructions and mappings when a Fault occurs as well as when running tests in Static mode.
Parameters:
void setStubURL()
Deprecated. Renamed to setOutboundStubURL.
void setStubURL()
Deprecated. Renamed to setOutboundStubURL.
Specifies how long to wait for the service to respond before cancelling the call. Subscribes to the ON_TIMEOUT event
Parameters:
intTimeout – number of milliseconds to wait befor publishing the ON_TIMEOUT event.
objHandler – if an object, the instance to notify of events (objFunction is required); if a string, the JSX id of the instance to notify of events (objFunction is required), must exist in the same Server; if a function, the function to call to notify of events (objFunction ignored)
objFunction – if objHandler is a string or object then the function to call on that instance. either a function or a string that is the name of a method of the instance
Returns:
reference to self
Deprecated. Due to browser security constraints, this method is no longer used. Use setTimeout instead. This method no longer affects any aspect of the Service call.
Specifies timeout settings for resolving the domain name, establishing the connection to the server, sending the data, and receiving the response. The timeout parameters of the setTimeouts method are specified in milliseconds, so a value of 1000 would represent 1 second. A value of zero represents an infinite timeout. There are four separate timeout parameters: resolveTimeout, connectTimeout, sendTimeout, and receiveTimeout. When calling the setTimeouts method, all four values must be specified. The timeouts are applied at the Winsock layer.
Parameters:
intResolveTimeout – The value is applied to mapping host names (such as "www.microsoft.com") to IP addresses; the default value is infinite, meaning no timeout.
intConnectTimeout – The value is applied to establishing a communication socket with the target server, with a default timeout value of 60 seconds.
intSendTimeout – The value applies to sending an individual packet of request data (if any) on the communication socket to the target server. A large request sent to a server will normally be broken up into multiple packets; the send timeout applies to sending each packet individually. The default value is 5 minutes.
intReceiveTimeout – The value applies to receiving a packet of response data from the target server. Large responses will be broken up into multiple packets; the receive timeout applies to fetching each packet of data off the socket. The default value is 60 minutes.
Returns:
reference to self
Sets the user name to send with the posting (for those sites requiring http authentication)
Parameters:
Returns:
reference to self
Sets the password to send with the posting (for those sites requiring http authentication)
Parameters:
strPass – password for user
Returns:
reference to self
Copyright © 2001-2007, TIBCO Software Inc.