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/"
xmlns:wsa="http://www.w3.org/2005/08/addressing"
xmlns:vwa="http://xmldefs.example.com/Technical/Addressing/V1">
    <soapenv:Header>
        <wsa:MessageID>urn</wsa:MessageID>
        &lt;wsa:To>ws://example.com/Wholesale/TelematicEventNotificationService/V1</wsa:To>
        &lt;wsa:Action>http://xmldefs.example.com/Wholesale/TelematicEventNotificationService/V1/TelematicEventNotificationServicePortType/SyncTelematicEvent</wsa:Action>
        <vwa:Country wsa:isReferenceParameter="true">CN</vwa:Country>
        <vwa:Brand wsa:IsReferenceParameter="true">V</vwa:Brand>
        <vwa:Stage wsa:IsReferenceParameter="true">QualityAssurance</vwa:Stage>
    </soapenv:Header>
    <soapenv:Body>
        <GetQuote xmlns="http://www.webserviceX.NET/">
            <A1>MSFT</A1>
            <B1>
                <B2 xmlns="http://www.webserviceX.net/” >
                    <B3>SSS</B3>
               </B2>
           </B1>
            <C1>
                <C2>
                    <C3>VVV</C3>
               </C2>
           </C1>
       </GetQuote>
    </soapenv:Body>
</soapenv:Envelope>

asked Feb 20 '14 at 10:12

chilkat's gravatar image

chilkat ♦♦
11.8k316358421


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> .... 
    </soapenv:Envelope>';

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.

link

answered Feb 20 '14 at 10:21

chilkat's gravatar image

chilkat ♦♦
11.8k316358421

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();

link

answered Feb 21 '14 at 07:49

sam's gravatar image

sam
1114

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.

link

answered Feb 21 '14 at 08:01

chilkat's gravatar image

chilkat ♦♦
11.8k316358421

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...

link

answered Feb 21 '14 at 09:18

sam's gravatar image

sam
1114

Your answer
toggle preview

Follow this question

By Email:

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

By RSS:

Answers

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

Tags:

×186
×59
×11

Asked: Feb 20 '14 at 10:12

Seen: 2,443 times

Last updated: Feb 21 '14 at 09:18

powered by OSQA