The soap Command

The soap command is used to facilitate networked communication by means of SOAP messages. SOAP message objects are also useful to parse other styles of XML -formatted messages which are not really SOAP , for example NCBI Entrez eutils result messages.

SOAP objects are created like other Cactvs objects, and have internal state, so it is possible to communicate with multiple sources simultaneously by creating a SOAP object for every channel.

SOAP objects share many characteristics with JSON objects, and many commands are identical or at least very similar.

These are the currently supported SOAP object commands:

soap append

soap append soaphandle ?attribute value?...
soap append soaphandle dict
s.append(?attribute,value?,...)
s.append(?attribute=value?,...)
s.append(dict)

This is a variant of the soap set command. The difference is that the supplied data is appended to the current attribute value instead of replacing it. In case appending is not a possible operation, the result is the same as using soap set .

The set of supported attributes is explained in the paragraph on soap set .

The command returns the original object handle or reference.

soap create

soap create ?attribute value?...
soap create dict
Soap(?attribute,value?,...)
Soap(dict)
Soap(?attribute=value?,...)
Soap.Create(?attribute,value?,...)
Soap.Create(dict)
Soap.Create(?attribute=value?,...)

Create a new SOAP object. The return value is the new object handle or reference. If no extra attributes are specified, an empty object with default settings is created. Processing of specified optional attribute/value pairs is performed in as an identical fashion to the soap set command.

soap delete

soap delete ?soaphandle?...
soap delete all
s.delete()
Soap.Delete(?sref/shandle?,...)
Soap.Delete(“all”)

Destroy one or more SOAP objects. The special word all can be used to remove all SOAP objects currently defined in the interpreter.

For the sake of consistency with the commands for other objects, soap close is an alias to this command.

The return value is the number of successfully deleted SOAP objects.

soap error

soap error soaphandle ??message? channel? ?code? ?factor?
s.error(?message=?,?channel=?,?code=?,?uri=?)

Send a properly formatted SOAP error message over a Tcl channel to a client, or at least prepare it. If any of the optional arguments behind the channel argument are provided, they are processed like equivalent soap set commands and change the internal attributes of the object.

In the generated message, the message, code and factor values are wrapped into XML tags of type faultstring , faultcode and faultfactor , respectively. Usually, the factor value should be set to the URI of the service, which could be stored in the uri attribute of the SOAP object. This core information is then embedded into a standard SOAP fault envelope. If no channel argument or an empty string is specified, and the internal channel of the SOAP object is undefined, no data is transmitted over the channel, but the message is still formatted. If a valid channel was specified, or the SOAP object has a valid internal channel, the message is immediately transmitted.

The return value of the command is the complete SOAP error message, with header and body. The internal header and body fields of the SOAP object are also updated and allow subsequent individual retrieval of these components.

soap find

soap find soaphandle taglist ?mode? ?contentflags?
s.find(tags=,?mode=?,?contentflags=?)

Find the contents and/or attributes of specific XML tags in a message. The generation of a parse tree (see soap parse command) is a prerequisite for this function. If a parse tree does not yet exist, but the SOAP object has body data, an attempt is automatically made to execute a parse of the full message body data.

The command returns data found inside the first of potentially multiple query tags which matches in case-sensitive fashion a tag in the parse tree, which is traversed depth-first.

The mode argument determines the reporting mode. It can be one of

The type of tag content reported can be configured by the contentflags argument. The argument can be an arbitrary list made from the words

The default output selection is just chardata . If multiple content flags are selected, the order of the elements in an item output list is tag , attributes , chardata and finally children . If a query fails to yield any results, an empty string is returned. In reporting mode all , the item output lists are themselves list elements of the overall result list.

This command is not SOAP -specific but can work in principle on any XML data, for example Entrez eutils output.

soap get

soap get soaphandle attribute
s.get(attribute)
s.attribute
s[attribute]

Query the value of an attribute of a SOAP object. The list of recognized attributes is explained in the paragraph on the soap set command.

The return value of the command is the value of the attribute.

soap list

soap list ?pattern?
Soap.List(?pattern=?)

Return a list of the handles or references of all currently existing SOAP objects in the interpreter. If desired, the list can be filtered by a string pattern.

soap parse

soap parse soaphandle ?starttag? ?classname/instanceindex? ?data?
s.parse(?starttag=?,?class=?,?data=?)

Parse an XML message stored in the body attribute of the object and create the parse tree which is the prerequisite for retrieval of message content via the soap find command. If a data argument is supplied, it replaces the body data of the object.

