How to set text/xml payload using javascript in apigee

I have to set the following request text/xml payload using javascript but I am unable to do it using javascript.

I have to send this payload with http client call 

Also I cannot use assign message for setting the payload since I have to call the http client in loop and the payload will be dynamic

Content Type - text/xml; charset=utf-8

<soapenv:Envelope xmlns:ser="http://service.ws.posidex.com/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">

<soapenv:Header/>
<soapenv:Body>
<ser:findCustomer>
<Demographics>
<RefID>6790001</RefID>
<UserID/>
<ProductID/>
<FirstName>${promoterFirstName.result}</FirstName> ----->"promoterFirstName" of promoters from Initial request
<MiddleName/>
<LastName>${promoterLastName.result}</LastName> ----->"promoterLastName" of promoters from Initial request
<InduCode/>
<LocCode/>
<NegLocMat/>
<NegInduMat/>
<CustType>I</CustType> ----->Static Hardcoded value
<ApplctnNO/>
<DateOfBirth>${promoterDOB}</DateOfBirth> ----->"promoterDOB" of promoters from Initial request. But need to convert the date fromat from DD-MM-YYYY to DD/MM/YYYY
<CompanyName/>
<Pan>${promoterPAN.result}</Pan> ----->"promoterPAN" of promoters from Initial request
</Demographics>
<Address>
<AddrLn1>${promoterAddress1.result}</AddrLn1> ----->"promoterAddress1" of promoters from Initial request
<AddrLn2>${promoterAddress2.result}</AddrLn2> ----->"promoterAddress2" of promoters from Initial request
<AddrLn3>${promoterAddress3.result}</AddrLn3> ----->"promoterAddress3" of promoters from Initial request
<City>${promoterCity.result}</City> ----->"promoterCity" of promoters from Initial request
<Pincode>${promoterPinCode.result}</Pincode> ----->"promoterPinCode" of promoters from Initial request
<CompanyAddr1/>
<CompanyAddr2/>
<CompanyAddr3/>
<CompanyPincd/>
</Address>
<Contact>
<Phone1>${promoterMobileNumber.result}</Phone1> ----->"promoterMobileNumber" of promoters from Initial request
<Phone2/>
<CompanyPhone1/>
<CompanyPhone2/>
</Contact>
</ser:findCustomer>
</soapenv:Body>
</soapenv:Envelope>

 

0 1 359
1 REPLY 1

Not sure why you need to send that way but you can manipulate the request payload with in JS ...Start with below reference & test with simple xml & once you get a hold you know what needs to be done.

tip: search in community for some reference which can help achieve it.

https://www.googlecloudcommunity.com/gc/Apigee/How-to-modify-XML-request-payload-using-Javascript/td...