AddXml (HttpRequest subroutine): Difference between revisions
mNo edit summary |
mNo edit summary |
||
Line 65: | Line 65: | ||
does it cause resumption of readability line-ends or indents if they were | does it cause resumption of readability line-ends or indents if they were | ||
suspended by a containing <code>xml:space="preserve"</code>. | suspended by a containing <code>xml:space="preserve"</code>. | ||
</ul> | |||
<div id="sortcan"></div> | <div id="sortcan"></div> | ||
==Examples== | |||
The following example shows the effect of the <var>NoEmptyElt</var> option:<p class="code">Begin | |||
%d is object Xmldoc | %d is object Xmldoc | ||
%d = new | %d = new | ||
Line 76: | Line 78: | ||
Text To %sl | Text To %sl | ||
<top p:abc="p" q:xyz="q" | <top p:abc="p" q:xyz="q" | ||
xmlns:p="urn:p" xmlns:q="http://q.com" | xmlns:p="urn:p" xmlns:q=<nowiki>"http://q.com"</nowiki> | ||
name="t" id="z15" | name="t" id="z15" | ||
/> | /> | ||
End Text | End Text | ||
%d:LoadXml(%sl) | %d:LoadXml(%sl) | ||
%htr:AddXml(%d, ' | %htr:AddXml(%d, 'NoEmptyElt') | ||
Print %d:Serial(, 'EBCDIC | Print %d:Serial(, 'EBCDIC NoEmptyElt') | ||
End </p> | End </p> | ||
The <var>Print</var> statement above (which uses the <var>[[Serial (XmlDoc/XmlNode function)|Serial]]</var> method of the <var class="product>[[Janus SOAP]]</var> [[XmlDoc API]]) displays the resulting <var>XmlDoc</var> content added to the <var>HttpRequest</var> object (formatted with some newlines for the sake of instruction): <p class="code"><top | The <var>Print</var> statement above (which uses the <var>[[Serial (XmlDoc/XmlNode function)|Serial]]</var> method of the <var class="product">[[Janus SOAP]]</var> [[XmlDoc API]]) displays the resulting <var>XmlDoc</var> content added to the <var>HttpRequest</var> object (formatted with some newlines for the sake of instruction): <p class="code"><top | ||
xmlns:p="urn:p" xmlns:q=<nowiki>"http://q.com"</nowiki> | |||
xmlns:p="urn:p" xmlns:q="http://q.com" | p:abc="p" q:xyz="q" | ||
name="t" id="z15"> | |||
</top> </p> | </top> </p> | ||
<var>NoEmptyElt</var> produces an STag (<code><top ...></code>) and an ETag (<code></top></code>) for an empty element, rather than just the EmptyElemTag (<code><top ...></code>). | |||
==See also== | ==See also== | ||
{{Template:HttpRequest:AddXml footer}} | {{Template:HttpRequest:AddXml footer}} |
Revision as of 00:05, 17 June 2011
Add an XmlDoc to POST data for this request (HttpRequest class)
This 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
%httpreq | A previously defined and instantiated HttpRequest object. |
---|---|
doc | An XmlDoc object that contains an instantiated XmlDoc object. |
xmloptions | Any combination of the following options (but single occurrences only):
|
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 xmloptions 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. In addition, 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 Serial method of the Janus SOAP XmlDoc API) 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>
NoEmptyElt produces an STag (<top ...>
) and an ETag (</top>
) for an empty element, rather than just the EmptyElemTag (<top ...>
).