AddXml (HttpRequest subroutine): Difference between revisions
m (match syntax table to syntax template; edits, tags and links) |
m (→Usage notes) |
||
Line 33: | Line 33: | ||
<ul> | <ul> | ||
<li>The <var>XmlDoc</var> that is passed is serialized into the post data of the request being built. It is not required that you serialize the <var>XmlDoc</var> first. | <li>The <var>XmlDoc</var> that is passed is serialized into the post data of the request being built. It is not required that you serialize the <var>XmlDoc</var> first. | ||
<li>Invoking this method erases any post data previously added by <var>AddXml</var> or <var>[[ | <li>Invoking this method erases any post data previously added by <var>AddXml</var> or <var>[[AddLongstring (HttpRequest subroutine)|AddLongstring]]</var> method calls. | ||
<li>If you do not explicitly set a content-type HTTP request header via <var>[[AddHeader (HttpRequest subroutine)|AddHeader]]</var>, <var>AddXml</var> generates a content-type header of "text/xml" upon a Post. To suppress this automatic header generation, you can set the <var>[[AutoSendXmlContentType (HttpRequest property)|AutoSendXmlContentType]]</var> property to <code>False</code>. | <li>If you do not explicitly set a content-type HTTP request header via <var>[[AddHeader (HttpRequest subroutine)|AddHeader]]</var>, <var>AddXml</var> generates a content-type header of "text/xml" upon a Post. To suppress this automatic header generation, you can set the <var>[[AutoSendXmlContentType (HttpRequest property)|AutoSendXmlContentType]]</var> property to <code>False</code>. | ||
<li>The <var class="term">options</var> may be specified in any case, for example, you can use | <li>The <var class="term">options</var> may be specified in any case, for example, you can use |
Revision as of 16:52, 21 June 2011
Add an XmlDoc to POST data for this request (HttpRequest class)
The AddXml subroutine adds a Janus SOAP XmlDoc object instance to the HTTP Post data that is subsequently sent on a Post method invocation.
Syntax
httpRequest:AddXml( doc, [options])
Syntax terms
httpRequest | A previously defined and instantiated HttpRequest object. |
---|---|
doc | A previously defined and instantiated XmlDoc object. |
options | Any combination of the following options (but single occurrences only):
Note: These options are described in greater detail in "XmlDoc API serialization options". |
Usage notes
- The XmlDoc that is passed is serialized into the post data of the request being built. It is not required that you serialize the XmlDoc first.
- Invoking this method erases any post data previously added by AddXml or AddLongstring method calls.
- If you do not explicitly set a content-type HTTP request header via AddHeader, AddXml generates a content-type header of "text/xml" upon a Post. To suppress this automatic header generation, you can set the AutoSendXmlContentType property to
False
. - The options may be specified in any case, for example, you can use
either
NoXmlDecl
ornoxmldecl
, interchangeably. - If one of the line-end (
CR
,LF
,CRLF
) options or ifIndent
is specified, and an element to be serialized has thexml:space="preserve"
attribute, then within the serialization of that element and its descendants, no line-end (nor indentation) characters are inserted to provide readability. Additionally, thexml:space="default"
attribute has no effect under these options. Specified by itself, it does not influence serialization, nor does it cause resumption of readability line-ends or indents if they were suspended by a containingxml:space="preserve"
.
Examples
- The following example shows the effect of the NoEmptyElt option:
begin %d is object xmlDoc %d = new %htr is object httpRequest %htr = new %sl is object stringlist %sl = new text to %sl <top p:abc="p" q:xyz="q" xmlns:p="urn:p" xmlns:q="http://q.com" name="t" id="z15" /> end text %d:loadXml(%sl) %htr:addXml(%d, 'NoEmptyElt') print %d:Serial(, 'EBCDIC NoEmptyElt') end
The print statement above (which uses the Janus SOAP XmlDoc API serial method) displays the resulting XmlDoc content added to the HttpRequest object (formatted with some newlines for the sake of instruction):
<top xmlns:p="urn:p" xmlns:q="http://q.com" p:abc="p" q:xyz="q" name="t" id="z15"> </top>
Comments:
-
NoEmptyElt produces an STag (
<top ...>
) and an ETag (</top>
) for an empty element, rather than just the EmptyElemTag (<top ...>
).
-
NoEmptyElt produces an STag (