[SalesForce] How to Construct SOAP XML Request in apex

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <SOAP-ENV:Header>

  </SOAP-ENV:Header>

</SOAP-ENV:Envelope>

Please help me in building the XML Request Structure in apex.I have started like this Is this Correct?

Best Answer

One way would be to create XML using String concatenation. This makes generated XML very much readable.

String requestInput = '?xml version="1.0" encoding="UTF-8"?>'+
        '<SOAP-ENV:Envelope '+
        ' xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" '+
        ' xmlns:xsd="http://www.w3.org/2001/XMLSchema" '+
        ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> '+
        ' <SOAP-ENV:Header> '+
        ' </SOAP-ENV:Header>';
Related Topic