login about faq

How can the Chilkat XML API be used to generate SOAP in Delphi like below? This is to be used as the XML body of an HTTP request.

<?xml version="1.0" encoding="UTF-8" ?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
        <vwa:Country wsa:isReferenceParameter="true">CN</vwa:Country>
        <vwa:Brand wsa:IsReferenceParameter="true">V</vwa:Brand>
        <vwa:Stage wsa:IsReferenceParameter="true">QualityAssurance</vwa:Stage>
        <GetQuote xmlns="http://www.webserviceX.NET/">
                <B2 xmlns="http://www.webserviceX.net/” >

asked Feb 20 '14 at 10:12

chilkat's gravatar image

chilkat ♦♦

My recommendation is that there is no need to use an XML API (Chilkat or otherwise) to generate XML that is structurally the same in every case, except for the various pieces that compose the actual content. An XML API is good for parsing existing XML to extract information, or for modifying existing XML, but to create XML that is nothing more than boilerplate + plugged-in values, using an XML API is over-complicating matters.

What I would recommend is to simply insert the pre-composed and "templated" SOAP XML string directly within your source code. For example:

soapXmlStr := '<?xml version="1.0" encoding="UTF-8" ?> .... 
    <A1>STOCK_SYMBOL</A1> .... 

Then simply write code that does string replacements for the various parts: Replace "STOCK_SYMBOL" with the actual value, etc. You then have the SOAP XML that can be passed to the Chilkat HTTP method.

There is no need to use an XML API to build an XML string that can just as well be built with simple string pattern replacement, or alternatively, simple string concatenation.


answered Feb 20 '14 at 10:21

chilkat's gravatar image

chilkat ♦♦

edited Feb 20 '14 at 10:23

I agree your solution. However, I don't want to save XML to file and load it again to Chilkat HTTP method.

Is there any possible to use Chilkat XML component to assign the value of the specific nodes?

I found "IChilkatXml.FindChild()" method can do find the specific node, but how can I assign the value to node?

For example: soapReq := TChilkatXml.Create(Self).ControlInterface; soapReq.LoadXmlFile(programpath+XML_temp); soapReq.FindChild('A1').Content:='32434';<----------------------Here returns error. soapReq.GetRoot2();


answered Feb 21 '14 at 07:49

sam's gravatar image


There is no file in the solution I proposed. The XML template is nothing more than a literal string in your Delphi source code. It is NOT loaded from a file.


answered Feb 21 '14 at 08:01

chilkat's gravatar image

chilkat ♦♦

I do follow your suggestion, but I found it quite hard to make sure the value of the each XML nodes should not exist anywhere else in the XML or any other phrase has part of it. Especially for some XML has thousands nodes...


answered Feb 21 '14 at 09:18

sam's gravatar image


Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: Feb 20 '14 at 10:12

Seen: 4,724 times

Last updated: Feb 21 '14 at 09:18

powered by OSQA