By default, or when the start tag argument is set to an empty string (or None for Python ), the complete message is parsed. Optionally, processing can be limited to a subsection of the full data that starts with the specified tag. In that case, only the content between the selected opening and closing tags matching the supplied start tag is analyzed, and the argument replaces the tag attribute of the SOAP object. By default the first start tag match is used, but this can be changed with the next optional argument.

In case of multiple tags with the same name in the parsed data, an additional class attribute can be specified as a second element. If this optional filtering argument is used, the first tag block matching both the tag name and having a matching class attribute is extracted and parsed. If the class argument is omitted, or empty, no class filtering is performed. Instead of a class name, it is also possible to specify an integer instance index in the same argument position. By default, the first occurrence of the start tag (index 0) is parsed, but by specifying a different start tag index, a different tag instance may be selected.

The result of the command is the parse tree in nested list representation. This is the same data as the parsetree attribute which can be queried via soap get .

soap read

soap read soaphandle ?channel?
s.read(?channel=?)

Read a message with a HTTP header from a channel. If the channel argument is not supplied, the internally configured SOAP object channel is used. The internal header and body attributes of the object are updated when the read succeeds. Note that this command works with any communication which uses a HTTP header and body data. It is not limited to reading SOAP messages, or even plain XML data.

The reader supports chunked data transmission.

The return value of the command is the received body text. In most applications, this command is followed by a soap parse command, and then multiple soap find commands.

soap ref

Soap.Ref(identifier)

Python -only method to get a reference of the SOAP object from its handle.

soap reformat

soap reformat soaphandle ?text?
s.reformat(?text=?)

Pretty-print an XML blob, with properly indented nested tags for easy visual inspection. If no explicit string is specified, the current body attribute value of the soap object is used. The return value of the command is the reformatted content. The original data is not changed.

This command assumes that the input is not pre-formatted. It does not attempt to remove existing line feeds for formatting whitespace on the input, but rather adds it own formatting on top.

soap request

soap request soaphandle ?method? ?channel? ?parameters? ?uri?
s.request(?method=?,?channel=?,?parameters=?,?uri=?)

Call a SOAP handler on a remote server, or at least prepare the message content to do that. If any of the optional arguments with the exception of the channel argument are provided, they are processed like soap set commands and change the internal attributes of the object. If the uri argument is not supplied, and the SOAP object has no configured uri attribute, a default URI to be used as part of the HTTP POST instruction in the header is constructed from the host , port and method attributes. This URI is not directly used to open a communication channel, though - the Tcl transmission channel can have been opened by any suitable means.

If the channel argument is not supplied, or written as an empty string, and the object has no valid internal handle, the message is just assembled. Otherwise, it is transmitted directly. Using an explicit channel argument does not update the internal channel attribute of the object.

The return value of the command is the assembled SOAP request message, with header and body. The internal header and body fields of the SOAP object are also updated and allow subsequent individual retrievals of these components.

Note that this command just sends the request, but does not wait for or read the server response. Use the soap read command for this purpose.

soap respond

soap respond soaphandle responsedata ?channel? ?method? ?namespace?
s.respond(data=,?channel=?,?method=?,?namespace=?)

Send a properly formatted SOAP response message over a Tcl channel to a client, usually as a response after receiving a SOAP request message from that client. If any of the optional arguments behind channel are provided, they are processed like soap set commands and change the internal attributes of the object

In the generated message, the responsedata value is wrapped into an XML tag of type < methodResponse >, where method is replaced by the name of the configured SOAP method. This core information is then embedded into a standard SOAP envelope and transmitted over the channel. If no channel argument is given, and the internal channel of the SOAP object is undefined, the message is just formatted, but not transmitted.

The return value of the command is the complete SOAP message, with header and body. The internal header and body fields of the SOAP object are also updated and allow subsequent individual retrievals of these components.

soap set

soap set soaphandle ?attribute value?...
soap set soaphandle dict
s.set(?attribute,value?,...)
s.set(dict)
s.set(attribute=value,...)
s.attribute = value
s[attribute] = value

Set one or more attributes of a SOAP object. Since this paragraph is also referenced from the soap get subcommand, the attribute set listed here includes attributes which cannot be set, or for which setting them to any scripted value does not usually make sense.

The currently supported set of attributes is:

soap subcommands

soap subcommands
dir(Soap)

This command returns a list of all the subcommands of the soap command.